on master help sign in
Update to rust 1.58, fix a bunch of optional lints
e7eab95Blaž Hrastnik
flake.lock+12−12
@@ -2,11 +2,11 @@
2 "nodes": {
2 "nodes": {
3 "devshell": {
3 "devshell": {
4 "locked": {
4 "locked": {
5− "lastModified": 1640301433,
5+ "lastModified": 1641980203,
6− "narHash": "sha256-eplae8ZNiEmxbOgwUn9IihaJfEUxoUilkwciRPGskYE=",
6+ "narHash": "sha256-RiWJ3+6V267Ji+P54K1Xrj1Nsah9BfG/aLfIhqgVyBY=",
7 "owner": "numtide",
7 "owner": "numtide",
8 "repo": "devshell",
8 "repo": "devshell",
9− "rev": "f87fb932740abe1c1b46f6edd8a36ade17881666",
9+ "rev": "d897c1ddb4eab66cc2b783c7868d78555b9880ad",
10 "type": "github"
10 "type": "github"
11 },
11 },
12 "original": {
12 "original": {
@@ -41,11 +41,11 @@
41 ]
41 ]
42 },
42 },
43 "locked": {
43 "locked": {
44− "lastModified": 1641449444,
44+ "lastModified": 1642054253,
45− "narHash": "sha256-InqsyCVafPqXmK7YqUfFVpb6eVYJWUWbYXEvey0J+3c=",
45+ "narHash": "sha256-kHh9VmaB7gbS6pheheC4x0uT84LEmhfbsbWEQJgU2E4=",
46 "owner": "yusdacra",
46 "owner": "yusdacra",
47 "repo": "nix-cargo-integration",
47 "repo": "nix-cargo-integration",
48− "rev": "d1aa15a832db331a97082b7f8c7da737a6789c77",
48+ "rev": "f8fa9af990195a3f63fe2dde84aa187e193da793",
49 "type": "github"
49 "type": "github"
50 },
50 },
51 "original": {
51 "original": {
@@ -56,11 +56,11 @@
56 },
56 },
57 "nixpkgs": {
57 "nixpkgs": {
58 "locked": {
58 "locked": {
59− "lastModified": 1639699734,
59+ "lastModified": 1641887635,
60− "narHash": "sha256-tlX6WebGmiHb2Hmniff+ltYp+7dRfdsBxw9YczLsP60=",
60+ "narHash": "sha256-kDGpufwzVaiGe5e1sBUBPo9f1YN+nYHJlYqCaVpZTQQ=",
61 "owner": "nixos",
61 "owner": "nixos",
62 "repo": "nixpkgs",
62 "repo": "nixpkgs",
63− "rev": "03ec468b14067729a285c2c7cfa7b9434a04816c",
63+ "rev": "b2737d4980a17cc2b7d600d7d0b32fd7333aca88",
64 "type": "github"
64 "type": "github"
65 },
65 },
66 "original": {
66 "original": {
@@ -99,11 +99,11 @@
99 "nixpkgs": "nixpkgs_2"
99 "nixpkgs": "nixpkgs_2"
100 },
100 },
101 "locked": {
101 "locked": {
102− "lastModified": 1639880499,
102+ "lastModified": 1642128126,
103− "narHash": "sha256-/BibDmFwgWuuTUkNVO6YlvuTSWM9dpBvlZoTAPs7ORI=",
103+ "narHash": "sha256-av8JUACdrTfQYl/ftZJvKpZEmZfa0avCq7tt5Usdoq0=",
104 "owner": "oxalica",
104 "owner": "oxalica",
105 "repo": "rust-overlay",
105 "repo": "rust-overlay",
106− "rev": "c6c83589ae048af20d93d01eb07a4176012093d0",
106+ "rev": "ce4ef6f2d74f2b68f7547df1de22d1b0037ce4ad",
107 "type": "github"
107 "type": "github"
108 },
108 },
109 "original": {
109 "original": {
helix-core/src/increment/date_time.rs+16−16
@@ -195,82 +195,82 @@ struct DateField {
195impl DateField {
195impl DateField {
196 fn from_specifier(specifier: &str) -> Option<Self> {
196 fn from_specifier(specifier: &str) -> Option<Self> {
197 match specifier {
197 match specifier {
198− "Y" => Some(DateField {
198+ "Y" => Some(Self {
199 regex: r"\d{4}",
199 regex: r"\d{4}",
200 unit: DateUnit::Years,
200 unit: DateUnit::Years,
201 max_len: 5,
201 max_len: 5,
202 }),
202 }),
203− "y" => Some(DateField {
203+ "y" => Some(Self {
204 regex: r"\d\d",
204 regex: r"\d\d",
205 unit: DateUnit::Years,
205 unit: DateUnit::Years,
206 max_len: 2,
206 max_len: 2,
207 }),
207 }),
208− "m" => Some(DateField {
208+ "m" => Some(Self {
209 regex: r"[0-1]\d",
209 regex: r"[0-1]\d",
210 unit: DateUnit::Months,
210 unit: DateUnit::Months,
211 max_len: 2,
211 max_len: 2,
212 }),
212 }),
213− "d" => Some(DateField {
213+ "d" => Some(Self {
214 regex: r"[0-3]\d",
214 regex: r"[0-3]\d",
215 unit: DateUnit::Days,
215 unit: DateUnit::Days,
216 max_len: 2,
216 max_len: 2,
217 }),
217 }),
218− "-d" => Some(DateField {
218+ "-d" => Some(Self {
219 regex: r"[1-3]?\d",
219 regex: r"[1-3]?\d",
220 unit: DateUnit::Days,
220 unit: DateUnit::Days,
221 max_len: 2,
221 max_len: 2,
222 }),
222 }),
223− "a" => Some(DateField {
223+ "a" => Some(Self {
224 regex: r"Sun|Mon|Tue|Wed|Thu|Fri|Sat",
224 regex: r"Sun|Mon|Tue|Wed|Thu|Fri|Sat",
225 unit: DateUnit::Days,
225 unit: DateUnit::Days,
226 max_len: 3,
226 max_len: 3,
227 }),
227 }),
228− "A" => Some(DateField {
228+ "A" => Some(Self {
229 regex: r"Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday",
229 regex: r"Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday",
230 unit: DateUnit::Days,
230 unit: DateUnit::Days,
231 max_len: 9,
231 max_len: 9,
232 }),
232 }),
233− "b" | "h" => Some(DateField {
233+ "b" | "h" => Some(Self {
234 regex: r"Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec",
234 regex: r"Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec",
235 unit: DateUnit::Months,
235 unit: DateUnit::Months,
236 max_len: 3,
236 max_len: 3,
237 }),
237 }),
238− "B" => Some(DateField {
238+ "B" => Some(Self {
239 regex: r"January|February|March|April|May|June|July|August|September|October|November|December",
239 regex: r"January|February|March|April|May|June|July|August|September|October|November|December",
240 unit: DateUnit::Months,
240 unit: DateUnit::Months,
241 max_len: 9,
241 max_len: 9,
242 }),
242 }),
243− "H" => Some(DateField {
243+ "H" => Some(Self {
244 regex: r"[0-2]\d",
244 regex: r"[0-2]\d",
245 unit: DateUnit::Hours,
245 unit: DateUnit::Hours,
246 max_len: 2,
246 max_len: 2,
247 }),
247 }),
248− "M" => Some(DateField {
248+ "M" => Some(Self {
249 regex: r"[0-5]\d",
249 regex: r"[0-5]\d",
250 unit: DateUnit::Minutes,
250 unit: DateUnit::Minutes,
251 max_len: 2,
251 max_len: 2,
252 }),
252 }),
253− "S" => Some(DateField {
253+ "S" => Some(Self {
254 regex: r"[0-5]\d",
254 regex: r"[0-5]\d",
255 unit: DateUnit::Seconds,
255 unit: DateUnit::Seconds,
256 max_len: 2,
256 max_len: 2,
257 }),
257 }),
258− "I" => Some(DateField {
258+ "I" => Some(Self {
259 regex: r"[0-1]\d",
259 regex: r"[0-1]\d",
260 unit: DateUnit::Hours,
260 unit: DateUnit::Hours,
261 max_len: 2,
261 max_len: 2,
262 }),
262 }),
263− "-I" => Some(DateField {
263+ "-I" => Some(Self {
264 regex: r"1?\d",
264 regex: r"1?\d",
265 unit: DateUnit::Hours,
265 unit: DateUnit::Hours,
266 max_len: 2,
266 max_len: 2,
267 }),
267 }),
268− "P" => Some(DateField {
268+ "P" => Some(Self {
269 regex: r"am|pm",
269 regex: r"am|pm",
270 unit: DateUnit::AmPm,
270 unit: DateUnit::AmPm,
271 max_len: 2,
271 max_len: 2,
272 }),
272 }),
273− "p" => Some(DateField {
273+ "p" => Some(Self {
274 regex: r"AM|PM",
274 regex: r"AM|PM",
275 unit: DateUnit::AmPm,
275 unit: DateUnit::AmPm,
276 max_len: 2,
276 max_len: 2,
helix-term/src/commands.rs+16−19
@@ -173,7 +173,7 @@ macro_rules! static_commands {
173impl MappableCommand {
173impl MappableCommand {
174 pub fn execute(&self, cx: &mut Context) {
174 pub fn execute(&self, cx: &mut Context) {
175 match &self {
175 match &self {
176− MappableCommand::Typable { name, args, doc: _ } => {
176+ Self::Typable { name, args, doc: _ } => {
177 let args: Vec<Cow<str>> = args.iter().map(Cow::from).collect();
177 let args: Vec<Cow<str>> = args.iter().map(Cow::from).collect();
178 if let Some(command) = cmd::TYPABLE_COMMAND_MAP.get(name.as_str()) {
178 if let Some(command) = cmd::TYPABLE_COMMAND_MAP.get(name.as_str()) {
179 let mut cx = compositor::Context {
179 let mut cx = compositor::Context {
@@ -186,21 +186,21 @@ impl MappableCommand {
186 }
186 }
187 }
187 }
188 }
188 }
189− MappableCommand::Static { fun, .. } => (fun)(cx),
189+ Self::Static { fun, .. } => (fun)(cx),
190 }
190 }
191 }
191 }
192
192
193 pub fn name(&self) -> &str {
193 pub fn name(&self) -> &str {
194 match &self {
194 match &self {
195− MappableCommand::Typable { name, .. } => name,
195+ Self::Typable { name, .. } => name,
196− MappableCommand::Static { name, .. } => name,
196+ Self::Static { name, .. } => name,
197 }
197 }
198 }
198 }
199
199
200 pub fn doc(&self) -> &str {
200 pub fn doc(&self) -> &str {
201 match &self {
201 match &self {
202− MappableCommand::Typable { doc, .. } => doc,
202+ Self::Typable { doc, .. } => doc,
203− MappableCommand::Static { doc, .. } => doc,
203+ Self::Static { doc, .. } => doc,
204 }
204 }
205 }
205 }
206
206
@@ -3494,11 +3494,9 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
3494 match op {
3494 match op {
3495 ResourceOp::Create(op) => {
3495 ResourceOp::Create(op) => {
3496 let path = op.uri.to_file_path().unwrap();
3496 let path = op.uri.to_file_path().unwrap();
3497− let ignore_if_exists = if let Some(options) = &op.options {
3497+ let ignore_if_exists = op.options.as_ref().map_or(false, |options| {
3498 !options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false)
3498 !options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false)
3499− } else {
3500− false
3501− };
3499+ });
3502 if ignore_if_exists && path.exists() {
3500 if ignore_if_exists && path.exists() {
3503 Ok(())
3501 Ok(())
3504 } else {
3502 } else {
@@ -3508,11 +3506,12 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
3508 ResourceOp::Delete(op) => {
3506 ResourceOp::Delete(op) => {
3509 let path = op.uri.to_file_path().unwrap();
3507 let path = op.uri.to_file_path().unwrap();
3510 if path.is_dir() {
3508 if path.is_dir() {
3511− let recursive = if let Some(options) = &op.options {
3509+ let recursive = op
3510+ .options
3511+ .as_ref()
3512+ .and_then(|options| options.recursive)
3512− options.recursive.unwrap_or(false)
3513+ .unwrap_or(false);
3513− } else {
3514+
3514− false
3515− };
3516 if recursive {
3515 if recursive {
3517 fs::remove_dir_all(&path)
3516 fs::remove_dir_all(&path)
3518 } else {
3517 } else {
@@ -3527,11 +3526,9 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
3527 ResourceOp::Rename(op) => {
3526 ResourceOp::Rename(op) => {
3528 let from = op.old_uri.to_file_path().unwrap();
3527 let from = op.old_uri.to_file_path().unwrap();
3529 let to = op.new_uri.to_file_path().unwrap();
3528 let to = op.new_uri.to_file_path().unwrap();
3530− let ignore_if_exists = if let Some(options) = &op.options {
3529+ let ignore_if_exists = op.options.as_ref().map_or(false, |options| {
3531 !options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false)
3530 !options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false)
3532− } else {
3533− false
3534− };
3531+ });
3535 if ignore_if_exists && to.exists() {
3532 if ignore_if_exists && to.exists() {
3536 Ok(())
3533 Ok(())
3537 } else {
3534 } else {
helix-term/src/job.rs+7−7
@@ -22,8 +22,8 @@ pub struct Jobs {
22}
22}
23
23
24impl Job {
24impl Job {
25− pub fn new<F: Future<Output = anyhow::Result<()>> + Send + 'static>(f: F) -> Job {
25+ pub fn new<F: Future<Output = anyhow::Result<()>> + Send + 'static>(f: F) -> Self {
26− Job {
26+ Self {
27 future: f.map(|r| r.map(|()| None)).boxed(),
27 future: f.map(|r| r.map(|()| None)).boxed(),
28 wait: false,
28 wait: false,
29 }
29 }
@@ -31,22 +31,22 @@ impl Job {
31
31
32 pub fn with_callback<F: Future<Output = anyhow::Result<Callback>> + Send + 'static>(
32 pub fn with_callback<F: Future<Output = anyhow::Result<Callback>> + Send + 'static>(
33 f: F,
33 f: F,
34− ) -> Job {
34+ ) -> Self {
35− Job {
35+ Self {
36 future: f.map(|r| r.map(Some)).boxed(),
36 future: f.map(|r| r.map(Some)).boxed(),
37 wait: false,
37 wait: false,
38 }
38 }
39 }
39 }
40
40
41− pub fn wait_before_exiting(mut self) -> Job {
41+ pub fn wait_before_exiting(mut self) -> Self {
42 self.wait = true;
42 self.wait = true;
43 self
43 self
44 }
44 }
45}
45}
46
46
47impl Jobs {
47impl Jobs {
48− pub fn new() -> Jobs {
48+ pub fn new() -> Self {
49− Jobs::default()
49+ Self::default()
50 }
50 }
51
51
52 pub fn spawn<F: Future<Output = anyhow::Result<()>> + Send + 'static>(&mut self, f: F) {
52 pub fn spawn<F: Future<Output = anyhow::Result<()>> + Send + 'static>(&mut self, f: F) {
helix-term/src/keymap.rs+4−4
@@ -344,7 +344,7 @@ pub struct Keymap {
344
344
345impl Keymap {
345impl Keymap {
346 pub fn new(root: KeyTrie) -> Self {
346 pub fn new(root: KeyTrie) -> Self {
347− Keymap {
347+ Self {
348 root,
348 root,
349 state: Vec::new(),
349 state: Vec::new(),
350 sticky: None,
350 sticky: None,
@@ -368,7 +368,7 @@ impl Keymap {
368 /// key cancels pending keystrokes. If there are no pending keystrokes but a
368 /// key cancels pending keystrokes. If there are no pending keystrokes but a
369 /// sticky node is in use, it will be cleared.
369 /// sticky node is in use, it will be cleared.
370 pub fn get(&mut self, key: KeyEvent) -> KeymapResult {
370 pub fn get(&mut self, key: KeyEvent) -> KeymapResult {
371− if let key!(Esc) = key {
371+ if key!(Esc) == key {
372 if !self.state.is_empty() {
372 if !self.state.is_empty() {
373 return KeymapResult::new(
373 return KeymapResult::new(
374 // Note that Esc is not included here
374 // Note that Esc is not included here
@@ -477,7 +477,7 @@ impl DerefMut for Keymaps {
477}
477}
478
478
479impl Default for Keymaps {
479impl Default for Keymaps {
480− fn default() -> Keymaps {
480+ fn default() -> Self {
481 let normal = keymap!({ "Normal mode"
481 let normal = keymap!({ "Normal mode"
482 "h" | "left" => move_char_left,
482 "h" | "left" => move_char_left,
483 "j" | "down" => move_line_down,
483 "j" | "down" => move_line_down,
@@ -784,7 +784,7 @@ impl Default for Keymaps {
784 "C-x" => completion,
784 "C-x" => completion,
785 "C-r" => insert_register,
785 "C-r" => insert_register,
786 });
786 });
787− Keymaps(hashmap!(
787+ Self(hashmap!(
788 Mode::Normal => Keymap::new(normal),
788 Mode::Normal => Keymap::new(normal),
789 Mode::Select => Keymap::new(select),
789 Mode::Select => Keymap::new(select),
790 Mode::Insert => Keymap::new(insert),
790 Mode::Insert => Keymap::new(insert),
helix-term/src/ui/completion.rs+1−1
@@ -158,7 +158,7 @@ impl Completion {
158 let resolved_additional_text_edits = if item.additional_text_edits.is_some() {
158 let resolved_additional_text_edits = if item.additional_text_edits.is_some() {
159 None
159 None
160 } else {
160 } else {
161− Completion::resolve_completion_item(doc, item.clone())
161+ Self::resolve_completion_item(doc, item.clone())
162 .and_then(|item| item.additional_text_edits)
162 .and_then(|item| item.additional_text_edits)
163 };
163 };
164
164
helix-tui/src/widgets/block.rs+5−5
@@ -15,12 +15,12 @@ pub enum BorderType {
15}
15}
16
16
17impl BorderType {
17impl BorderType {
18− pub fn line_symbols(border_type: BorderType) -> line::Set {
18+ pub fn line_symbols(border_type: Self) -> line::Set {
19 match border_type {
19 match border_type {
20− BorderType::Plain => line::NORMAL,
20+ Self::Plain => line::NORMAL,
21− BorderType::Rounded => line::ROUNDED,
21+ Self::Rounded => line::ROUNDED,
22− BorderType::Double => line::DOUBLE,
22+ Self::Double => line::DOUBLE,
23− BorderType::Thick => line::THICK,
23+ Self::Thick => line::THICK,
24 }
24 }
25 }
25 }
26}
26}
helix-tui/src/widgets/paragraph.rs+1−1
@@ -166,7 +166,7 @@ impl<'a> Widget for Paragraph<'a> {
166 Box::new(WordWrapper::new(&mut styled, text_area.width, trim))
166 Box::new(WordWrapper::new(&mut styled, text_area.width, trim))
167 } else {
167 } else {
168 let mut line_composer = Box::new(LineTruncator::new(&mut styled, text_area.width));
168 let mut line_composer = Box::new(LineTruncator::new(&mut styled, text_area.width));
169− if let Alignment::Left = self.alignment {
169+ if self.alignment == Alignment::Left {
170 line_composer.set_horizontal_offset(self.scroll.1);
170 line_composer.set_horizontal_offset(self.scroll.1);
171 }
171 }
172 line_composer
172 line_composer
helix-view/src/info.rs+2−2
@@ -16,7 +16,7 @@ pub struct Info {
16}
16}
17
17
18impl Info {
18impl Info {
19− pub fn new(title: &str, body: Vec<(&str, BTreeSet<KeyEvent>)>) -> Info {
19+ pub fn new(title: &str, body: Vec<(&str, BTreeSet<KeyEvent>)>) -> Self {
20 let body = body
20 let body = body
21 .into_iter()
21 .into_iter()
22 .map(|(desc, events)| {
22 .map(|(desc, events)| {
@@ -38,7 +38,7 @@ impl Info {
38 );
38 );
39 }
39 }
40
40
41− Info {
41+ Self {
42 title: title.to_string(),
42 title: title.to_string(),
43 width: text.lines().map(|l| l.width()).max().unwrap() as u16,
43 width: text.lines().map(|l| l.width()).max().unwrap() as u16,
44 height: body.len() as u16,
44 height: body.len() as u16,