on master help sign in
Update to rust 1.58, fix a bunch of optional lints
commite7eab95b943ff15396c5d512a9c95650ab98a902 authorBlaž Hrastnik <blaz@mxxn.io> dateFri 14 Jan 2022, 12:25 (5 years ago) parentf5b0821
9 files changed+64−67
flake.lock+12−12 helix-core/src/increment/date_time.rs+16−16 helix-term/src/commands.rs+16−19 helix-term/src/job.rs+7−7 helix-term/src/keymap.rs+4−4 helix-term/src/ui/completion.rs+1−1 helix-tui/src/widgets/block.rs+5−5 helix-tui/src/widgets/paragraph.rs+1−1 helix-view/src/info.rs+2−2
flake.lock+12−12
@@ -2,11 +2,11 @@
22 "nodes": {
33 "devshell": {
44 "locked": {
5− "lastModified": 1640301433,
6− "narHash": "sha256-eplae8ZNiEmxbOgwUn9IihaJfEUxoUilkwciRPGskYE=",
5+ "lastModified": 1641980203,
6+ "narHash": "sha256-RiWJ3+6V267Ji+P54K1Xrj1Nsah9BfG/aLfIhqgVyBY=",
77 "owner": "numtide",
88 "repo": "devshell",
9− "rev": "f87fb932740abe1c1b46f6edd8a36ade17881666",
9+ "rev": "d897c1ddb4eab66cc2b783c7868d78555b9880ad",
1010 "type": "github"
1111 },
1212 "original": {
@@ -41,11 +41,11 @@
4141 ]
4242 },
4343 "locked": {
44− "lastModified": 1641449444,
45− "narHash": "sha256-InqsyCVafPqXmK7YqUfFVpb6eVYJWUWbYXEvey0J+3c=",
44+ "lastModified": 1642054253,
45+ "narHash": "sha256-kHh9VmaB7gbS6pheheC4x0uT84LEmhfbsbWEQJgU2E4=",
4646 "owner": "yusdacra",
4747 "repo": "nix-cargo-integration",
48− "rev": "d1aa15a832db331a97082b7f8c7da737a6789c77",
48+ "rev": "f8fa9af990195a3f63fe2dde84aa187e193da793",
4949 "type": "github"
5050 },
5151 "original": {
@@ -56,11 +56,11 @@
5656 },
5757 "nixpkgs": {
5858 "locked": {
59− "lastModified": 1639699734,
60− "narHash": "sha256-tlX6WebGmiHb2Hmniff+ltYp+7dRfdsBxw9YczLsP60=",
59+ "lastModified": 1641887635,
60+ "narHash": "sha256-kDGpufwzVaiGe5e1sBUBPo9f1YN+nYHJlYqCaVpZTQQ=",
6161 "owner": "nixos",
6262 "repo": "nixpkgs",
63− "rev": "03ec468b14067729a285c2c7cfa7b9434a04816c",
63+ "rev": "b2737d4980a17cc2b7d600d7d0b32fd7333aca88",
6464 "type": "github"
6565 },
6666 "original": {
@@ -99,11 +99,11 @@
9999 "nixpkgs": "nixpkgs_2"
100100 },
101101 "locked": {
102− "lastModified": 1639880499,
103− "narHash": "sha256-/BibDmFwgWuuTUkNVO6YlvuTSWM9dpBvlZoTAPs7ORI=",
102+ "lastModified": 1642128126,
103+ "narHash": "sha256-av8JUACdrTfQYl/ftZJvKpZEmZfa0avCq7tt5Usdoq0=",
104104 "owner": "oxalica",
105105 "repo": "rust-overlay",
106− "rev": "c6c83589ae048af20d93d01eb07a4176012093d0",
106+ "rev": "ce4ef6f2d74f2b68f7547df1de22d1b0037ce4ad",
107107 "type": "github"
108108 },
109109 "original": {
helix-core/src/increment/date_time.rs+16−16
@@ -195,82 +195,82 @@ struct DateField {
195195impl DateField {
196196 fn from_specifier(specifier: &str) -> Option<Self> {
197197 match specifier {
198− "Y" => Some(DateField {
198+ "Y" => Some(Self {
199199 regex: r"\d{4}",
200200 unit: DateUnit::Years,
201201 max_len: 5,
202202 }),
203− "y" => Some(DateField {
203+ "y" => Some(Self {
204204 regex: r"\d\d",
205205 unit: DateUnit::Years,
206206 max_len: 2,
207207 }),
208− "m" => Some(DateField {
208+ "m" => Some(Self {
209209 regex: r"[0-1]\d",
210210 unit: DateUnit::Months,
211211 max_len: 2,
212212 }),
213− "d" => Some(DateField {
213+ "d" => Some(Self {
214214 regex: r"[0-3]\d",
215215 unit: DateUnit::Days,
216216 max_len: 2,
217217 }),
218− "-d" => Some(DateField {
218+ "-d" => Some(Self {
219219 regex: r"[1-3]?\d",
220220 unit: DateUnit::Days,
221221 max_len: 2,
222222 }),
223− "a" => Some(DateField {
223+ "a" => Some(Self {
224224 regex: r"Sun|Mon|Tue|Wed|Thu|Fri|Sat",
225225 unit: DateUnit::Days,
226226 max_len: 3,
227227 }),
228− "A" => Some(DateField {
228+ "A" => Some(Self {
229229 regex: r"Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday",
230230 unit: DateUnit::Days,
231231 max_len: 9,
232232 }),
233− "b" | "h" => Some(DateField {
233+ "b" | "h" => Some(Self {
234234 regex: r"Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec",
235235 unit: DateUnit::Months,
236236 max_len: 3,
237237 }),
238− "B" => Some(DateField {
238+ "B" => Some(Self {
239239 regex: r"January|February|March|April|May|June|July|August|September|October|November|December",
240240 unit: DateUnit::Months,
241241 max_len: 9,
242242 }),
243− "H" => Some(DateField {
243+ "H" => Some(Self {
244244 regex: r"[0-2]\d",
245245 unit: DateUnit::Hours,
246246 max_len: 2,
247247 }),
248− "M" => Some(DateField {
248+ "M" => Some(Self {
249249 regex: r"[0-5]\d",
250250 unit: DateUnit::Minutes,
251251 max_len: 2,
252252 }),
253− "S" => Some(DateField {
253+ "S" => Some(Self {
254254 regex: r"[0-5]\d",
255255 unit: DateUnit::Seconds,
256256 max_len: 2,
257257 }),
258− "I" => Some(DateField {
258+ "I" => Some(Self {
259259 regex: r"[0-1]\d",
260260 unit: DateUnit::Hours,
261261 max_len: 2,
262262 }),
263− "-I" => Some(DateField {
263+ "-I" => Some(Self {
264264 regex: r"1?\d",
265265 unit: DateUnit::Hours,
266266 max_len: 2,
267267 }),
268− "P" => Some(DateField {
268+ "P" => Some(Self {
269269 regex: r"am|pm",
270270 unit: DateUnit::AmPm,
271271 max_len: 2,
272272 }),
273− "p" => Some(DateField {
273+ "p" => Some(Self {
274274 regex: r"AM|PM",
275275 unit: DateUnit::AmPm,
276276 max_len: 2,
helix-term/src/commands.rs+16−19
@@ -173,7 +173,7 @@ macro_rules! static_commands {
173173impl MappableCommand {
174174 pub fn execute(&self, cx: &mut Context) {
175175 match &self {
176− MappableCommand::Typable { name, args, doc: _ } => {
176+ Self::Typable { name, args, doc: _ } => {
177177 let args: Vec<Cow<str>> = args.iter().map(Cow::from).collect();
178178 if let Some(command) = cmd::TYPABLE_COMMAND_MAP.get(name.as_str()) {
179179 let mut cx = compositor::Context {
@@ -186,21 +186,21 @@ impl MappableCommand {
186186 }
187187 }
188188 }
189− MappableCommand::Static { fun, .. } => (fun)(cx),
189+ Self::Static { fun, .. } => (fun)(cx),
190190 }
191191 }
192192
193193 pub fn name(&self) -> &str {
194194 match &self {
195− MappableCommand::Typable { name, .. } => name,
196− MappableCommand::Static { name, .. } => name,
195+ Self::Typable { name, .. } => name,
196+ Self::Static { name, .. } => name,
197197 }
198198 }
199199
200200 pub fn doc(&self) -> &str {
201201 match &self {
202− MappableCommand::Typable { doc, .. } => doc,
203− MappableCommand::Static { doc, .. } => doc,
202+ Self::Typable { doc, .. } => doc,
203+ Self::Static { doc, .. } => doc,
204204 }
205205 }
206206
@@ -3494,11 +3494,9 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
34943494 match op {
34953495 ResourceOp::Create(op) => {
34963496 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| {
34983498 !options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false)
3499− } else {
3500− false
3501− };
3499+ });
35023500 if ignore_if_exists && path.exists() {
35033501 Ok(())
35043502 } else {
@@ -3508,11 +3506,12 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
35083506 ResourceOp::Delete(op) => {
35093507 let path = op.uri.to_file_path().unwrap();
35103508 if path.is_dir() {
3511− let recursive = if let Some(options) = &op.options {
3512− options.recursive.unwrap_or(false)
3513− } else {
3514− false
3515− };
3509+ let recursive = op
3510+ .options
3511+ .as_ref()
3512+ .and_then(|options| options.recursive)
3513+ .unwrap_or(false);
3514+
35163515 if recursive {
35173516 fs::remove_dir_all(&path)
35183517 } else {
@@ -3527,11 +3526,9 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
35273526 ResourceOp::Rename(op) => {
35283527 let from = op.old_uri.to_file_path().unwrap();
35293528 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| {
35313530 !options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false)
3532− } else {
3533− false
3534− };
3531+ });
35353532 if ignore_if_exists && to.exists() {
35363533 Ok(())
35373534 } else {
helix-term/src/job.rs+7−7
@@ -22,8 +22,8 @@ pub struct Jobs {
2222}
2323
2424impl Job {
25− pub fn new<F: Future<Output = anyhow::Result<()>> + Send + 'static>(f: F) -> Job {
26− Job {
25+ pub fn new<F: Future<Output = anyhow::Result<()>> + Send + 'static>(f: F) -> Self {
26+ Self {
2727 future: f.map(|r| r.map(|()| None)).boxed(),
2828 wait: false,
2929 }
@@ -31,22 +31,22 @@ impl Job {
3131
3232 pub fn with_callback<F: Future<Output = anyhow::Result<Callback>> + Send + 'static>(
3333 f: F,
34− ) -> Job {
35− Job {
34+ ) -> Self {
35+ Self {
3636 future: f.map(|r| r.map(Some)).boxed(),
3737 wait: false,
3838 }
3939 }
4040
41− pub fn wait_before_exiting(mut self) -> Job {
41+ pub fn wait_before_exiting(mut self) -> Self {
4242 self.wait = true;
4343 self
4444 }
4545}
4646
4747impl Jobs {
48− pub fn new() -> Jobs {
49− Jobs::default()
48+ pub fn new() -> Self {
49+ Self::default()
5050 }
5151
5252 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 {
344344
345345impl Keymap {
346346 pub fn new(root: KeyTrie) -> Self {
347− Keymap {
347+ Self {
348348 root,
349349 state: Vec::new(),
350350 sticky: None,
@@ -368,7 +368,7 @@ impl Keymap {
368368 /// key cancels pending keystrokes. If there are no pending keystrokes but a
369369 /// sticky node is in use, it will be cleared.
370370 pub fn get(&mut self, key: KeyEvent) -> KeymapResult {
371− if let key!(Esc) = key {
371+ if key!(Esc) == key {
372372 if !self.state.is_empty() {
373373 return KeymapResult::new(
374374 // Note that Esc is not included here
@@ -477,7 +477,7 @@ impl DerefMut for Keymaps {
477477}
478478
479479impl Default for Keymaps {
480− fn default() -> Keymaps {
480+ fn default() -> Self {
481481 let normal = keymap!({ "Normal mode"
482482 "h" | "left" => move_char_left,
483483 "j" | "down" => move_line_down,
@@ -784,7 +784,7 @@ impl Default for Keymaps {
784784 "C-x" => completion,
785785 "C-r" => insert_register,
786786 });
787− Keymaps(hashmap!(
787+ Self(hashmap!(
788788 Mode::Normal => Keymap::new(normal),
789789 Mode::Select => Keymap::new(select),
790790 Mode::Insert => Keymap::new(insert),
helix-term/src/ui/completion.rs+1−1
@@ -158,7 +158,7 @@ impl Completion {
158158 let resolved_additional_text_edits = if item.additional_text_edits.is_some() {
159159 None
160160 } else {
161− Completion::resolve_completion_item(doc, item.clone())
161+ Self::resolve_completion_item(doc, item.clone())
162162 .and_then(|item| item.additional_text_edits)
163163 };
164164
helix-tui/src/widgets/block.rs+5−5
@@ -15,12 +15,12 @@ pub enum BorderType {
1515}
1616
1717impl BorderType {
18− pub fn line_symbols(border_type: BorderType) -> line::Set {
18+ pub fn line_symbols(border_type: Self) -> line::Set {
1919 match border_type {
20− BorderType::Plain => line::NORMAL,
21− BorderType::Rounded => line::ROUNDED,
22− BorderType::Double => line::DOUBLE,
23− BorderType::Thick => line::THICK,
20+ Self::Plain => line::NORMAL,
21+ Self::Rounded => line::ROUNDED,
22+ Self::Double => line::DOUBLE,
23+ Self::Thick => line::THICK,
2424 }
2525 }
2626}
helix-tui/src/widgets/paragraph.rs+1−1
@@ -166,7 +166,7 @@ impl<'a> Widget for Paragraph<'a> {
166166 Box::new(WordWrapper::new(&mut styled, text_area.width, trim))
167167 } else {
168168 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 {
170170 line_composer.set_horizontal_offset(self.scroll.1);
171171 }
172172 line_composer
helix-view/src/info.rs+2−2
@@ -16,7 +16,7 @@ pub struct Info {
1616}
1717
1818impl 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 {
2020 let body = body
2121 .into_iter()
2222 .map(|(desc, events)| {
@@ -38,7 +38,7 @@ impl Info {
3838 );
3939 }
4040
41− Info {
41+ Self {
4242 title: title.to_string(),
4343 width: text.lines().map(|l| l.width()).max().unwrap() as u16,
4444 height: body.len() as u16,