diff options
author | Jeremy A. Kolb <[email protected]> | 2018-11-29 20:30:49 +0000 |
---|---|---|
committer | Jeremy A. Kolb <[email protected]> | 2018-11-29 20:30:49 +0000 |
commit | f32dc7135175c1e8a9ea81d7c18c21b2722f28c5 (patch) | |
tree | 7f63a507106e33d4c4b1282e901fbcecc4c30143 | |
parent | 70a7cb34ec18d30a680a73727e1d87a0a786dc44 (diff) |
Clippy lints
-rw-r--r-- | crates/gen_lsp_server/src/msg.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/conv.rs | 11 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main.rs | 1 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 13 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/path_map.rs | 4 |
5 files changed, 14 insertions, 17 deletions
diff --git a/crates/gen_lsp_server/src/msg.rs b/crates/gen_lsp_server/src/msg.rs index e0d0aeab5..e1b27c808 100644 --- a/crates/gen_lsp_server/src/msg.rs +++ b/crates/gen_lsp_server/src/msg.rs | |||
@@ -94,7 +94,7 @@ impl RawRequest { | |||
94 | R::Params: Serialize, | 94 | R::Params: Serialize, |
95 | { | 95 | { |
96 | RawRequest { | 96 | RawRequest { |
97 | id: id, | 97 | id, |
98 | method: R::METHOD.to_string(), | 98 | method: R::METHOD.to_string(), |
99 | params: to_value(params).unwrap(), | 99 | params: to_value(params).unwrap(), |
100 | } | 100 | } |
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 5d5a0c55e..28368787c 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs | |||
@@ -63,10 +63,7 @@ impl ConvWith for TextUnit { | |||
63 | 63 | ||
64 | fn conv_with(self, line_index: &LineIndex) -> Position { | 64 | fn conv_with(self, line_index: &LineIndex) -> Position { |
65 | let line_col = line_index.line_col(self); | 65 | let line_col = line_index.line_col(self); |
66 | Position::new( | 66 | Position::new(u64::from(line_col.line), u64::from(line_col.col_utf16)) |
67 | u64::from(line_col.line), | ||
68 | u64::from(u32::from(line_col.col_utf16)), | ||
69 | ) | ||
70 | } | 67 | } |
71 | } | 68 | } |
72 | 69 | ||
@@ -204,10 +201,8 @@ impl TryConvWith for SourceChange { | |||
204 | .map(|it| it.edits.as_slice()) | 201 | .map(|it| it.edits.as_slice()) |
205 | .unwrap_or(&[]); | 202 | .unwrap_or(&[]); |
206 | let line_col = translate_offset_with_edit(&*line_index, pos.offset, edits); | 203 | let line_col = translate_offset_with_edit(&*line_index, pos.offset, edits); |
207 | let position = Position::new( | 204 | let position = |
208 | u64::from(line_col.line), | 205 | Position::new(u64::from(line_col.line), u64::from(line_col.col_utf16)); |
209 | u64::from(u32::from(line_col.col_utf16)), | ||
210 | ); | ||
211 | Some(TextDocumentPositionParams { | 206 | Some(TextDocumentPositionParams { |
212 | text_document: TextDocumentIdentifier::new(pos.file_id.try_conv_with(world)?), | 207 | text_document: TextDocumentIdentifier::new(pos.file_id.try_conv_with(world)?), |
213 | position, | 208 | position, |
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 26bcddd8e..173418520 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs | |||
@@ -2,7 +2,6 @@ | |||
2 | extern crate log; | 2 | extern crate log; |
3 | #[macro_use] | 3 | #[macro_use] |
4 | extern crate failure; | 4 | extern crate failure; |
5 | #[macro_use] | ||
6 | extern crate serde_derive; | 5 | extern crate serde_derive; |
7 | extern crate serde; | 6 | extern crate serde; |
8 | extern crate flexi_logger; | 7 | extern crate flexi_logger; |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 27933a7ae..6d5622b15 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -384,7 +384,7 @@ pub fn handle_completion( | |||
384 | let completion_triggered_after_single_colon = { | 384 | let completion_triggered_after_single_colon = { |
385 | let mut res = false; | 385 | let mut res = false; |
386 | if let Some(ctx) = params.context { | 386 | if let Some(ctx) = params.context { |
387 | if ctx.trigger_character.unwrap_or(String::new()) == ":" { | 387 | if ctx.trigger_character.unwrap_or_default() == ":" { |
388 | let source_file = world.analysis().file_syntax(position.file_id); | 388 | let source_file = world.analysis().file_syntax(position.file_id); |
389 | let syntax = source_file.syntax(); | 389 | let syntax = source_file.syntax(); |
390 | let text = syntax.text(); | 390 | let text = syntax.text(); |
@@ -567,10 +567,13 @@ pub fn handle_rename(world: ServerWorld, params: RenameParams) -> Result<Option< | |||
567 | let mut changes = HashMap::new(); | 567 | let mut changes = HashMap::new(); |
568 | for r in refs { | 568 | for r in refs { |
569 | if let Ok(loc) = to_location(r.0, r.1, &world, &line_index) { | 569 | if let Ok(loc) = to_location(r.0, r.1, &world, &line_index) { |
570 | changes.entry(loc.uri).or_insert(Vec::new()).push(TextEdit { | 570 | changes |
571 | range: loc.range, | 571 | .entry(loc.uri) |
572 | new_text: params.new_name.clone(), | 572 | .or_insert_with(Vec::new) |
573 | }); | 573 | .push(TextEdit { |
574 | range: loc.range, | ||
575 | new_text: params.new_name.clone(), | ||
576 | }); | ||
574 | } | 577 | } |
575 | } | 578 | } |
576 | 579 | ||
diff --git a/crates/ra_lsp_server/src/path_map.rs b/crates/ra_lsp_server/src/path_map.rs index a624043d8..33babda4b 100644 --- a/crates/ra_lsp_server/src/path_map.rs +++ b/crates/ra_lsp_server/src/path_map.rs | |||
@@ -33,7 +33,7 @@ impl PathMap { | |||
33 | let file_id = self | 33 | let file_id = self |
34 | .path2id | 34 | .path2id |
35 | .get(path.as_path()) | 35 | .get(path.as_path()) |
36 | .map(|&id| id) | 36 | .cloned() |
37 | .unwrap_or_else(|| { | 37 | .unwrap_or_else(|| { |
38 | inserted = true; | 38 | inserted = true; |
39 | let id = self.new_file_id(); | 39 | let id = self.new_file_id(); |
@@ -43,7 +43,7 @@ impl PathMap { | |||
43 | (inserted, file_id) | 43 | (inserted, file_id) |
44 | } | 44 | } |
45 | pub fn get_id(&self, path: &Path) -> Option<FileId> { | 45 | pub fn get_id(&self, path: &Path) -> Option<FileId> { |
46 | self.path2id.get(path).map(|&id| id) | 46 | self.path2id.get(path).cloned() |
47 | } | 47 | } |
48 | pub fn get_path(&self, file_id: FileId) -> &Path { | 48 | pub fn get_path(&self, file_id: FileId) -> &Path { |
49 | self.id2path.get(&file_id).unwrap().as_path() | 49 | self.id2path.get(&file_id).unwrap().as_path() |