From 0d5d63a80ea08f2af439bcc72fff9b24d144c70d Mon Sep 17 00:00:00 2001 From: kjeremy Date: Fri, 20 Dec 2019 15:14:30 -0500 Subject: Clippy lints --- crates/ra_lsp_server/src/main_loop.rs | 2 +- crates/ra_lsp_server/src/main_loop/handlers.rs | 2 +- crates/ra_lsp_server/src/world.rs | 20 ++++++++------------ 3 files changed, 10 insertions(+), 14 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 965e7c53c..9e207415e 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -131,7 +131,7 @@ pub fn main_loop( let feature_flags = { let mut ff = FeatureFlags::default(); for (flag, value) in config.feature_flags { - if let Err(_) = ff.set(flag.as_str(), value) { + if ff.set(flag.as_str(), value).is_err() { log::error!("unknown feature flag: {:?}", flag); show_message( req::MessageType::Error, diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 5b64b27cd..5e3b1a73f 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -164,7 +164,7 @@ pub fn handle_on_type_formatting( // in `ra_ide`, the `on_type` invariant is that // `text.char_at(position) == typed_char`. - position.offset = position.offset - TextUnit::of_char('.'); + position.offset -= TextUnit::of_char('.'); let char_typed = params.ch.chars().next().unwrap_or('\0'); // We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`, diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 16cc11e8c..f89b23089 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -287,19 +287,15 @@ impl WorldSnapshot { /// /// When processing non-windows path, this is essentially the same as `Url::from_file_path`. fn url_from_path_with_drive_lowercasing(path: impl AsRef) -> Result { - let component_has_windows_drive = path - .as_ref() - .components() - .find(|comp| { - if let Component::Prefix(c) = comp { - match c.kind() { - Prefix::Disk(_) | Prefix::VerbatimDisk(_) => return true, - _ => return false, - } + let component_has_windows_drive = path.as_ref().components().any(|comp| { + if let Component::Prefix(c) = comp { + match c.kind() { + Prefix::Disk(_) | Prefix::VerbatimDisk(_) => return true, + _ => return false, } - false - }) - .is_some(); + } + false + }); // VSCode expects drive letters to be lowercased, where rust will uppercase the drive letters. if component_has_windows_drive { -- cgit v1.2.3