Update to rust 1.58, fix a bunch of optional lints

pull/1526/head
Blaž Hrastnik 3 years ago
parent f5b0821860
commit e7eab95b94

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"devshell": { "devshell": {
"locked": { "locked": {
"lastModified": 1640301433, "lastModified": 1641980203,
"narHash": "sha256-eplae8ZNiEmxbOgwUn9IihaJfEUxoUilkwciRPGskYE=", "narHash": "sha256-RiWJ3+6V267Ji+P54K1Xrj1Nsah9BfG/aLfIhqgVyBY=",
"owner": "numtide", "owner": "numtide",
"repo": "devshell", "repo": "devshell",
"rev": "f87fb932740abe1c1b46f6edd8a36ade17881666", "rev": "d897c1ddb4eab66cc2b783c7868d78555b9880ad",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -41,11 +41,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1641449444, "lastModified": 1642054253,
"narHash": "sha256-InqsyCVafPqXmK7YqUfFVpb6eVYJWUWbYXEvey0J+3c=", "narHash": "sha256-kHh9VmaB7gbS6pheheC4x0uT84LEmhfbsbWEQJgU2E4=",
"owner": "yusdacra", "owner": "yusdacra",
"repo": "nix-cargo-integration", "repo": "nix-cargo-integration",
"rev": "d1aa15a832db331a97082b7f8c7da737a6789c77", "rev": "f8fa9af990195a3f63fe2dde84aa187e193da793",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -56,11 +56,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1639699734, "lastModified": 1641887635,
"narHash": "sha256-tlX6WebGmiHb2Hmniff+ltYp+7dRfdsBxw9YczLsP60=", "narHash": "sha256-kDGpufwzVaiGe5e1sBUBPo9f1YN+nYHJlYqCaVpZTQQ=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "03ec468b14067729a285c2c7cfa7b9434a04816c", "rev": "b2737d4980a17cc2b7d600d7d0b32fd7333aca88",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -99,11 +99,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1639880499, "lastModified": 1642128126,
"narHash": "sha256-/BibDmFwgWuuTUkNVO6YlvuTSWM9dpBvlZoTAPs7ORI=", "narHash": "sha256-av8JUACdrTfQYl/ftZJvKpZEmZfa0avCq7tt5Usdoq0=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "c6c83589ae048af20d93d01eb07a4176012093d0", "rev": "ce4ef6f2d74f2b68f7547df1de22d1b0037ce4ad",
"type": "github" "type": "github"
}, },
"original": { "original": {

@ -195,82 +195,82 @@ struct DateField {
impl DateField { impl DateField {
fn from_specifier(specifier: &str) -> Option<Self> { fn from_specifier(specifier: &str) -> Option<Self> {
match specifier { match specifier {
"Y" => Some(DateField { "Y" => Some(Self {
regex: r"\d{4}", regex: r"\d{4}",
unit: DateUnit::Years, unit: DateUnit::Years,
max_len: 5, max_len: 5,
}), }),
"y" => Some(DateField { "y" => Some(Self {
regex: r"\d\d", regex: r"\d\d",
unit: DateUnit::Years, unit: DateUnit::Years,
max_len: 2, max_len: 2,
}), }),
"m" => Some(DateField { "m" => Some(Self {
regex: r"[0-1]\d", regex: r"[0-1]\d",
unit: DateUnit::Months, unit: DateUnit::Months,
max_len: 2, max_len: 2,
}), }),
"d" => Some(DateField { "d" => Some(Self {
regex: r"[0-3]\d", regex: r"[0-3]\d",
unit: DateUnit::Days, unit: DateUnit::Days,
max_len: 2, max_len: 2,
}), }),
"-d" => Some(DateField { "-d" => Some(Self {
regex: r"[1-3]?\d", regex: r"[1-3]?\d",
unit: DateUnit::Days, unit: DateUnit::Days,
max_len: 2, max_len: 2,
}), }),
"a" => Some(DateField { "a" => Some(Self {
regex: r"Sun|Mon|Tue|Wed|Thu|Fri|Sat", regex: r"Sun|Mon|Tue|Wed|Thu|Fri|Sat",
unit: DateUnit::Days, unit: DateUnit::Days,
max_len: 3, max_len: 3,
}), }),
"A" => Some(DateField { "A" => Some(Self {
regex: r"Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday", regex: r"Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday",
unit: DateUnit::Days, unit: DateUnit::Days,
max_len: 9, max_len: 9,
}), }),
"b" | "h" => Some(DateField { "b" | "h" => Some(Self {
regex: r"Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec", regex: r"Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec",
unit: DateUnit::Months, unit: DateUnit::Months,
max_len: 3, max_len: 3,
}), }),
"B" => Some(DateField { "B" => Some(Self {
regex: r"January|February|March|April|May|June|July|August|September|October|November|December", regex: r"January|February|March|April|May|June|July|August|September|October|November|December",
unit: DateUnit::Months, unit: DateUnit::Months,
max_len: 9, max_len: 9,
}), }),
"H" => Some(DateField { "H" => Some(Self {
regex: r"[0-2]\d", regex: r"[0-2]\d",
unit: DateUnit::Hours, unit: DateUnit::Hours,
max_len: 2, max_len: 2,
}), }),
"M" => Some(DateField { "M" => Some(Self {
regex: r"[0-5]\d", regex: r"[0-5]\d",
unit: DateUnit::Minutes, unit: DateUnit::Minutes,
max_len: 2, max_len: 2,
}), }),
"S" => Some(DateField { "S" => Some(Self {
regex: r"[0-5]\d", regex: r"[0-5]\d",
unit: DateUnit::Seconds, unit: DateUnit::Seconds,
max_len: 2, max_len: 2,
}), }),
"I" => Some(DateField { "I" => Some(Self {
regex: r"[0-1]\d", regex: r"[0-1]\d",
unit: DateUnit::Hours, unit: DateUnit::Hours,
max_len: 2, max_len: 2,
}), }),
"-I" => Some(DateField { "-I" => Some(Self {
regex: r"1?\d", regex: r"1?\d",
unit: DateUnit::Hours, unit: DateUnit::Hours,
max_len: 2, max_len: 2,
}), }),
"P" => Some(DateField { "P" => Some(Self {
regex: r"am|pm", regex: r"am|pm",
unit: DateUnit::AmPm, unit: DateUnit::AmPm,
max_len: 2, max_len: 2,
}), }),
"p" => Some(DateField { "p" => Some(Self {
regex: r"AM|PM", regex: r"AM|PM",
unit: DateUnit::AmPm, unit: DateUnit::AmPm,
max_len: 2, max_len: 2,

@ -173,7 +173,7 @@ macro_rules! static_commands {
impl MappableCommand { impl MappableCommand {
pub fn execute(&self, cx: &mut Context) { pub fn execute(&self, cx: &mut Context) {
match &self { match &self {
MappableCommand::Typable { name, args, doc: _ } => { Self::Typable { name, args, doc: _ } => {
let args: Vec<Cow<str>> = args.iter().map(Cow::from).collect(); let args: Vec<Cow<str>> = args.iter().map(Cow::from).collect();
if let Some(command) = cmd::TYPABLE_COMMAND_MAP.get(name.as_str()) { if let Some(command) = cmd::TYPABLE_COMMAND_MAP.get(name.as_str()) {
let mut cx = compositor::Context { let mut cx = compositor::Context {
@ -186,21 +186,21 @@ impl MappableCommand {
} }
} }
} }
MappableCommand::Static { fun, .. } => (fun)(cx), Self::Static { fun, .. } => (fun)(cx),
} }
} }
pub fn name(&self) -> &str { pub fn name(&self) -> &str {
match &self { match &self {
MappableCommand::Typable { name, .. } => name, Self::Typable { name, .. } => name,
MappableCommand::Static { name, .. } => name, Self::Static { name, .. } => name,
} }
} }
pub fn doc(&self) -> &str { pub fn doc(&self) -> &str {
match &self { match &self {
MappableCommand::Typable { doc, .. } => doc, Self::Typable { doc, .. } => doc,
MappableCommand::Static { doc, .. } => doc, Self::Static { doc, .. } => doc,
} }
} }
@ -3494,11 +3494,9 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
match op { match op {
ResourceOp::Create(op) => { ResourceOp::Create(op) => {
let path = op.uri.to_file_path().unwrap(); let path = op.uri.to_file_path().unwrap();
let ignore_if_exists = if let Some(options) = &op.options { let ignore_if_exists = op.options.as_ref().map_or(false, |options| {
!options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false) !options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false)
} else { });
false
};
if ignore_if_exists && path.exists() { if ignore_if_exists && path.exists() {
Ok(()) Ok(())
} else { } else {
@ -3508,11 +3506,12 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
ResourceOp::Delete(op) => { ResourceOp::Delete(op) => {
let path = op.uri.to_file_path().unwrap(); let path = op.uri.to_file_path().unwrap();
if path.is_dir() { if path.is_dir() {
let recursive = if let Some(options) = &op.options { let recursive = op
options.recursive.unwrap_or(false) .options
} else { .as_ref()
false .and_then(|options| options.recursive)
}; .unwrap_or(false);
if recursive { if recursive {
fs::remove_dir_all(&path) fs::remove_dir_all(&path)
} else { } else {
@ -3527,11 +3526,9 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
ResourceOp::Rename(op) => { ResourceOp::Rename(op) => {
let from = op.old_uri.to_file_path().unwrap(); let from = op.old_uri.to_file_path().unwrap();
let to = op.new_uri.to_file_path().unwrap(); let to = op.new_uri.to_file_path().unwrap();
let ignore_if_exists = if let Some(options) = &op.options { let ignore_if_exists = op.options.as_ref().map_or(false, |options| {
!options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false) !options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false)
} else { });
false
};
if ignore_if_exists && to.exists() { if ignore_if_exists && to.exists() {
Ok(()) Ok(())
} else { } else {

@ -22,8 +22,8 @@ pub struct Jobs {
} }
impl Job { impl Job {
pub fn new<F: Future<Output = anyhow::Result<()>> + Send + 'static>(f: F) -> Job { pub fn new<F: Future<Output = anyhow::Result<()>> + Send + 'static>(f: F) -> Self {
Job { Self {
future: f.map(|r| r.map(|()| None)).boxed(), future: f.map(|r| r.map(|()| None)).boxed(),
wait: false, wait: false,
} }
@ -31,22 +31,22 @@ impl Job {
pub fn with_callback<F: Future<Output = anyhow::Result<Callback>> + Send + 'static>( pub fn with_callback<F: Future<Output = anyhow::Result<Callback>> + Send + 'static>(
f: F, f: F,
) -> Job { ) -> Self {
Job { Self {
future: f.map(|r| r.map(Some)).boxed(), future: f.map(|r| r.map(Some)).boxed(),
wait: false, wait: false,
} }
} }
pub fn wait_before_exiting(mut self) -> Job { pub fn wait_before_exiting(mut self) -> Self {
self.wait = true; self.wait = true;
self self
} }
} }
impl Jobs { impl Jobs {
pub fn new() -> Jobs { pub fn new() -> Self {
Jobs::default() Self::default()
} }
pub fn spawn<F: Future<Output = anyhow::Result<()>> + Send + 'static>(&mut self, f: F) { pub fn spawn<F: Future<Output = anyhow::Result<()>> + Send + 'static>(&mut self, f: F) {

@ -344,7 +344,7 @@ pub struct Keymap {
impl Keymap { impl Keymap {
pub fn new(root: KeyTrie) -> Self { pub fn new(root: KeyTrie) -> Self {
Keymap { Self {
root, root,
state: Vec::new(), state: Vec::new(),
sticky: None, sticky: None,
@ -368,7 +368,7 @@ impl Keymap {
/// key cancels pending keystrokes. If there are no pending keystrokes but a /// key cancels pending keystrokes. If there are no pending keystrokes but a
/// sticky node is in use, it will be cleared. /// sticky node is in use, it will be cleared.
pub fn get(&mut self, key: KeyEvent) -> KeymapResult { pub fn get(&mut self, key: KeyEvent) -> KeymapResult {
if let key!(Esc) = key { if key!(Esc) == key {
if !self.state.is_empty() { if !self.state.is_empty() {
return KeymapResult::new( return KeymapResult::new(
// Note that Esc is not included here // Note that Esc is not included here
@ -477,7 +477,7 @@ impl DerefMut for Keymaps {
} }
impl Default for Keymaps { impl Default for Keymaps {
fn default() -> Keymaps { fn default() -> Self {
let normal = keymap!({ "Normal mode" let normal = keymap!({ "Normal mode"
"h" | "left" => move_char_left, "h" | "left" => move_char_left,
"j" | "down" => move_line_down, "j" | "down" => move_line_down,
@ -784,7 +784,7 @@ impl Default for Keymaps {
"C-x" => completion, "C-x" => completion,
"C-r" => insert_register, "C-r" => insert_register,
}); });
Keymaps(hashmap!( Self(hashmap!(
Mode::Normal => Keymap::new(normal), Mode::Normal => Keymap::new(normal),
Mode::Select => Keymap::new(select), Mode::Select => Keymap::new(select),
Mode::Insert => Keymap::new(insert), Mode::Insert => Keymap::new(insert),

@ -158,7 +158,7 @@ impl Completion {
let resolved_additional_text_edits = if item.additional_text_edits.is_some() { let resolved_additional_text_edits = if item.additional_text_edits.is_some() {
None None
} else { } else {
Completion::resolve_completion_item(doc, item.clone()) Self::resolve_completion_item(doc, item.clone())
.and_then(|item| item.additional_text_edits) .and_then(|item| item.additional_text_edits)
}; };

@ -15,12 +15,12 @@ pub enum BorderType {
} }
impl BorderType { impl BorderType {
pub fn line_symbols(border_type: BorderType) -> line::Set { pub fn line_symbols(border_type: Self) -> line::Set {
match border_type { match border_type {
BorderType::Plain => line::NORMAL, Self::Plain => line::NORMAL,
BorderType::Rounded => line::ROUNDED, Self::Rounded => line::ROUNDED,
BorderType::Double => line::DOUBLE, Self::Double => line::DOUBLE,
BorderType::Thick => line::THICK, Self::Thick => line::THICK,
} }
} }
} }

@ -166,7 +166,7 @@ impl<'a> Widget for Paragraph<'a> {
Box::new(WordWrapper::new(&mut styled, text_area.width, trim)) Box::new(WordWrapper::new(&mut styled, text_area.width, trim))
} else { } else {
let mut line_composer = Box::new(LineTruncator::new(&mut styled, text_area.width)); let mut line_composer = Box::new(LineTruncator::new(&mut styled, text_area.width));
if let Alignment::Left = self.alignment { if self.alignment == Alignment::Left {
line_composer.set_horizontal_offset(self.scroll.1); line_composer.set_horizontal_offset(self.scroll.1);
} }
line_composer line_composer

@ -16,7 +16,7 @@ pub struct Info {
} }
impl Info { impl Info {
pub fn new(title: &str, body: Vec<(&str, BTreeSet<KeyEvent>)>) -> Info { pub fn new(title: &str, body: Vec<(&str, BTreeSet<KeyEvent>)>) -> Self {
let body = body let body = body
.into_iter() .into_iter()
.map(|(desc, events)| { .map(|(desc, events)| {
@ -38,7 +38,7 @@ impl Info {
); );
} }
Info { Self {
title: title.to_string(), title: title.to_string(),
width: text.lines().map(|l| l.width()).max().unwrap() as u16, width: text.lines().map(|l| l.width()).max().unwrap() as u16,
height: body.len() as u16, height: body.len() as u16,

Loading…
Cancel
Save