From c2ad4d4858beaf13519ce73d3bfbb8e5f5d7e446 Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Wed, 18 Jan 2023 14:08:26 +0100 Subject: [PATCH 1/2] bump msrv to 1.63 --- .github/workflows/build.yml | 16 ++++------------ .github/workflows/msrv-rust-toolchain.toml | 3 --- helix-term/src/lib.rs | 2 ++ rust-toolchain.toml | 2 +- 4 files changed, 7 insertions(+), 16 deletions(-) delete mode 100644 .github/workflows/msrv-rust-toolchain.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d6fcb3e8426..e6b89c7aeeb7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,19 +9,11 @@ on: jobs: check: - name: Check + name: Check (msrv) runs-on: ubuntu-latest - strategy: - matrix: - rust: [stable, msrv] steps: - name: Checkout sources uses: actions/checkout@v3 - - - name: Use MSRV rust toolchain - if: matrix.rust == 'msrv' - run: cp .github/workflows/msrv-rust-toolchain.toml rust-toolchain.toml - - name: Install stable toolchain uses: helix-editor/rust-toolchain@v1 with: @@ -44,7 +36,7 @@ jobs: uses: actions/checkout@v3 - name: Install stable toolchain - uses: dtolnay/rust-toolchain@1.61 + uses: dtolnay/rust-toolchain@1.63 - uses: Swatinem/rust-cache@v2 @@ -73,7 +65,7 @@ jobs: uses: actions/checkout@v3 - name: Install stable toolchain - uses: dtolnay/rust-toolchain@1.61 + uses: dtolnay/rust-toolchain@1.63 with: components: rustfmt, clippy @@ -98,7 +90,7 @@ jobs: uses: actions/checkout@v3 - name: Install stable toolchain - uses: dtolnay/rust-toolchain@1.61 + uses: dtolnay/rust-toolchain@1.63 - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/msrv-rust-toolchain.toml b/.github/workflows/msrv-rust-toolchain.toml deleted file mode 100644 index b169d31e6f55..000000000000 --- a/.github/workflows/msrv-rust-toolchain.toml +++ /dev/null @@ -1,3 +0,0 @@ -[toolchain] -channel = "1.61.0" -components = ["rustfmt", "rust-src"] diff --git a/helix-term/src/lib.rs b/helix-term/src/lib.rs index a945b20dedaf..412cbd1d9a99 100644 --- a/helix-term/src/lib.rs +++ b/helix-term/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::type_complexity)] + #[macro_use] extern crate helix_view; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b169d31e6f55..ace4f5f96e55 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.61.0" +channel = "1.63.0" components = ["rustfmt", "rust-src"] From 97f0cc03905cedfc58318de2c1a1f83297464971 Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Sat, 21 Jan 2023 18:18:31 +0100 Subject: [PATCH 2/2] resolve new complex type clippy lints --- helix-term/src/commands.rs | 4 +++- helix-term/src/compositor.rs | 1 + helix-term/src/job.rs | 7 +++++-- helix-term/src/lib.rs | 2 -- helix-term/src/ui/editor.rs | 4 ++-- helix-term/src/ui/menu.rs | 4 +++- helix-term/src/ui/picker.rs | 8 ++++++-- helix-term/src/ui/prompt.rs | 11 +++++++---- 8 files changed, 27 insertions(+), 14 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 8b742d00aeb3..cccf574b3f74 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -69,13 +69,15 @@ use grep_searcher::{sinks, BinaryDetection, SearcherBuilder}; use ignore::{DirEntry, WalkBuilder, WalkState}; use tokio_stream::wrappers::UnboundedReceiverStream; +pub type OnKeyCallback = Box; + pub struct Context<'a> { pub register: Option, pub count: Option, pub editor: &'a mut Editor, pub callback: Option, - pub on_next_key_callback: Option>, + pub on_next_key_callback: Option, pub jobs: &'a mut Jobs, } diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs index 2e4a2e20e9f4..bcb3e44904e4 100644 --- a/helix-term/src/compositor.rs +++ b/helix-term/src/compositor.rs @@ -7,6 +7,7 @@ use helix_view::graphics::{CursorKind, Rect}; use tui::buffer::Buffer as Surface; pub type Callback = Box; +pub type SyncCallback = Box; // Cursive-inspired pub enum EventResult { diff --git a/helix-term/src/job.rs b/helix-term/src/job.rs index 2888b6eb1565..19f2521a5231 100644 --- a/helix-term/src/job.rs +++ b/helix-term/src/job.rs @@ -5,9 +5,12 @@ use crate::compositor::Compositor; use futures_util::future::{BoxFuture, Future, FutureExt}; use futures_util::stream::{FuturesUnordered, StreamExt}; +pub type EditorCompositorCallback = Box; +pub type EditorCallback = Box; + pub enum Callback { - EditorCompositor(Box), - Editor(Box), + EditorCompositor(EditorCompositorCallback), + Editor(EditorCallback), } pub type JobFuture = BoxFuture<'static, anyhow::Result>>; diff --git a/helix-term/src/lib.rs b/helix-term/src/lib.rs index 412cbd1d9a99..a945b20dedaf 100644 --- a/helix-term/src/lib.rs +++ b/helix-term/src/lib.rs @@ -1,5 +1,3 @@ -#![allow(clippy::type_complexity)] - #[macro_use] extern crate helix_view; diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index f8244600c9d4..e4f86facf6d9 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -1,5 +1,5 @@ use crate::{ - commands, + commands::{self, OnKeyCallback}, compositor::{Component, Context, Event, EventResult}, job::{self, Callback}, key, @@ -34,7 +34,7 @@ use super::statusline; pub struct EditorView { pub keymaps: Keymaps, - on_next_key: Option>, + on_next_key: Option, pseudo_pending: Vec, last_insert: (commands::MappableCommand, Vec), pub(crate) completion: Option, diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index e92578c5a136..98cf877bddc2 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -43,6 +43,8 @@ impl Item for PathBuf { } } +pub type MenuCallback = Box, MenuEvent)>; + pub struct Menu { options: Vec, editor_data: T::Data, @@ -55,7 +57,7 @@ pub struct Menu { widths: Vec, - callback_fn: Box, MenuEvent)>, + callback_fn: MenuCallback, scroll: usize, size: (u16, u16), diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index ccf37eb2bac5..0d6413a4d3ef 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -61,6 +61,8 @@ impl From for PathOrId { } } +type FileCallback = Box Option>; + /// File path and range of lines (used to align and highlight lines) pub type FileLocation = (PathOrId, Option<(usize, usize)>); @@ -71,7 +73,7 @@ pub struct FilePicker { preview_cache: HashMap, read_buffer: Vec, /// Given an item in the picker, return the file path and line number to display. - file_fn: Box Option>, + file_fn: FileCallback, } pub enum CachedPreview { @@ -371,6 +373,8 @@ impl Ord for PickerMatch { } } +type PickerCallback = Box; + pub struct Picker { options: Vec, editor_data: T::Data, @@ -392,7 +396,7 @@ pub struct Picker { /// Constraints for tabular formatting widths: Vec, - callback_fn: Box, + callback_fn: PickerCallback, } impl Picker { diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 5fb6745a90e5..f438231fa9c0 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -14,8 +14,11 @@ use helix_view::{ Editor, }; -pub type Completion = (RangeFrom, Cow<'static, str>); type PromptCharHandler = Box; +pub type Completion = (RangeFrom, Cow<'static, str>); +type CompletionFn = Box Vec>; +type CallbackFn = Box; +pub type DocFn = Box Option>>; pub struct Prompt { prompt: Cow<'static, str>, @@ -25,9 +28,9 @@ pub struct Prompt { selection: Option, history_register: Option, history_pos: Option, - completion_fn: Box Vec>, - callback_fn: Box, - pub doc_fn: Box Option>>, + completion_fn: CompletionFn, + callback_fn: CallbackFn, + pub doc_fn: DocFn, next_char_handler: Option, }