diff options
author | kjeremy <[email protected]> | 2019-02-06 20:50:26 +0000 |
---|---|---|
committer | kjeremy <[email protected]> | 2019-02-06 20:50:26 +0000 |
commit | 6753051a45e067fb8267f7ecbbf1b894558718d1 (patch) | |
tree | 9da7f488f6564ac7f84d54ae9fc7296bcf2460e4 | |
parent | c1e10a24fa3ba2b03a738afd8e1f7f472a12e29f (diff) |
Some clippy cleanups
-rw-r--r-- | crates/ra_assists/src/introduce_variable.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/expr.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/expr/scope.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/impl_block.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/resolve.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_context.rs | 9 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_item.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/rename.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide_api/src/symbol_index.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/conv.rs | 7 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 34 |
15 files changed, 49 insertions, 55 deletions
diff --git a/crates/ra_assists/src/introduce_variable.rs b/crates/ra_assists/src/introduce_variable.rs index c937a816c..f587b4fe6 100644 --- a/crates/ra_assists/src/introduce_variable.rs +++ b/crates/ra_assists/src/introduce_variable.rs | |||
@@ -8,7 +8,7 @@ use ra_syntax::{ | |||
8 | 8 | ||
9 | use crate::{AssistCtx, Assist}; | 9 | use crate::{AssistCtx, Assist}; |
10 | 10 | ||
11 | pub(crate) fn introduce_variable<'a>(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 11 | pub(crate) fn introduce_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
12 | let node = ctx.covering_node(); | 12 | let node = ctx.covering_node(); |
13 | if !valid_covering_node(node) { | 13 | if !valid_covering_node(node) { |
14 | return None; | 14 | return None; |
@@ -61,13 +61,13 @@ fn valid_covering_node(node: &SyntaxNode) -> bool { | |||
61 | /// Check wether the node is a valid expression which can be extracted to a variable. | 61 | /// Check wether the node is a valid expression which can be extracted to a variable. |
62 | /// In general that's true for any expression, but in some cases that would produce invalid code. | 62 | /// In general that's true for any expression, but in some cases that would produce invalid code. |
63 | fn valid_target_expr(node: &SyntaxNode) -> Option<&ast::Expr> { | 63 | fn valid_target_expr(node: &SyntaxNode) -> Option<&ast::Expr> { |
64 | return match node.kind() { | 64 | match node.kind() { |
65 | PATH_EXPR => None, | 65 | PATH_EXPR => None, |
66 | BREAK_EXPR => ast::BreakExpr::cast(node).and_then(|e| e.expr()), | 66 | BREAK_EXPR => ast::BreakExpr::cast(node).and_then(|e| e.expr()), |
67 | RETURN_EXPR => ast::ReturnExpr::cast(node).and_then(|e| e.expr()), | 67 | RETURN_EXPR => ast::ReturnExpr::cast(node).and_then(|e| e.expr()), |
68 | LOOP_EXPR => ast::ReturnExpr::cast(node).and_then(|e| e.expr()), | 68 | LOOP_EXPR => ast::ReturnExpr::cast(node).and_then(|e| e.expr()), |
69 | _ => ast::Expr::cast(node), | 69 | _ => ast::Expr::cast(node), |
70 | }; | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | /// Returns the syntax node which will follow the freshly introduced var | 73 | /// Returns the syntax node which will follow the freshly introduced var |
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index f9f702ae2..6826e966b 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -805,7 +805,7 @@ impl ExprCollector { | |||
805 | let lit = match child.flavor() { | 805 | let lit = match child.flavor() { |
806 | LiteralFlavor::IntNumber { suffix } => { | 806 | LiteralFlavor::IntNumber { suffix } => { |
807 | let known_name = suffix | 807 | let known_name = suffix |
808 | .map(|s| Name::new(s)) | 808 | .map(Name::new) |
809 | .and_then(|name| UncertainIntTy::from_name(&name)); | 809 | .and_then(|name| UncertainIntTy::from_name(&name)); |
810 | 810 | ||
811 | Literal::Int( | 811 | Literal::Int( |
@@ -815,7 +815,7 @@ impl ExprCollector { | |||
815 | } | 815 | } |
816 | LiteralFlavor::FloatNumber { suffix } => { | 816 | LiteralFlavor::FloatNumber { suffix } => { |
817 | let known_name = suffix | 817 | let known_name = suffix |
818 | .map(|s| Name::new(s)) | 818 | .map(Name::new) |
819 | .and_then(|name| UncertainFloatTy::from_name(&name)); | 819 | .and_then(|name| UncertainFloatTy::from_name(&name)); |
820 | 820 | ||
821 | Literal::Float( | 821 | Literal::Float( |
@@ -910,7 +910,7 @@ impl ExprCollector { | |||
910 | } | 910 | } |
911 | ast::PatKind::PathPat(p) => { | 911 | ast::PatKind::PathPat(p) => { |
912 | let path = p.path().and_then(Path::from_ast); | 912 | let path = p.path().and_then(Path::from_ast); |
913 | path.map(|path| Pat::Path(path)).unwrap_or(Pat::Missing) | 913 | path.map(Pat::Path).unwrap_or(Pat::Missing) |
914 | } | 914 | } |
915 | ast::PatKind::TuplePat(p) => { | 915 | ast::PatKind::TuplePat(p) => { |
916 | let args = p.args().map(|p| self.collect_pat(p)).collect(); | 916 | let args = p.args().map(|p| self.collect_pat(p)).collect(); |
diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index 9202e3671..368994bf7 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs | |||
@@ -105,7 +105,7 @@ impl ExprScopes { | |||
105 | fn add_params_bindings(&mut self, scope: ScopeId, params: &[PatId]) { | 105 | fn add_params_bindings(&mut self, scope: ScopeId, params: &[PatId]) { |
106 | let body = Arc::clone(&self.body); | 106 | let body = Arc::clone(&self.body); |
107 | params | 107 | params |
108 | .into_iter() | 108 | .iter() |
109 | .for_each(|pat| self.add_bindings(&body, scope, *pat)); | 109 | .for_each(|pat| self.add_bindings(&body, scope, *pat)); |
110 | } | 110 | } |
111 | 111 | ||
@@ -147,7 +147,7 @@ impl ScopesWithSyntaxMapping { | |||
147 | }) | 147 | }) |
148 | } | 148 | } |
149 | 149 | ||
150 | pub fn scope_for_offset<'a>(&'a self, offset: TextUnit) -> Option<ScopeId> { | 150 | pub fn scope_for_offset(&self, offset: TextUnit) -> Option<ScopeId> { |
151 | self.scopes | 151 | self.scopes |
152 | .scope_for | 152 | .scope_for |
153 | .iter() | 153 | .iter() |
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index 738c58fbe..094dbedb3 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs | |||
@@ -72,7 +72,7 @@ impl ImplBlock { | |||
72 | } | 72 | } |
73 | 73 | ||
74 | pub fn module(&self) -> Module { | 74 | pub fn module(&self) -> Module { |
75 | self.module_impl_blocks.module.clone() | 75 | self.module_impl_blocks.module |
76 | } | 76 | } |
77 | 77 | ||
78 | pub fn target_trait_ref(&self) -> Option<&TypeRef> { | 78 | pub fn target_trait_ref(&self) -> Option<&TypeRef> { |
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs index 5ca7bacb5..0f60d4742 100644 --- a/crates/ra_hir/src/resolve.rs +++ b/crates/ra_hir/src/resolve.rs | |||
@@ -78,7 +78,7 @@ impl Resolver { | |||
78 | _ => return PerNs::none(), | 78 | _ => return PerNs::none(), |
79 | }; | 79 | }; |
80 | let module_res = item_map.resolve_path(db, module, path); | 80 | let module_res = item_map.resolve_path(db, module, path); |
81 | module_res.map(|def| Resolution::Def(def)) | 81 | module_res.map(Resolution::Def) |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index cc5afad75..86a7f8b83 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -1225,7 +1225,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1225 | Ty::Tuple(ref tuple_args) => &**tuple_args, | 1225 | Ty::Tuple(ref tuple_args) => &**tuple_args, |
1226 | _ => &[], | 1226 | _ => &[], |
1227 | }; | 1227 | }; |
1228 | let expectations_iter = expectations.into_iter().chain(repeat(&Ty::Unknown)); | 1228 | let expectations_iter = expectations.iter().chain(repeat(&Ty::Unknown)); |
1229 | 1229 | ||
1230 | let inner_tys = args | 1230 | let inner_tys = args |
1231 | .iter() | 1231 | .iter() |
@@ -1398,10 +1398,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1398 | let method_ty = self.insert_type_vars(method_ty); | 1398 | let method_ty = self.insert_type_vars(method_ty); |
1399 | let (expected_receiver_ty, param_tys, ret_ty) = match &method_ty { | 1399 | let (expected_receiver_ty, param_tys, ret_ty) = match &method_ty { |
1400 | Ty::FnPtr(sig) => { | 1400 | Ty::FnPtr(sig) => { |
1401 | if sig.input.len() > 0 { | 1401 | if !sig.input.is_empty() { |
1402 | ( | 1402 | ( |
1403 | sig.input[0].clone(), | 1403 | sig.input[0].clone(), |
1404 | sig.input[1..].iter().cloned().collect(), | 1404 | sig.input[1..].to_vec(), |
1405 | sig.output.clone(), | 1405 | sig.output.clone(), |
1406 | ) | 1406 | ) |
1407 | } else { | 1407 | } else { |
@@ -1411,7 +1411,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1411 | Ty::FnDef { substs, sig, .. } => { | 1411 | Ty::FnDef { substs, sig, .. } => { |
1412 | let ret_ty = sig.output.clone().subst(&substs); | 1412 | let ret_ty = sig.output.clone().subst(&substs); |
1413 | 1413 | ||
1414 | if sig.input.len() > 0 { | 1414 | if !sig.input.is_empty() { |
1415 | let mut arg_iter = sig.input.iter().map(|ty| ty.clone().subst(&substs)); | 1415 | let mut arg_iter = sig.input.iter().map(|ty| ty.clone().subst(&substs)); |
1416 | let receiver_ty = arg_iter.next().unwrap(); | 1416 | let receiver_ty = arg_iter.next().unwrap(); |
1417 | (receiver_ty, arg_iter.collect(), ret_ty) | 1417 | (receiver_ty, arg_iter.collect(), ret_ty) |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 2282286b0..a7d4517ee 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -113,7 +113,7 @@ impl CrateImplBlocks { | |||
113 | krate: Crate, | 113 | krate: Crate, |
114 | ) -> Arc<CrateImplBlocks> { | 114 | ) -> Arc<CrateImplBlocks> { |
115 | let mut crate_impl_blocks = CrateImplBlocks { | 115 | let mut crate_impl_blocks = CrateImplBlocks { |
116 | krate: krate.clone(), | 116 | krate, |
117 | impls: FxHashMap::default(), | 117 | impls: FxHashMap::default(), |
118 | impls_by_trait: FxHashMap::default(), | 118 | impls_by_trait: FxHashMap::default(), |
119 | }; | 119 | }; |
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index 5d1851da6..8abab0221 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs | |||
@@ -130,12 +130,9 @@ impl<'a> CompletionContext<'a> { | |||
130 | .ancestors() | 130 | .ancestors() |
131 | .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) | 131 | .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) |
132 | .find_map(ast::FnDef::cast); | 132 | .find_map(ast::FnDef::cast); |
133 | match (self.module, self.function_syntax) { | 133 | if let (Some(module), Some(fn_def)) = (self.module, self.function_syntax) { |
134 | (Some(module), Some(fn_def)) => { | 134 | let function = source_binder::function_from_module(self.db, module, fn_def); |
135 | let function = source_binder::function_from_module(self.db, module, fn_def); | 135 | self.function = Some(function); |
136 | self.function = Some(function); | ||
137 | } | ||
138 | _ => (), | ||
139 | } | 136 | } |
140 | 137 | ||
141 | let parent = match name_ref.syntax().parent() { | 138 | let parent = match name_ref.syntax().parent() { |
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index bada6a33b..92e6e78bf 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -108,11 +108,11 @@ impl CompletionItem { | |||
108 | self.lookup | 108 | self.lookup |
109 | .as_ref() | 109 | .as_ref() |
110 | .map(|it| it.as_str()) | 110 | .map(|it| it.as_str()) |
111 | .unwrap_or(self.label()) | 111 | .unwrap_or_else(|| self.label()) |
112 | } | 112 | } |
113 | 113 | ||
114 | pub fn insert_text_format(&self) -> InsertTextFormat { | 114 | pub fn insert_text_format(&self) -> InsertTextFormat { |
115 | self.insert_text_format.clone() | 115 | self.insert_text_format |
116 | } | 116 | } |
117 | pub fn insert_text(&self) -> String { | 117 | pub fn insert_text(&self) -> String { |
118 | match &self.insert_text { | 118 | match &self.insert_text { |
@@ -217,7 +217,7 @@ impl Builder { | |||
217 | let def = resolution | 217 | let def = resolution |
218 | .as_ref() | 218 | .as_ref() |
219 | .take_types() | 219 | .take_types() |
220 | .or(resolution.as_ref().take_values()); | 220 | .or_else(|| resolution.as_ref().take_values()); |
221 | let def = match def { | 221 | let def = match def { |
222 | None => return self, | 222 | None => return self, |
223 | Some(it) => it, | 223 | Some(it) => it, |
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 88efcea2a..681f36623 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -89,7 +89,11 @@ pub(crate) fn reference_definition( | |||
89 | .and_then(hir::Path::from_ast) | 89 | .and_then(hir::Path::from_ast) |
90 | { | 90 | { |
91 | let resolved = resolver.resolve_path(db, &path); | 91 | let resolved = resolver.resolve_path(db, &path); |
92 | match resolved.clone().take_types().or(resolved.take_values()) { | 92 | match resolved |
93 | .clone() | ||
94 | .take_types() | ||
95 | .or_else(|| resolved.take_values()) | ||
96 | { | ||
93 | Some(Resolution::Def(def)) => return Exact(NavigationTarget::from_def(db, def)), | 97 | Some(Resolution::Def(def)) => return Exact(NavigationTarget::from_def(db, def)), |
94 | Some(Resolution::LocalBinding(pat)) => { | 98 | Some(Resolution::LocalBinding(pat)) => { |
95 | let body = resolver.body().expect("no body for local binding"); | 99 | let body = resolver.body().expect("no body for local binding"); |
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 8beaba5de..68d59aae1 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -117,7 +117,7 @@ impl fmt::Debug for AnalysisChange { | |||
117 | if !self.libraries_added.is_empty() { | 117 | if !self.libraries_added.is_empty() { |
118 | d.field("libraries_added", &self.libraries_added.len()); | 118 | d.field("libraries_added", &self.libraries_added.len()); |
119 | } | 119 | } |
120 | if !self.crate_graph.is_some() { | 120 | if self.crate_graph.is_none() { |
121 | d.field("crate_graph", &self.crate_graph); | 121 | d.field("crate_graph", &self.crate_graph); |
122 | } | 122 | } |
123 | d.finish() | 123 | d.finish() |
diff --git a/crates/ra_ide_api/src/rename.rs b/crates/ra_ide_api/src/rename.rs index db5ccf969..1c9491a0a 100644 --- a/crates/ra_ide_api/src/rename.rs +++ b/crates/ra_ide_api/src/rename.rs | |||
@@ -95,12 +95,12 @@ fn rename_mod( | |||
95 | }; | 95 | }; |
96 | source_file_edits.push(edit); | 96 | source_file_edits.push(edit); |
97 | 97 | ||
98 | return Some(SourceChange { | 98 | Some(SourceChange { |
99 | label: "rename".to_string(), | 99 | label: "rename".to_string(), |
100 | source_file_edits, | 100 | source_file_edits, |
101 | file_system_edits, | 101 | file_system_edits, |
102 | cursor_position: None, | 102 | cursor_position: None, |
103 | }); | 103 | }) |
104 | } | 104 | } |
105 | 105 | ||
106 | fn rename_reference( | 106 | fn rename_reference( |
@@ -124,12 +124,12 @@ fn rename_reference( | |||
124 | return None; | 124 | return None; |
125 | } | 125 | } |
126 | 126 | ||
127 | return Some(SourceChange { | 127 | Some(SourceChange { |
128 | label: "rename".to_string(), | 128 | label: "rename".to_string(), |
129 | source_file_edits: edit, | 129 | source_file_edits: edit, |
130 | file_system_edits: Vec::new(), | 130 | file_system_edits: Vec::new(), |
131 | cursor_position: None, | 131 | cursor_position: None, |
132 | }); | 132 | }) |
133 | } | 133 | } |
134 | 134 | ||
135 | #[cfg(test)] | 135 | #[cfg(test)] |
diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs index 72c93f530..9f939c650 100644 --- a/crates/ra_ide_api/src/symbol_index.rs +++ b/crates/ra_ide_api/src/symbol_index.rs | |||
@@ -137,7 +137,7 @@ impl SymbolIndex { | |||
137 | symbols.par_sort_by(cmp); | 137 | symbols.par_sort_by(cmp); |
138 | symbols.dedup_by(|s1, s2| cmp(s1, s2) == Ordering::Equal); | 138 | symbols.dedup_by(|s1, s2| cmp(s1, s2) == Ordering::Equal); |
139 | let names = symbols.iter().map(|it| it.name.as_str().to_lowercase()); | 139 | let names = symbols.iter().map(|it| it.name.as_str().to_lowercase()); |
140 | let map = fst::Map::from_iter(names.into_iter().zip(0u64..)).unwrap(); | 140 | let map = fst::Map::from_iter(names.zip(0u64..)).unwrap(); |
141 | SymbolIndex { symbols, map } | 141 | SymbolIndex { symbols, map } |
142 | } | 142 | } |
143 | 143 | ||
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 17fa07340..981385466 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs | |||
@@ -169,10 +169,7 @@ impl ConvWith for TextEdit { | |||
169 | type Output = Vec<lsp_types::TextEdit>; | 169 | type Output = Vec<lsp_types::TextEdit>; |
170 | 170 | ||
171 | fn conv_with(self, line_index: &LineIndex) -> Vec<lsp_types::TextEdit> { | 171 | fn conv_with(self, line_index: &LineIndex) -> Vec<lsp_types::TextEdit> { |
172 | self.as_atoms() | 172 | self.as_atoms().iter().map_conv_with(line_index).collect() |
173 | .into_iter() | ||
174 | .map_conv_with(line_index) | ||
175 | .collect() | ||
176 | } | 173 | } |
177 | } | 174 | } |
178 | 175 | ||
@@ -394,7 +391,7 @@ pub fn to_location_link( | |||
394 | origin_selection_range: Some(target.range.conv_with(line_index)), | 391 | origin_selection_range: Some(target.range.conv_with(line_index)), |
395 | target_uri, | 392 | target_uri, |
396 | target_range, | 393 | target_range, |
397 | target_selection_range: target_selection_range, | 394 | target_selection_range, |
398 | }; | 395 | }; |
399 | Ok(res) | 396 | Ok(res) |
400 | } | 397 | } |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index ab2b81bf0..aa55d1255 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -123,7 +123,7 @@ pub fn handle_on_type_formatting( | |||
123 | let edit = edit.source_file_edits.pop().unwrap(); | 123 | let edit = edit.source_file_edits.pop().unwrap(); |
124 | 124 | ||
125 | let change: Vec<TextEdit> = edit.edit.conv_with(&line_index); | 125 | let change: Vec<TextEdit> = edit.edit.conv_with(&line_index); |
126 | return Ok(Some(change)); | 126 | Ok(Some(change)) |
127 | } | 127 | } |
128 | 128 | ||
129 | pub fn handle_document_symbol( | 129 | pub fn handle_document_symbol( |
@@ -319,7 +319,7 @@ pub fn handle_runnables( | |||
319 | args: check_args, | 319 | args: check_args, |
320 | env: FxHashMap::default(), | 320 | env: FxHashMap::default(), |
321 | }); | 321 | }); |
322 | return Ok(res); | 322 | Ok(res) |
323 | } | 323 | } |
324 | 324 | ||
325 | pub fn handle_decorations( | 325 | pub fn handle_decorations( |
@@ -622,10 +622,8 @@ pub fn handle_code_lens( | |||
622 | // Gather runnables | 622 | // Gather runnables |
623 | for runnable in world.analysis().runnables(file_id)? { | 623 | for runnable in world.analysis().runnables(file_id)? { |
624 | let title = match &runnable.kind { | 624 | let title = match &runnable.kind { |
625 | RunnableKind::Test { name: _ } | RunnableKind::TestMod { path: _ } => { | 625 | RunnableKind::Test { .. } | RunnableKind::TestMod { .. } => Some("▶️Run Test"), |
626 | Some("▶️Run Test") | 626 | RunnableKind::Bench { .. } => Some("Run Bench"), |
627 | } | ||
628 | RunnableKind::Bench { name: _ } => Some("Run Bench"), | ||
629 | _ => None, | 627 | _ => None, |
630 | }; | 628 | }; |
631 | 629 | ||
@@ -679,7 +677,7 @@ pub fn handle_code_lens( | |||
679 | }), | 677 | }), |
680 | ); | 678 | ); |
681 | 679 | ||
682 | return Ok(Some(lenses)); | 680 | Ok(Some(lenses)) |
683 | } | 681 | } |
684 | 682 | ||
685 | #[derive(Debug, Serialize, Deserialize)] | 683 | #[derive(Debug, Serialize, Deserialize)] |
@@ -722,22 +720,20 @@ pub fn handle_code_lens_resolve(world: ServerWorld, code_lens: CodeLens) -> Resu | |||
722 | to_value(locations).unwrap(), | 720 | to_value(locations).unwrap(), |
723 | ]), | 721 | ]), |
724 | }; | 722 | }; |
725 | return Ok(CodeLens { | 723 | Ok(CodeLens { |
726 | range: code_lens.range, | 724 | range: code_lens.range, |
727 | command: Some(cmd), | 725 | command: Some(cmd), |
728 | data: None, | 726 | data: None, |
729 | }); | 727 | }) |
730 | } | ||
731 | None => { | ||
732 | return Ok(CodeLens { | ||
733 | range: code_lens.range, | ||
734 | command: Some(Command { | ||
735 | title: "Error".into(), | ||
736 | ..Default::default() | ||
737 | }), | ||
738 | data: None, | ||
739 | }); | ||
740 | } | 728 | } |
729 | None => Ok(CodeLens { | ||
730 | range: code_lens.range, | ||
731 | command: Some(Command { | ||
732 | title: "Error".into(), | ||
733 | ..Default::default() | ||
734 | }), | ||
735 | data: None, | ||
736 | }), | ||
741 | } | 737 | } |
742 | } | 738 | } |
743 | 739 | ||