on master help sign in
bump msrv to 1.63 (#5570)

* bump msrv to 1.63 * resolve new complex type clippy lints

commite474779c8729c36335b76badc98d8211829122d2 authorPascal Kuthe <pascal.kuthe@semimod.de> dateThu 9 Feb 2023, 03:24 (4 years ago) parentbd14f5a
10 files changed+32−28
.github/workflows/build.yml+4−12 .github/workflows/msrv-rust-toolchain.toml−3 helix-term/src/commands.rs+3−1 helix-term/src/compositor.rs+1 helix-term/src/job.rs+5−2 helix-term/src/ui/editor.rs+2−2 helix-term/src/ui/menu.rs+3−1 helix-term/src/ui/picker.rs+6−2 helix-term/src/ui/prompt.rs+7−4 rust-toolchain.toml+1−1
.github/workflows/build.yml+4−12
@@ -10,19 +10,11 @@ on:
1010
1111jobs:
1212 check:
13− name: Check
13+ name: Check (msrv)
1414 runs-on: ubuntu-latest
15− strategy:
16− matrix:
17− rust: [stable, msrv]
1815 steps:
1916 - name: Checkout sources
2017 uses: actions/checkout@v3
21−
22− - name: Use MSRV rust toolchain
23− if: matrix.rust == 'msrv'
24− run: cp .github/workflows/msrv-rust-toolchain.toml rust-toolchain.toml
25−
2618 - name: Install stable toolchain
2719 uses: helix-editor/rust-toolchain@v1
2820 with:
@@ -45,7 +37,7 @@ jobs:
4537 uses: actions/checkout@v3
4638
4739 - name: Install stable toolchain
48− uses: dtolnay/rust-toolchain@1.61
40+ uses: dtolnay/rust-toolchain@1.63
4941
5042 - uses: Swatinem/rust-cache@v2
5143
@@ -74,7 +66,7 @@ jobs:
7466 uses: actions/checkout@v3
7567
7668 - name: Install stable toolchain
77− uses: dtolnay/rust-toolchain@1.61
69+ uses: dtolnay/rust-toolchain@1.63
7870 with:
7971 components: rustfmt, clippy
8072
@@ -99,7 +91,7 @@ jobs:
9991 uses: actions/checkout@v3
10092
10193 - name: Install stable toolchain
102− uses: dtolnay/rust-toolchain@1.61
94+ uses: dtolnay/rust-toolchain@1.63
10395
10496 - uses: Swatinem/rust-cache@v2
10597
.github/workflows/msrv-rust-toolchain.tomldeleted−3
@@ -1,3 +0,0 @@
1−[toolchain]
2−channel = "1.61.0"
3−components = ["rustfmt", "rust-src"]
helix-term/src/commands.rs+3−1
@@ -73,13 +73,15 @@ use grep_searcher::{sinks, BinaryDetection, SearcherBuilder};
7373use ignore::{DirEntry, WalkBuilder, WalkState};
7474use tokio_stream::wrappers::UnboundedReceiverStream;
7575
76+pub type OnKeyCallback = Box<dyn FnOnce(&mut Context, KeyEvent)>;
77+
7678pub struct Context<'a> {
7779 pub register: Option<char>,
7880 pub count: Option<NonZeroUsize>,
7981 pub editor: &'a mut Editor,
8082
8183 pub callback: Option<crate::compositor::Callback>,
82− pub on_next_key_callback: Option<Box<dyn FnOnce(&mut Context, KeyEvent)>>,
84+ pub on_next_key_callback: Option<OnKeyCallback>,
8385 pub jobs: &'a mut Jobs,
8486}
8587
helix-term/src/compositor.rs+1
@@ -7,6 +7,7 @@ use helix_view::graphics::{CursorKind, Rect};
77use tui::buffer::Buffer as Surface;
88
99pub type Callback = Box<dyn FnOnce(&mut Compositor, &mut Context)>;
10+pub type SyncCallback = Box<dyn FnOnce(&mut Compositor, &mut Context) + Sync>;
1011
1112// Cursive-inspired
1213pub enum EventResult {
helix-term/src/job.rs+5−2
@@ -5,9 +5,12 @@ use crate::compositor::Compositor;
55use futures_util::future::{BoxFuture, Future, FutureExt};
66use futures_util::stream::{FuturesUnordered, StreamExt};
77
8+pub type EditorCompositorCallback = Box<dyn FnOnce(&mut Editor, &mut Compositor) + Send>;
9+pub type EditorCallback = Box<dyn FnOnce(&mut Editor) + Send>;
10+
811pub enum Callback {
9− EditorCompositor(Box<dyn FnOnce(&mut Editor, &mut Compositor) + Send>),
10− Editor(Box<dyn FnOnce(&mut Editor) + Send>),
12+ EditorCompositor(EditorCompositorCallback),
13+ Editor(EditorCallback),
1114}
1215
1316pub type JobFuture = BoxFuture<'static, anyhow::Result<Option<Callback>>>;
helix-term/src/ui/editor.rs+2−2
@@ -1,5 +1,5 @@
11use crate::{
2− commands,
2+ commands::{self, OnKeyCallback},
33 compositor::{Component, Context, Event, EventResult},
44 job::{self, Callback},
55 key,
@@ -37,7 +37,7 @@ use super::{document::LineDecoration, lsp::SignatureHelp};
3737
3838pub struct EditorView {
3939 pub keymaps: Keymaps,
40− on_next_key: Option<Box<dyn FnOnce(&mut commands::Context, KeyEvent)>>,
40+ on_next_key: Option<OnKeyCallback>,
4141 pseudo_pending: Vec<KeyEvent>,
4242 last_insert: (commands::MappableCommand, Vec<InsertEvent>),
4343 pub(crate) completion: Option<Completion>,
helix-term/src/ui/menu.rs+3−1
@@ -43,6 +43,8 @@ impl Item for PathBuf {
4343 }
4444}
4545
46+pub type MenuCallback<T> = Box<dyn Fn(&mut Editor, Option<&T>, MenuEvent)>;
47+
4648pub struct Menu<T: Item> {
4749 options: Vec<T>,
4850 editor_data: T::Data,
@@ -55,7 +57,7 @@ pub struct Menu<T: Item> {
5557
5658 widths: Vec<Constraint>,
5759
58− callback_fn: Box<dyn Fn(&mut Editor, Option<&T>, MenuEvent)>,
60+ callback_fn: MenuCallback<T>,
5961
6062 scroll: usize,
6163 size: (u16, u16),
helix-term/src/ui/picker.rs+6−2
@@ -70,6 +70,8 @@ impl From<DocumentId> for PathOrId {
7070 }
7171}
7272
73+type FileCallback<T> = Box<dyn Fn(&Editor, &T) -> Option<FileLocation>>;
74+
7375/// File path and range of lines (used to align and highlight lines)
7476pub type FileLocation = (PathOrId, Option<(usize, usize)>);
7577
@@ -80,7 +82,7 @@ pub struct FilePicker<T: Item> {
8082 preview_cache: HashMap<PathBuf, CachedPreview>,
8183 read_buffer: Vec<u8>,
8284 /// Given an item in the picker, return the file path and line number to display.
83− file_fn: Box<dyn Fn(&Editor, &T) -> Option<FileLocation>>,
85+ file_fn: FileCallback<T>,
8486}
8587
8688pub enum CachedPreview {
@@ -394,6 +396,8 @@ impl Ord for PickerMatch {
394396 }
395397}
396398
399+type PickerCallback<T> = Box<dyn Fn(&mut Context, &T, Action)>;
400+
397401pub struct Picker<T: Item> {
398402 options: Vec<T>,
399403 editor_data: T::Data,
@@ -415,7 +419,7 @@ pub struct Picker<T: Item> {
415419 /// Constraints for tabular formatting
416420 widths: Vec<Constraint>,
417421
418− callback_fn: Box<dyn Fn(&mut Context, &T, Action)>,
422+ callback_fn: PickerCallback<T>,
419423}
420424
421425impl<T: Item> Picker<T> {
helix-term/src/ui/prompt.rs+7−4
@@ -14,8 +14,11 @@ use helix_view::{
1414 Editor,
1515};
1616
17−pub type Completion = (RangeFrom<usize>, Cow<'static, str>);
1817type PromptCharHandler = Box<dyn Fn(&mut Prompt, char, &Context)>;
18+pub type Completion = (RangeFrom<usize>, Cow<'static, str>);
19+type CompletionFn = Box<dyn FnMut(&Editor, &str) -> Vec<Completion>>;
20+type CallbackFn = Box<dyn FnMut(&mut Context, &str, PromptEvent)>;
21+pub type DocFn = Box<dyn Fn(&str) -> Option<Cow<str>>>;
1922
2023pub struct Prompt {
2124 prompt: Cow<'static, str>,
@@ -25,9 +28,9 @@ pub struct Prompt {
2528 selection: Option<usize>,
2629 history_register: Option<char>,
2730 history_pos: Option<usize>,
28− completion_fn: Box<dyn FnMut(&Editor, &str) -> Vec<Completion>>,
29− callback_fn: Box<dyn FnMut(&mut Context, &str, PromptEvent)>,
30− pub doc_fn: Box<dyn Fn(&str) -> Option<Cow<str>>>,
31+ completion_fn: CompletionFn,
32+ callback_fn: CallbackFn,
33+ pub doc_fn: DocFn,
3134 next_char_handler: Option<PromptCharHandler>,
3235}
3336
rust-toolchain.toml+1−1
@@ -1,3 +1,3 @@
11[toolchain]
2−channel = "1.61.0"
2+channel = "1.63.0"
33components = ["rustfmt", "rust-src"]