on master help sign in
Bump rust to 1.57, fix new lint failures
commit34f46e7502a562ffb1a3f681046c6cb7e86f7286 authorBlaž Hrastnik <blaz@mxxn.io> dateFri 3 Dec 2021, 12:48 (5 years ago) parentd31bef7
8 files changed+55−95
flake.lock+19−18 helix-term/src/commands.rs+25−25 helix-term/src/ui/editor.rs+1−1 helix-term/src/ui/picker.rs+5−5 helix-tui/src/buffer.rs+1−10 helix-tui/src/text.rs+2−14 helix-tui/src/widgets/table.rs+1−10 helix-view/src/graphics.rs+1−12
flake.lock+19−18
@@ -2,11 +2,11 @@
22 "nodes": {
33 "devshell": {
44 "locked": {
5− "lastModified": 1632436039,
6− "narHash": "sha256-OtITeVWcKXn1SpVEnImpTGH91FycCskGBPqmlxiykv4=",
5+ "lastModified": 1637575296,
6+ "narHash": "sha256-ZY8YR5u8aglZPe27+AJMnPTG6645WuavB+w0xmhTarw=",
77 "owner": "numtide",
88 "repo": "devshell",
9− "rev": "7a7a7aa0adebe5488e5abaec688fd9ae0f8ea9c6",
9+ "rev": "0e56ef21ba1a717169953122c7415fa6a8cd2618",
1010 "type": "github"
1111 },
1212 "original": {
@@ -17,11 +17,11 @@
1717 },
1818 "flake-utils": {
1919 "locked": {
20− "lastModified": 1623875721,
21− "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
20+ "lastModified": 1637014545,
21+ "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
2222 "owner": "numtide",
2323 "repo": "flake-utils",
24− "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
24+ "rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
2525 "type": "github"
2626 },
2727 "original": {
@@ -41,11 +41,11 @@
4141 ]
4242 },
4343 "locked": {
44− "lastModified": 1634796585,
45− "narHash": "sha256-CW4yx6omk5qCXUIwXHp/sztA7u0SpyLq9NEACPnkiz8=",
44+ "lastModified": 1638425401,
45+ "narHash": "sha256-xc8ayvR3u90hSCMEy0zHHKav7lEgljAFXL4oIkWRp3M=",
4646 "owner": "yusdacra",
4747 "repo": "nix-cargo-integration",
48− "rev": "a84a2137a396f303978f1d48341e0390b0e16a8b",
48+ "rev": "1f8b511bb30f7d7b9051dfbb4784390bc0d48d37",
4949 "type": "github"
5050 },
5151 "original": {
@@ -56,11 +56,11 @@
5656 },
5757 "nixpkgs": {
5858 "locked": {
59− "lastModified": 1634782485,
60− "narHash": "sha256-psfh4OQSokGXG0lpq3zKFbhOo3QfoeudRcaUnwMRkQo=",
59+ "lastModified": 1638376152,
60+ "narHash": "sha256-ucgLpVqhFnClH7YRUHBHnmiOd82RZdFR3XJt36ks5fE=",
6161 "owner": "nixos",
6262 "repo": "nixpkgs",
63− "rev": "34ad3ffe08adfca17fcb4e4a47bb5f3b113687be",
63+ "rev": "6daa4a5c045d40e6eae60a3b6e427e8700f1c07f",
6464 "type": "github"
6565 },
6666 "original": {
@@ -72,15 +72,16 @@
7272 },
7373 "nixpkgs_2": {
7474 "locked": {
75− "lastModified": 1628186154,
76− "narHash": "sha256-r2d0wvywFnL9z4iptztdFMhaUIAaGzrSs7kSok0PgmE=",
75+ "lastModified": 1637453606,
76+ "narHash": "sha256-Gy6cwUswft9xqsjWxFYEnx/63/qzaFUwatcbV5GF/GQ=",
7777 "owner": "NixOS",
7878 "repo": "nixpkgs",
79− "rev": "06552b72346632b6943c8032e57e702ea12413bf",
79+ "rev": "8afc4e543663ca0a6a4f496262cd05233737e732",
8080 "type": "github"
8181 },
8282 "original": {
8383 "owner": "NixOS",
84+ "ref": "nixpkgs-unstable",
8485 "repo": "nixpkgs",
8586 "type": "github"
8687 }
@@ -98,11 +99,11 @@
9899 "nixpkgs": "nixpkgs_2"
99100 },
100101 "locked": {
101− "lastModified": 1634869268,
102− "narHash": "sha256-RVAcEFlFU3877Mm4q/nbXGEYTDg/wQNhzmXGMTV6wBs=",
102+ "lastModified": 1638497756,
103+ "narHash": "sha256-zKOvMKqGp71ZBnR+hBlPcv4TwNN82COW9EF+6ygrFs8=",
103104 "owner": "oxalica",
104105 "repo": "rust-overlay",
105− "rev": "c02c2d86354327317546501af001886fbb53d374",
106+ "rev": "783722a22ee5d762ac5c1c7b418b57b3010c827a",
106107 "type": "github"
107108 },
108109 "original": {
helix-term/src/commands.rs+25−25
@@ -2256,7 +2256,7 @@ mod cmd {
22562256 args: &[&str],
22572257 event: PromptEvent,
22582258 ) -> anyhow::Result<()> {
2259− quit_all_impl(&mut cx.editor, args, event, false)
2259+ quit_all_impl(cx.editor, args, event, false)
22602260 }
22612261
22622262 fn force_quit_all(
@@ -2264,7 +2264,7 @@ mod cmd {
22642264 args: &[&str],
22652265 event: PromptEvent,
22662266 ) -> anyhow::Result<()> {
2267− quit_all_impl(&mut cx.editor, args, event, true)
2267+ quit_all_impl(cx.editor, args, event, true)
22682268 }
22692269
22702270 fn cquit(
@@ -2300,7 +2300,7 @@ mod cmd {
23002300 _args: &[&str],
23012301 _event: PromptEvent,
23022302 ) -> anyhow::Result<()> {
2303− yank_main_selection_to_clipboard_impl(&mut cx.editor, ClipboardType::Clipboard)
2303+ yank_main_selection_to_clipboard_impl(cx.editor, ClipboardType::Clipboard)
23042304 }
23052305
23062306 fn yank_joined_to_clipboard(
@@ -2313,7 +2313,7 @@ mod cmd {
23132313 .first()
23142314 .copied()
23152315 .unwrap_or_else(|| doc.line_ending.as_str());
2316− yank_joined_to_clipboard_impl(&mut cx.editor, separator, ClipboardType::Clipboard)
2316+ yank_joined_to_clipboard_impl(cx.editor, separator, ClipboardType::Clipboard)
23172317 }
23182318
23192319 fn yank_main_selection_to_primary_clipboard(
@@ -2321,7 +2321,7 @@ mod cmd {
23212321 _args: &[&str],
23222322 _event: PromptEvent,
23232323 ) -> anyhow::Result<()> {
2324− yank_main_selection_to_clipboard_impl(&mut cx.editor, ClipboardType::Selection)
2324+ yank_main_selection_to_clipboard_impl(cx.editor, ClipboardType::Selection)
23252325 }
23262326
23272327 fn yank_joined_to_primary_clipboard(
@@ -2334,7 +2334,7 @@ mod cmd {
23342334 .first()
23352335 .copied()
23362336 .unwrap_or_else(|| doc.line_ending.as_str());
2337− yank_joined_to_clipboard_impl(&mut cx.editor, separator, ClipboardType::Selection)
2337+ yank_joined_to_clipboard_impl(cx.editor, separator, ClipboardType::Selection)
23382338 }
23392339
23402340 fn paste_clipboard_after(
@@ -2342,7 +2342,7 @@ mod cmd {
23422342 _args: &[&str],
23432343 _event: PromptEvent,
23442344 ) -> anyhow::Result<()> {
2345− paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Clipboard)
2345+ paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Clipboard)
23462346 }
23472347
23482348 fn paste_clipboard_before(
@@ -2350,7 +2350,7 @@ mod cmd {
23502350 _args: &[&str],
23512351 _event: PromptEvent,
23522352 ) -> anyhow::Result<()> {
2353− paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Clipboard)
2353+ paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Clipboard)
23542354 }
23552355
23562356 fn paste_primary_clipboard_after(
@@ -2358,7 +2358,7 @@ mod cmd {
23582358 _args: &[&str],
23592359 _event: PromptEvent,
23602360 ) -> anyhow::Result<()> {
2361− paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Selection)
2361+ paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Selection)
23622362 }
23632363
23642364 fn paste_primary_clipboard_before(
@@ -2366,7 +2366,7 @@ mod cmd {
23662366 _args: &[&str],
23672367 _event: PromptEvent,
23682368 ) -> anyhow::Result<()> {
2369− paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Selection)
2369+ paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Selection)
23702370 }
23712371
23722372 fn replace_selections_with_clipboard_impl(
@@ -2544,7 +2544,7 @@ mod cmd {
25442544
25452545 let line = args[0].parse::<usize>()?;
25462546
2547− goto_line_impl(&mut cx.editor, NonZeroUsize::new(line));
2547+ goto_line_impl(cx.editor, NonZeroUsize::new(line));
25482548
25492549 let (view, doc) = current!(cx.editor);
25502550
@@ -3545,7 +3545,7 @@ fn push_jump(editor: &mut Editor) {
35453545}
35463546
35473547fn goto_line(cx: &mut Context) {
3548− goto_line_impl(&mut cx.editor, cx.count)
3548+ goto_line_impl(cx.editor, cx.count)
35493549}
35503550
35513551fn goto_line_impl(editor: &mut Editor, count: Option<NonZeroUsize>) {
@@ -4445,7 +4445,7 @@ fn yank_joined_to_clipboard_impl(
44454445fn yank_joined_to_clipboard(cx: &mut Context) {
44464446 let line_ending = doc!(cx.editor).line_ending;
44474447 let _ = yank_joined_to_clipboard_impl(
4448− &mut cx.editor,
4448+ cx.editor,
44494449 line_ending.as_str(),
44504450 ClipboardType::Clipboard,
44514451 );
@@ -4473,20 +4473,20 @@ fn yank_main_selection_to_clipboard_impl(
44734473}
44744474
44754475fn yank_main_selection_to_clipboard(cx: &mut Context) {
4476− let _ = yank_main_selection_to_clipboard_impl(&mut cx.editor, ClipboardType::Clipboard);
4476+ let _ = yank_main_selection_to_clipboard_impl(cx.editor, ClipboardType::Clipboard);
44774477}
44784478
44794479fn yank_joined_to_primary_clipboard(cx: &mut Context) {
44804480 let line_ending = doc!(cx.editor).line_ending;
44814481 let _ = yank_joined_to_clipboard_impl(
4482− &mut cx.editor,
4482+ cx.editor,
44834483 line_ending.as_str(),
44844484 ClipboardType::Selection,
44854485 );
44864486}
44874487
44884488fn yank_main_selection_to_primary_clipboard(cx: &mut Context) {
4489− let _ = yank_main_selection_to_clipboard_impl(&mut cx.editor, ClipboardType::Selection);
4489+ let _ = yank_main_selection_to_clipboard_impl(cx.editor, ClipboardType::Selection);
44904490 exit_select_mode(cx);
44914491}
44924492
@@ -4569,19 +4569,19 @@ fn paste_clipboard_impl(
45694569}
45704570
45714571fn paste_clipboard_after(cx: &mut Context) {
4572− let _ = paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Clipboard);
4572+ let _ = paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Clipboard);
45734573}
45744574
45754575fn paste_clipboard_before(cx: &mut Context) {
4576− let _ = paste_clipboard_impl(&mut cx.editor, Paste::Before, ClipboardType::Clipboard);
4576+ let _ = paste_clipboard_impl(cx.editor, Paste::Before, ClipboardType::Clipboard);
45774577}
45784578
45794579fn paste_primary_clipboard_after(cx: &mut Context) {
4580− let _ = paste_clipboard_impl(&mut cx.editor, Paste::After, ClipboardType::Selection);
4580+ let _ = paste_clipboard_impl(cx.editor, Paste::After, ClipboardType::Selection);
45814581}
45824582
45834583fn paste_primary_clipboard_before(cx: &mut Context) {
4584− let _ = paste_clipboard_impl(&mut cx.editor, Paste::Before, ClipboardType::Selection);
4584+ let _ = paste_clipboard_impl(cx.editor, Paste::Before, ClipboardType::Selection);
45854585}
45864586
45874587fn replace_with_yanked(cx: &mut Context) {
@@ -4638,11 +4638,11 @@ fn replace_selections_with_clipboard_impl(
46384638}
46394639
46404640fn replace_selections_with_clipboard(cx: &mut Context) {
4641− let _ = replace_selections_with_clipboard_impl(&mut cx.editor, ClipboardType::Clipboard);
4641+ let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Clipboard);
46424642}
46434643
46444644fn replace_selections_with_primary_clipboard(cx: &mut Context) {
4645− let _ = replace_selections_with_clipboard_impl(&mut cx.editor, ClipboardType::Selection);
4645+ let _ = replace_selections_with_clipboard_impl(cx.editor, ClipboardType::Selection);
46464646}
46474647
46484648fn paste_after(cx: &mut Context) {
@@ -5157,7 +5157,7 @@ fn expand_selection(cx: &mut Context) {
51575157 doc.set_selection(view.id, selection);
51585158 }
51595159 };
5160− motion(&mut cx.editor);
5160+ motion(cx.editor);
51615161 cx.editor.last_motion = Some(Motion(Box::new(motion)));
51625162}
51635163
@@ -5389,7 +5389,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
53895389 });
53905390 doc.set_selection(view.id, selection);
53915391 };
5392− textobject(&mut cx.editor);
5392+ textobject(cx.editor);
53935393 cx.editor.last_motion = Some(Motion(Box::new(textobject)));
53945394 }
53955395 })
@@ -5719,7 +5719,7 @@ fn rename_symbol(cx: &mut Context) {
57195719 let task = language_server.rename_symbol(doc.identifier(), pos, input.to_string());
57205720 let edits = block_on(task).unwrap_or_default();
57215721 log::debug!("Edits from LSP: {:?}", edits);
5722− apply_workspace_edit(&mut cx.editor, offset_encoding, &edits);
5722+ apply_workspace_edit(cx.editor, offset_encoding, &edits);
57235723 },
57245724 );
57255725 cx.push_layer(Box::new(prompt));
helix-term/src/ui/editor.rs+1−1
@@ -922,7 +922,7 @@ impl EditorView {
922922impl Component for EditorView {
923923 fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
924924 let mut cxt = commands::Context {
925− editor: &mut cx.editor,
925+ editor: cx.editor,
926926 count: None,
927927 register: None,
928928 callback: None,
helix-term/src/ui/picker.rs+5−5
@@ -46,7 +46,7 @@ pub struct FilePicker<T> {
4646}
4747
4848pub enum CachedPreview {
49− Document(Document),
49+ Document(Box<Document>),
5050 Binary,
5151 LargeFile,
5252 NotFound,
@@ -140,7 +140,7 @@ impl<T> FilePicker<T> {
140140 _ => {
141141 // TODO: enable syntax highlighting; blocked by async rendering
142142 Document::open(path, None, Some(&editor.theme), None)
143− .map(CachedPreview::Document)
143+ .map(|doc| CachedPreview::Document(Box::new(doc)))
144144 .unwrap_or(CachedPreview::NotFound)
145145 }
146146 },
@@ -421,19 +421,19 @@ impl<T: 'static> Component for Picker<T> {
421421 }
422422 key!(Enter) => {
423423 if let Some(option) = self.selection() {
424− (self.callback_fn)(&mut cx.editor, option, Action::Replace);
424+ (self.callback_fn)(cx.editor, option, Action::Replace);
425425 }
426426 return close_fn;
427427 }
428428 ctrl!('s') => {
429429 if let Some(option) = self.selection() {
430− (self.callback_fn)(&mut cx.editor, option, Action::HorizontalSplit);
430+ (self.callback_fn)(cx.editor, option, Action::HorizontalSplit);
431431 }
432432 return close_fn;
433433 }
434434 ctrl!('v') => {
435435 if let Some(option) = self.selection() {
436− (self.callback_fn)(&mut cx.editor, option, Action::VerticalSplit);
436+ (self.callback_fn)(cx.editor, option, Action::VerticalSplit);
437437 }
438438 return close_fn;
439439 }
helix-tui/src/buffer.rs+1−10
@@ -102,7 +102,7 @@ impl Default for Cell {
102102/// buf.get_mut(5, 0).set_char('x');
103103/// assert_eq!(buf.get(5, 0).symbol, "x");
104104/// ```
105−#[derive(Debug, Clone, PartialEq)]
105+#[derive(Debug, Default, Clone, PartialEq)]
106106pub struct Buffer {
107107 /// The area represented by this buffer
108108 pub area: Rect,
@@ -111,15 +111,6 @@ pub struct Buffer {
111111 pub content: Vec<Cell>,
112112}
113113
114−impl Default for Buffer {
115− fn default() -> Buffer {
116− Buffer {
117− area: Default::default(),
118− content: Vec::new(),
119− }
120− }
121−}
122−
123114impl Buffer {
124115 /// Returns a Buffer with all cells set to the default one
125116 pub fn empty(area: Rect) -> Buffer {
helix-tui/src/text.rs+2−14
@@ -195,15 +195,9 @@ impl<'a> From<&'a str> for Span<'a> {
195195}
196196
197197/// A string composed of clusters of graphemes, each with their own style.
198−#[derive(Debug, Clone, PartialEq)]
198+#[derive(Debug, Default, Clone, PartialEq)]
199199pub struct Spans<'a>(pub Vec<Span<'a>>);
200200
201−impl<'a> Default for Spans<'a> {
202− fn default() -> Spans<'a> {
203− Spans(Vec::new())
204− }
205−}
206−
207201impl<'a> Spans<'a> {
208202 /// Returns the width of the underlying string.
209203 ///
@@ -280,17 +274,11 @@ impl<'a> From<Spans<'a>> for String {
280274/// text.extend(Text::styled("Some more lines\nnow with more style!", style));
281275/// assert_eq!(6, text.height());
282276/// ```
283−#[derive(Debug, Clone, PartialEq)]
277+#[derive(Debug, Default, Clone, PartialEq)]
284278pub struct Text<'a> {
285279 pub lines: Vec<Spans<'a>>,
286280}
287281
288−impl<'a> Default for Text<'a> {
289− fn default() -> Text<'a> {
290− Text { lines: Vec::new() }
291− }
292−}
293−
294282impl<'a> Text<'a> {
295283 /// Create some text (potentially multiple lines) with no style.
296284 ///
helix-tui/src/widgets/table.rs+1−10
@@ -363,21 +363,12 @@ impl<'a> Table<'a> {
363363 }
364364}
365365
366−#[derive(Debug, Clone)]
366+#[derive(Debug, Default, Clone)]
367367pub struct TableState {
368368 pub offset: usize,
369369 pub selected: Option<usize>,
370370}
371371
372−impl Default for TableState {
373− fn default() -> TableState {
374− TableState {
375− offset: 0,
376− selected: None,
377− }
378− }
379−}
380−
381372impl TableState {
382373 pub fn selected(&self) -> Option<usize> {
383374 self.selected
helix-view/src/graphics.rs+1−12
@@ -25,7 +25,7 @@ pub struct Margin {
2525
2626/// A simple rectangle used in the computation of the layout and to give widgets an hint about the
2727/// area they are supposed to render to. (x, y) = (0, 0) is at the top left corner of the screen.
28−#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
28+#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq)]
2929pub struct Rect {
3030 pub x: u16,
3131 pub y: u16,
@@ -33,17 +33,6 @@ pub struct Rect {
3333 pub height: u16,
3434}
3535
36−impl Default for Rect {
37− fn default() -> Rect {
38− Rect {
39− x: 0,
40− y: 0,
41− width: 0,
42− height: 0,
43− }
44− }
45−}
46−
4736impl Rect {
4837 /// Creates a new rect, with width and height limited to keep the area under max u16.
4938 /// If clipped, aspect ratio will be preserved.