aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-10-30 17:39:18 +0000
committerGitHub <[email protected]>2019-10-30 17:39:18 +0000
commiteee55d4663084a01ce80f5ee201d8e1e345417cd (patch)
tree7fc1497065d00cfba1cd00523ed9545886745da1 /crates
parentd929f9c49bceb3b7c32ea45c5e55c42f168bbf34 (diff)
parentb441b4e8effeaf4532fd2e45c4d864480857c49e (diff)
Merge #2129
2129: Some clippy fixes r=kjeremy a=kjeremy Co-authored-by: kjeremy <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/assists/early_return.rs2
-rw-r--r--crates/ra_assists/src/assists/inline_local_variable.rs6
-rw-r--r--crates/ra_assists/src/assists/raw_string.rs2
-rw-r--r--crates/ra_ide_api/src/call_info.rs2
-rw-r--r--crates/ra_ide_api/src/change.rs2
-rw-r--r--crates/ra_ide_api/src/completion/complete_path.rs2
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs4
-rw-r--r--crates/ra_ide_api/src/references/search_scope.rs5
-rw-r--r--crates/ra_ide_api/src/typing.rs2
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs2
-rw-r--r--crates/ra_mbe/src/mbe_expander/matcher.rs3
-rw-r--r--crates/ra_mbe/src/syntax_bridge.rs2
-rw-r--r--crates/ra_syntax/src/ast/make.rs4
13 files changed, 17 insertions, 21 deletions
diff --git a/crates/ra_assists/src/assists/early_return.rs b/crates/ra_assists/src/assists/early_return.rs
index e839d831e..ad6c5695a 100644
--- a/crates/ra_assists/src/assists/early_return.rs
+++ b/crates/ra_assists/src/assists/early_return.rs
@@ -50,7 +50,7 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Opt
50 } 50 }
51 51
52 // check for early return and continue 52 // check for early return and continue
53 let first_in_then_block = then_block.syntax().first_child()?.clone(); 53 let first_in_then_block = then_block.syntax().first_child()?;
54 if ast::ReturnExpr::can_cast(first_in_then_block.kind()) 54 if ast::ReturnExpr::can_cast(first_in_then_block.kind())
55 || ast::ContinueExpr::can_cast(first_in_then_block.kind()) 55 || ast::ContinueExpr::can_cast(first_in_then_block.kind())
56 || first_in_then_block 56 || first_in_then_block
diff --git a/crates/ra_assists/src/assists/inline_local_variable.rs b/crates/ra_assists/src/assists/inline_local_variable.rs
index f43910574..a7fd9b6d2 100644
--- a/crates/ra_assists/src/assists/inline_local_variable.rs
+++ b/crates/ra_assists/src/assists/inline_local_variable.rs
@@ -51,10 +51,8 @@ pub(crate) fn inline_local_varialbe(ctx: AssistCtx<impl HirDatabase>) -> Option<
51 let mut wrap_in_parens = vec![true; refs.len()]; 51 let mut wrap_in_parens = vec![true; refs.len()];
52 52
53 for (i, desc) in refs.iter().enumerate() { 53 for (i, desc) in refs.iter().enumerate() {
54 let usage_node = ctx 54 let usage_node =
55 .covering_node_for_range(desc.range) 55 ctx.covering_node_for_range(desc.range).ancestors().find_map(ast::PathExpr::cast)?;
56 .ancestors()
57 .find_map(|node| ast::PathExpr::cast(node))?;
58 let usage_parent_option = usage_node.syntax().parent().and_then(ast::Expr::cast); 56 let usage_parent_option = usage_node.syntax().parent().and_then(ast::Expr::cast);
59 let usage_parent = match usage_parent_option { 57 let usage_parent = match usage_parent_option {
60 Some(u) => u, 58 Some(u) => u,
diff --git a/crates/ra_assists/src/assists/raw_string.rs b/crates/ra_assists/src/assists/raw_string.rs
index 6f4b66c31..58f7157ae 100644
--- a/crates/ra_assists/src/assists/raw_string.rs
+++ b/crates/ra_assists/src/assists/raw_string.rs
@@ -131,7 +131,7 @@ pub(crate) fn remove_hash(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
131 ctx.add_assist(AssistId("remove_hash"), "remove hash from raw string", |edit| { 131 ctx.add_assist(AssistId("remove_hash"), "remove hash from raw string", |edit| {
132 edit.target(token.text_range()); 132 edit.target(token.text_range());
133 let result = &text[2..text.len() - 1]; 133 let result = &text[2..text.len() - 1];
134 let result = if result.starts_with("\"") { 134 let result = if result.starts_with('\"') {
135 // no more hash, escape 135 // no more hash, escape
136 let internal_str = &result[1..result.len() - 1]; 136 let internal_str = &result[1..result.len() - 1];
137 format!("\"{}\"", internal_str.escape_default().to_string()) 137 format!("\"{}\"", internal_str.escape_default().to_string())
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs
index 175af3fd9..e494f5620 100644
--- a/crates/ra_ide_api/src/call_info.rs
+++ b/crates/ra_ide_api/src/call_info.rs
@@ -95,7 +95,7 @@ impl FnCallNode {
95 Some(FnCallNode::CallExpr(expr)) 95 Some(FnCallNode::CallExpr(expr))
96 } else if let Some(expr) = ast::MethodCallExpr::cast(node.clone()) { 96 } else if let Some(expr) = ast::MethodCallExpr::cast(node.clone()) {
97 Some(FnCallNode::MethodCallExpr(expr)) 97 Some(FnCallNode::MethodCallExpr(expr))
98 } else if let Some(expr) = ast::MacroCall::cast(node.clone()) { 98 } else if let Some(expr) = ast::MacroCall::cast(node) {
99 Some(FnCallNode::MacroCallExpr(expr)) 99 Some(FnCallNode::MacroCallExpr(expr))
100 } else { 100 } else {
101 None 101 None
diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs
index 050249c0e..39c5946c7 100644
--- a/crates/ra_ide_api/src/change.rs
+++ b/crates/ra_ide_api/src/change.rs
@@ -43,7 +43,7 @@ impl fmt::Debug for AnalysisChange {
43 if !self.libraries_added.is_empty() { 43 if !self.libraries_added.is_empty() {
44 d.field("libraries_added", &self.libraries_added.len()); 44 d.field("libraries_added", &self.libraries_added.len());
45 } 45 }
46 if !self.crate_graph.is_some() { 46 if !self.crate_graph.is_none() {
47 d.field("crate_graph", &self.crate_graph); 47 d.field("crate_graph", &self.crate_graph);
48 } 48 }
49 d.finish() 49 d.finish()
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index 956d8ce49..a58fdc036 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -67,7 +67,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
67 }); 67 });
68 } 68 }
69 } 69 }
70 _ => return, 70 _ => {}
71 }; 71 };
72} 72}
73 73
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs
index f7e98e6df..65bb639ed 100644
--- a/crates/ra_ide_api/src/completion/presentation.rs
+++ b/crates/ra_ide_api/src/completion/presentation.rs
@@ -136,7 +136,7 @@ impl Completions {
136 for (idx, s) in docs.match_indices(&macro_name) { 136 for (idx, s) in docs.match_indices(&macro_name) {
137 let (before, after) = (&docs[..idx], &docs[idx + s.len()..]); 137 let (before, after) = (&docs[..idx], &docs[idx + s.len()..]);
138 // Ensure to match the full word 138 // Ensure to match the full word
139 if after.starts_with("!") 139 if after.starts_with('!')
140 && before 140 && before
141 .chars() 141 .chars()
142 .rev() 142 .rev()
@@ -225,7 +225,7 @@ impl Completions {
225 } else { 225 } else {
226 (format!("{}($0)", data.name()), format!("{}(…)", name)) 226 (format!("{}($0)", data.name()), format!("{}(…)", name))
227 }; 227 };
228 builder = builder.lookup_by(name.clone()).label(label).insert_snippet(snippet); 228 builder = builder.lookup_by(name).label(label).insert_snippet(snippet);
229 } 229 }
230 230
231 self.add(builder) 231 self.add(builder)
diff --git a/crates/ra_ide_api/src/references/search_scope.rs b/crates/ra_ide_api/src/references/search_scope.rs
index dbd1af597..f2789e0b2 100644
--- a/crates/ra_ide_api/src/references/search_scope.rs
+++ b/crates/ra_ide_api/src/references/search_scope.rs
@@ -111,8 +111,7 @@ impl NameDefinition {
111 if vis.as_str() != "" { 111 if vis.as_str() != "" {
112 let source_root_id = db.file_source_root(file_id); 112 let source_root_id = db.file_source_root(file_id);
113 let source_root = db.source_root(source_root_id); 113 let source_root = db.source_root(source_root_id);
114 let mut res = 114 let mut res = source_root.walk().map(|id| (id, None)).collect::<FxHashMap<_, _>>();
115 source_root.walk().map(|id| (id.into(), None)).collect::<FxHashMap<_, _>>();
116 115
117 // FIXME: add "pub(in path)" 116 // FIXME: add "pub(in path)"
118 117
@@ -128,7 +127,7 @@ impl NameDefinition {
128 let root_file = crate_graph.crate_root(crate_id); 127 let root_file = crate_graph.crate_root(crate_id);
129 let source_root_id = db.file_source_root(root_file); 128 let source_root_id = db.file_source_root(root_file);
130 let source_root = db.source_root(source_root_id); 129 let source_root = db.source_root(source_root_id);
131 res.extend(source_root.walk().map(|id| (id.into(), None))); 130 res.extend(source_root.walk().map(|id| (id, None)));
132 } 131 }
133 } 132 }
134 return SearchScope::new(res); 133 return SearchScope::new(res);
diff --git a/crates/ra_ide_api/src/typing.rs b/crates/ra_ide_api/src/typing.rs
index 2dfbe6944..d51132f73 100644
--- a/crates/ra_ide_api/src/typing.rs
+++ b/crates/ra_ide_api/src/typing.rs
@@ -261,7 +261,7 @@ impl S {
261 261
262 fn type_char(char_typed: char, before: &str, after: &str) { 262 fn type_char(char_typed: char, before: &str, after: &str) {
263 let (actual, file_change) = do_type_char(char_typed, before) 263 let (actual, file_change) = do_type_char(char_typed, before)
264 .expect(&format!("typing `{}` did nothing", char_typed)); 264 .unwrap_or_else(|| panic!("typing `{}` did nothing", char_typed));
265 265
266 if after.contains("<|>") { 266 if after.contains("<|>") {
267 let (offset, after) = extract_offset(after); 267 let (offset, after) = extract_offset(after);
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 1a87706fe..379dab438 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -196,7 +196,7 @@ pub fn main_loop(
196 task_receiver.into_iter().for_each(|task| { 196 task_receiver.into_iter().for_each(|task| {
197 on_task(task, &connection.sender, &mut loop_state.pending_requests, &mut world_state) 197 on_task(task, &connection.sender, &mut loop_state.pending_requests, &mut world_state)
198 }); 198 });
199 libdata_receiver.into_iter().for_each(|lib| drop(lib)); 199 libdata_receiver.into_iter().for_each(drop);
200 log::info!("...tasks have finished"); 200 log::info!("...tasks have finished");
201 log::info!("joining threadpool..."); 201 log::info!("joining threadpool...");
202 drop(pool); 202 drop(pool);
diff --git a/crates/ra_mbe/src/mbe_expander/matcher.rs b/crates/ra_mbe/src/mbe_expander/matcher.rs
index 0548e8512..33b9d483d 100644
--- a/crates/ra_mbe/src/mbe_expander/matcher.rs
+++ b/crates/ra_mbe/src/mbe_expander/matcher.rs
@@ -123,7 +123,6 @@ fn match_subtree(
123 } 123 }
124 None => bindings.push_optional(name), 124 None => bindings.push_optional(name),
125 } 125 }
126 ()
127 } 126 }
128 Op::Repeat { subtree, kind, separator } => { 127 Op::Repeat { subtree, kind, separator } => {
129 match_repeat(bindings, subtree, kind, separator, src)? 128 match_repeat(bindings, subtree, kind, separator, src)?
@@ -159,7 +158,7 @@ impl<'a> TtIter<'a> {
159 pub(crate) fn expect_lifetime(&mut self) -> Result<&tt::Ident, ()> { 158 pub(crate) fn expect_lifetime(&mut self) -> Result<&tt::Ident, ()> {
160 let ident = self.expect_ident()?; 159 let ident = self.expect_ident()?;
161 // check if it start from "`" 160 // check if it start from "`"
162 if ident.text.chars().next() != Some('\'') { 161 if !ident.text.starts_with('\'') {
163 return Err(()); 162 return Err(());
164 } 163 }
165 Ok(ident) 164 Ok(ident)
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs
index 1b543c84b..592fcf527 100644
--- a/crates/ra_mbe/src/syntax_bridge.rs
+++ b/crates/ra_mbe/src/syntax_bridge.rs
@@ -383,7 +383,7 @@ mod tests {
383 "#, 383 "#,
384 ); 384 );
385 let expansion = expand(&rules, "literals!(foo);"); 385 let expansion = expand(&rules, "literals!(foo);");
386 let tts = &[expansion.clone().into()]; 386 let tts = &[expansion.into()];
387 let buffer = tt::buffer::TokenBuffer::new(tts); 387 let buffer = tt::buffer::TokenBuffer::new(tts);
388 let mut tt_src = SubtreeTokenSource::new(&buffer); 388 let mut tt_src = SubtreeTokenSource::new(&buffer);
389 let mut tokens = vec![]; 389 let mut tokens = vec![];
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 76dad9155..3d5f18bfa 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -129,11 +129,11 @@ pub fn where_clause(preds: impl Iterator<Item = ast::WherePred>) -> ast::WhereCl
129} 129}
130 130
131pub fn if_expression(condition: &ast::Expr, statement: &str) -> ast::IfExpr { 131pub fn if_expression(condition: &ast::Expr, statement: &str) -> ast::IfExpr {
132 return ast_from_text(&format!( 132 ast_from_text(&format!(
133 "fn f() {{ if !{} {{\n {}\n}}\n}}", 133 "fn f() {{ if !{} {{\n {}\n}}\n}}",
134 condition.syntax().text(), 134 condition.syntax().text(),
135 statement 135 statement
136 )); 136 ))
137} 137}
138 138
139fn ast_from_text<N: AstNode>(text: &str) -> N { 139fn ast_from_text<N: AstNode>(text: &str) -> N {