aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Kolb <[email protected]>2019-07-04 18:26:44 +0100
committerJeremy Kolb <[email protected]>2019-07-04 22:43:00 +0100
commit4ad9e986ad05e404df73701c098b71f73a847ca6 (patch)
tree2a2b2cc9dbee07d0aa92df883c807edbab264a85
parentc6a6e43372de9530ec7df0f38352466ed107e1a2 (diff)
Some clippy fixes for 1.36
-rw-r--r--crates/gen_lsp_server/src/lib.rs2
-rw-r--r--crates/ra_assists/src/auto_import.rs12
-rw-r--r--crates/ra_cli/src/main.rs2
-rw-r--r--crates/ra_db/src/input.rs4
-rw-r--r--crates/ra_hir/src/code_model/docs.rs2
-rw-r--r--crates/ra_hir/src/expr.rs8
-rw-r--r--crates/ra_hir/src/expr/scope.rs2
-rw-r--r--crates/ra_hir/src/lang_item.rs4
-rw-r--r--crates/ra_hir/src/mock.rs2
-rw-r--r--crates/ra_hir/src/nameres/collector.rs14
-rw-r--r--crates/ra_hir/src/resolve.rs4
-rw-r--r--crates/ra_hir/src/ty/infer.rs14
-rw-r--r--crates/ra_hir/src/ty/infer/unify.rs4
-rw-r--r--crates/ra_ide_api/src/db.rs4
-rw-r--r--crates/ra_ide_api/src/display/structure.rs2
-rw-r--r--crates/ra_ide_api/src/line_index_utils.rs5
-rw-r--r--crates/ra_ide_api/src/symbol_index.rs2
-rw-r--r--crates/ra_lsp_server/src/conv.rs2
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs7
-rw-r--r--crates/ra_mbe/src/mbe_expander.rs2
-rw-r--r--crates/ra_mbe/src/mbe_parser.rs2
-rw-r--r--crates/ra_mbe/src/subtree_source.rs2
-rw-r--r--crates/ra_mbe/src/syntax_bridge.rs2
-rw-r--r--crates/ra_mbe/src/tt_cursor.rs12
-rw-r--r--crates/ra_project_model/src/lib.rs2
-rw-r--r--crates/ra_project_model/src/sysroot.rs2
-rw-r--r--crates/ra_syntax/src/ast/expr_extensions.rs2
-rw-r--r--crates/ra_syntax/src/fuzz.rs4
-rw-r--r--crates/ra_syntax/src/parsing/text_token_source.rs2
-rw-r--r--crates/ra_syntax/src/syntax_node.rs2
-rw-r--r--crates/ra_syntax/src/validation/unescape.rs2
31 files changed, 62 insertions, 70 deletions
diff --git a/crates/gen_lsp_server/src/lib.rs b/crates/gen_lsp_server/src/lib.rs
index 7ecef83cb..0984e3e25 100644
--- a/crates/gen_lsp_server/src/lib.rs
+++ b/crates/gen_lsp_server/src/lib.rs
@@ -130,7 +130,7 @@ fn initialize(
130 Ok(RawMessage::Notification(n)) => { 130 Ok(RawMessage::Notification(n)) => {
131 n.cast::<Initialized>().map_err(|_| "expected initialized notification")?; 131 n.cast::<Initialized>().map_err(|_| "expected initialized notification")?;
132 } 132 }
133 _ => Err(format!("expected initialized notification"))?, 133 _ => Err("expected initialized notification".to_string())?,
134 } 134 }
135 Ok(params) 135 Ok(params)
136} 136}
diff --git a/crates/ra_assists/src/auto_import.rs b/crates/ra_assists/src/auto_import.rs
index 75ab8fa0f..f8f37e852 100644
--- a/crates/ra_assists/src/auto_import.rs
+++ b/crates/ra_assists/src/auto_import.rs
@@ -39,13 +39,13 @@ fn collect_path_segments_raw<'a>(
39 // We need to reverse only the new added segments 39 // We need to reverse only the new added segments
40 let only_new_segments = segments.split_at_mut(oldlen).1; 40 let only_new_segments = segments.split_at_mut(oldlen).1;
41 only_new_segments.reverse(); 41 only_new_segments.reverse();
42 return Some(segments.len() - oldlen); 42 Some(segments.len() - oldlen)
43} 43}
44 44
45fn fmt_segments(segments: &[SmolStr]) -> String { 45fn fmt_segments(segments: &[SmolStr]) -> String {
46 let mut buf = String::new(); 46 let mut buf = String::new();
47 fmt_segments_raw(segments, &mut buf); 47 fmt_segments_raw(segments, &mut buf);
48 return buf; 48 buf
49} 49}
50 50
51fn fmt_segments_raw(segments: &[SmolStr], buf: &mut String) { 51fn fmt_segments_raw(segments: &[SmolStr], buf: &mut String) {
@@ -61,7 +61,7 @@ fn fmt_segments_raw(segments: &[SmolStr], buf: &mut String) {
61 61
62// Returns the numeber of common segments. 62// Returns the numeber of common segments.
63fn compare_path_segments(left: &[SmolStr], right: &[&ast::PathSegment]) -> usize { 63fn compare_path_segments(left: &[SmolStr], right: &[&ast::PathSegment]) -> usize {
64 return left.iter().zip(right).filter(|(l, r)| compare_path_segment(l, r)).count(); 64 left.iter().zip(right).filter(|(l, r)| compare_path_segment(l, r)).count()
65} 65}
66 66
67fn compare_path_segment(a: &SmolStr, b: &ast::PathSegment) -> bool { 67fn compare_path_segment(a: &SmolStr, b: &ast::PathSegment) -> bool {
@@ -320,7 +320,7 @@ fn walk_use_tree_for_best_action<'a>(
320 320
321 // We remove the segments added 321 // We remove the segments added
322 current_path_segments.truncate(prev_len); 322 current_path_segments.truncate(prev_len);
323 return action; 323 action
324} 324}
325 325
326fn best_action_for_target<'b, 'a: 'b>( 326fn best_action_for_target<'b, 'a: 'b>(
@@ -339,7 +339,7 @@ fn best_action_for_target<'b, 'a: 'b>(
339 }); 339 });
340 340
341 match best_action { 341 match best_action {
342 Some(action) => return action, 342 Some(action) => action,
343 None => { 343 None => {
344 // We have no action and no UseItem was found in container so we find 344 // We have no action and no UseItem was found in container so we find
345 // another item and we use it as anchor. 345 // another item and we use it as anchor.
@@ -350,7 +350,7 @@ fn best_action_for_target<'b, 'a: 'b>(
350 .find(|n| n.range().start() < anchor.range().start()) 350 .find(|n| n.range().start() < anchor.range().start())
351 .or_else(|| Some(anchor)); 351 .or_else(|| Some(anchor));
352 352
353 return ImportAction::add_new_use(anchor, false); 353 ImportAction::add_new_use(anchor, false)
354 } 354 }
355 } 355 }
356} 356}
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs
index 25edbd5f7..48bc64450 100644
--- a/crates/ra_cli/src/main.rs
+++ b/crates/ra_cli/src/main.rs
@@ -112,6 +112,6 @@ fn read_stdin() -> Result<String> {
112} 112}
113 113
114fn rsplit_at_char(s: &str, c: char) -> Result<(&str, &str)> { 114fn rsplit_at_char(s: &str, c: char) -> Result<(&str, &str)> {
115 let idx = s.rfind(":").ok_or_else(|| format!("no `{}` in {}", c, s))?; 115 let idx = s.rfind(':').ok_or_else(|| format!("no `{}` in {}", c, s))?;
116 Ok((&s[..idx], &s[idx + 1..])) 116 Ok((&s[..idx], &s[idx + 1..]))
117} 117}
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index 5d3a6b3c9..2d563bd01 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -139,7 +139,7 @@ impl CrateGraph {
139 } 139 }
140 140
141 pub fn iter<'a>(&'a self) -> impl Iterator<Item = CrateId> + 'a { 141 pub fn iter<'a>(&'a self) -> impl Iterator<Item = CrateId> + 'a {
142 self.arena.keys().map(|it| *it) 142 self.arena.keys().copied()
143 } 143 }
144 144
145 pub fn crate_root(&self, crate_id: CrateId) -> FileId { 145 pub fn crate_root(&self, crate_id: CrateId) -> FileId {
@@ -191,7 +191,7 @@ impl CrateGraph {
191 return true; 191 return true;
192 } 192 }
193 } 193 }
194 return false; 194 false
195 } 195 }
196} 196}
197 197
diff --git a/crates/ra_hir/src/code_model/docs.rs b/crates/ra_hir/src/code_model/docs.rs
index f696307a7..007ef315d 100644
--- a/crates/ra_hir/src/code_model/docs.rs
+++ b/crates/ra_hir/src/code_model/docs.rs
@@ -74,7 +74,7 @@ pub(crate) fn documentation_query(
74 DocDef::Module(it) => docs_from_ast(&*it.declaration_source(db)?.ast), 74 DocDef::Module(it) => docs_from_ast(&*it.declaration_source(db)?.ast),
75 DocDef::StructField(it) => match it.source(db).ast { 75 DocDef::StructField(it) => match it.source(db).ast {
76 FieldSource::Named(named) => docs_from_ast(&*named), 76 FieldSource::Named(named) => docs_from_ast(&*named),
77 FieldSource::Pos(..) => return None, 77 FieldSource::Pos(..) => None,
78 }, 78 },
79 DocDef::Struct(it) => docs_from_ast(&*it.source(db).ast), 79 DocDef::Struct(it) => docs_from_ast(&*it.source(db).ast),
80 DocDef::Enum(it) => docs_from_ast(&*it.source(db).ast), 80 DocDef::Enum(it) => docs_from_ast(&*it.source(db).ast),
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index d5b4ba6b6..3e763fef0 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -150,7 +150,7 @@ impl BodySourceMap {
150 } 150 }
151 151
152 pub(crate) fn field_syntax(&self, expr: ExprId, field: usize) -> AstPtr<ast::NamedField> { 152 pub(crate) fn field_syntax(&self, expr: ExprId, field: usize) -> AstPtr<ast::NamedField> {
153 self.field_map[&(expr, field)].clone() 153 self.field_map[&(expr, field)]
154 } 154 }
155} 155}
156 156
@@ -471,15 +471,15 @@ impl Pat {
471 match self { 471 match self {
472 Pat::Range { .. } | Pat::Lit(..) | Pat::Path(..) | Pat::Wild | Pat::Missing => {} 472 Pat::Range { .. } | Pat::Lit(..) | Pat::Path(..) | Pat::Wild | Pat::Missing => {}
473 Pat::Bind { subpat, .. } => { 473 Pat::Bind { subpat, .. } => {
474 subpat.iter().map(|pat| *pat).for_each(f); 474 subpat.iter().copied().for_each(f);
475 } 475 }
476 Pat::Tuple(args) | Pat::TupleStruct { args, .. } => { 476 Pat::Tuple(args) | Pat::TupleStruct { args, .. } => {
477 args.iter().map(|pat| *pat).for_each(f); 477 args.iter().copied().for_each(f);
478 } 478 }
479 Pat::Ref { pat, .. } => f(*pat), 479 Pat::Ref { pat, .. } => f(*pat),
480 Pat::Slice { prefix, rest, suffix } => { 480 Pat::Slice { prefix, rest, suffix } => {
481 let total_iter = prefix.iter().chain(rest.iter()).chain(suffix.iter()); 481 let total_iter = prefix.iter().chain(rest.iter()).chain(suffix.iter());
482 total_iter.map(|pat| *pat).for_each(f); 482 total_iter.copied().for_each(f);
483 } 483 }
484 Pat::Struct { args, .. } => { 484 Pat::Struct { args, .. } => {
485 args.iter().map(|f| f.pat).for_each(f); 485 args.iter().map(|f| f.pat).for_each(f);
diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs
index f27cc6e8d..28fd52684 100644
--- a/crates/ra_hir/src/expr/scope.rs
+++ b/crates/ra_hir/src/expr/scope.rs
@@ -72,7 +72,7 @@ impl ExprScopes {
72 } 72 }
73 73
74 pub(crate) fn scope_for(&self, expr: ExprId) -> Option<ScopeId> { 74 pub(crate) fn scope_for(&self, expr: ExprId) -> Option<ScopeId> {
75 self.scope_by_expr.get(&expr).map(|&scope| scope) 75 self.scope_by_expr.get(&expr).copied()
76 } 76 }
77 77
78 pub(crate) fn scope_by_expr(&self) -> &FxHashMap<ExprId, ScopeId> { 78 pub(crate) fn scope_by_expr(&self) -> &FxHashMap<ExprId, ScopeId> {
diff --git a/crates/ra_hir/src/lang_item.rs b/crates/ra_hir/src/lang_item.rs
index f9fe47b0f..0443d4d9a 100644
--- a/crates/ra_hir/src/lang_item.rs
+++ b/crates/ra_hir/src/lang_item.rs
@@ -122,7 +122,7 @@ impl LangItems {
122 module: Module, 122 module: Module,
123 ) { 123 ) {
124 if let Some(module_lang_items) = db.module_lang_items(module) { 124 if let Some(module_lang_items) = db.module_lang_items(module) {
125 self.items.extend(module_lang_items.items.iter().map(|(k, v)| (k.clone(), v.clone()))) 125 self.items.extend(module_lang_items.items.iter().map(|(k, v)| (k.clone(), *v)))
126 } 126 }
127 127
128 // Look for lang items in the children 128 // Look for lang items in the children
@@ -142,7 +142,7 @@ impl LangItems {
142 { 142 {
143 let node = item.source(db).ast; 143 let node = item.source(db).ast;
144 if let Some(lang_item_name) = lang_item_name(&*node) { 144 if let Some(lang_item_name) = lang_item_name(&*node) {
145 self.items.entry(lang_item_name).or_insert(constructor(item)); 145 self.items.entry(lang_item_name).or_insert_with(|| constructor(item));
146 } 146 }
147 } 147 }
148} 148}
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index b26ea58c9..ba33273b8 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -76,7 +76,7 @@ impl MockDatabase {
76 76
77 pub fn diagnostics(&self) -> String { 77 pub fn diagnostics(&self) -> String {
78 let mut buf = String::from("\n"); 78 let mut buf = String::from("\n");
79 let mut files: Vec<FileId> = self.files.values().map(|&it| it).collect(); 79 let mut files: Vec<FileId> = self.files.values().copied().collect();
80 files.sort(); 80 files.sort();
81 for file in files { 81 for file in files {
82 let module = crate::source_binder::module_from_file_id(self, file).unwrap(); 82 let module = crate::source_binder::module_from_file_id(self, file).unwrap();
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs
index 2b07ebf4a..d66be34db 100644
--- a/crates/ra_hir/src/nameres/collector.rs
+++ b/crates/ra_hir/src/nameres/collector.rs
@@ -227,10 +227,8 @@ where
227 .items 227 .items
228 .iter() 228 .iter()
229 .map(|(name, res)| (name.clone(), Either::A(res.clone()))); 229 .map(|(name, res)| (name.clone(), Either::A(res.clone())));
230 let macros = scope 230 let macros =
231 .macros 231 scope.macros.iter().map(|(name, res)| (name.clone(), Either::B(*res)));
232 .iter()
233 .map(|(name, res)| (name.clone(), Either::B(res.clone())));
234 232
235 let all = items.chain(macros).collect::<Vec<_>>(); 233 let all = items.chain(macros).collect::<Vec<_>>();
236 self.update(module_id, Some(import_id), &all); 234 self.update(module_id, Some(import_id), &all);
@@ -243,10 +241,8 @@ where
243 .items 241 .items
244 .iter() 242 .iter()
245 .map(|(name, res)| (name.clone(), Either::A(res.clone()))); 243 .map(|(name, res)| (name.clone(), Either::A(res.clone())));
246 let macros = scope 244 let macros =
247 .macros 245 scope.macros.iter().map(|(name, res)| (name.clone(), Either::B(*res)));
248 .iter()
249 .map(|(name, res)| (name.clone(), Either::B(res.clone())));
250 246
251 let all = items.chain(macros).collect::<Vec<_>>(); 247 let all = items.chain(macros).collect::<Vec<_>>();
252 248
@@ -651,7 +647,7 @@ fn resolve_submodule(
651 candidates.push(file_dir_mod.clone()); 647 candidates.push(file_dir_mod.clone());
652 }; 648 };
653 let sr = db.source_root(source_root_id); 649 let sr = db.source_root(source_root_id);
654 let mut points_to = candidates.into_iter().filter_map(|path| sr.files.get(&path)).map(|&it| it); 650 let mut points_to = candidates.into_iter().filter_map(|path| sr.files.get(&path)).copied();
655 // FIXME: handle ambiguity 651 // FIXME: handle ambiguity
656 match points_to.next() { 652 match points_to.next() {
657 Some(file_id) => Ok(file_id), 653 Some(file_id) => Ok(file_id),
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index fc981e9b3..c8be27e54 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -272,7 +272,7 @@ impl Scope {
272 }, 272 },
273 Scope::ImplBlockScope(i) => { 273 Scope::ImplBlockScope(i) => {
274 if name.as_known_name() == Some(KnownName::SelfType) { 274 if name.as_known_name() == Some(KnownName::SelfType) {
275 PerNs::types(Resolution::SelfType(i.clone())) 275 PerNs::types(Resolution::SelfType(*i))
276 } else { 276 } else {
277 PerNs::none() 277 PerNs::none()
278 } 278 }
@@ -317,7 +317,7 @@ impl Scope {
317 } 317 }
318 } 318 }
319 Scope::ImplBlockScope(i) => { 319 Scope::ImplBlockScope(i) => {
320 f(Name::self_type(), PerNs::types(Resolution::SelfType(i.clone()))); 320 f(Name::self_type(), PerNs::types(Resolution::SelfType(*i)));
321 } 321 }
322 Scope::ExprScope(e) => { 322 Scope::ExprScope(e) => {
323 e.expr_scopes.entries(e.scope_id).iter().for_each(|e| { 323 e.expr_scopes.entries(e.scope_id).iter().for_each(|e| {
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index a2dc92370..9228dd314 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -116,16 +116,16 @@ pub struct InferenceResult {
116 116
117impl InferenceResult { 117impl InferenceResult {
118 pub fn method_resolution(&self, expr: ExprId) -> Option<Function> { 118 pub fn method_resolution(&self, expr: ExprId) -> Option<Function> {
119 self.method_resolutions.get(&expr).map(|it| *it) 119 self.method_resolutions.get(&expr).copied()
120 } 120 }
121 pub fn field_resolution(&self, expr: ExprId) -> Option<StructField> { 121 pub fn field_resolution(&self, expr: ExprId) -> Option<StructField> {
122 self.field_resolutions.get(&expr).map(|it| *it) 122 self.field_resolutions.get(&expr).copied()
123 } 123 }
124 pub fn assoc_resolutions_for_expr(&self, id: ExprId) -> Option<ImplItem> { 124 pub fn assoc_resolutions_for_expr(&self, id: ExprId) -> Option<ImplItem> {
125 self.assoc_resolutions.get(&id.into()).map(|it| *it) 125 self.assoc_resolutions.get(&id.into()).copied()
126 } 126 }
127 pub fn assoc_resolutions_for_pat(&self, id: PatId) -> Option<ImplItem> { 127 pub fn assoc_resolutions_for_pat(&self, id: PatId) -> Option<ImplItem> {
128 self.assoc_resolutions.get(&id.into()).map(|it| *it) 128 self.assoc_resolutions.get(&id.into()).copied()
129 } 129 }
130 pub(crate) fn add_diagnostics( 130 pub(crate) fn add_diagnostics(
131 &self, 131 &self,
@@ -239,8 +239,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
239 &self.resolver, 239 &self.resolver,
240 type_ref, 240 type_ref,
241 ); 241 );
242 let ty = self.insert_type_vars(ty); 242 self.insert_type_vars(ty)
243 ty
244 } 243 }
245 244
246 fn unify_substs(&mut self, substs1: &Substs, substs2: &Substs, depth: usize) -> bool { 245 fn unify_substs(&mut self, substs1: &Substs, substs2: &Substs, depth: usize) -> bool {
@@ -973,8 +972,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
973 972
974 for (arg_pat, arg_type) in args.iter().zip(arg_types.iter()) { 973 for (arg_pat, arg_type) in args.iter().zip(arg_types.iter()) {
975 let expected = if let Some(type_ref) = arg_type { 974 let expected = if let Some(type_ref) = arg_type {
976 let ty = self.make_ty(type_ref); 975 self.make_ty(type_ref)
977 ty
978 } else { 976 } else {
979 Ty::Unknown 977 Ty::Unknown
980 }; 978 };
diff --git a/crates/ra_hir/src/ty/infer/unify.rs b/crates/ra_hir/src/ty/infer/unify.rs
index 04633bdb2..49bf5b946 100644
--- a/crates/ra_hir/src/ty/infer/unify.rs
+++ b/crates/ra_hir/src/ty/infer/unify.rs
@@ -102,7 +102,7 @@ impl<T> Canonicalized<T> {
102 ty.fold(&mut |ty| match ty { 102 ty.fold(&mut |ty| match ty {
103 Ty::Bound(idx) => { 103 Ty::Bound(idx) => {
104 if (idx as usize) < self.free_vars.len() { 104 if (idx as usize) < self.free_vars.len() {
105 Ty::Infer(self.free_vars[idx as usize].clone()) 105 Ty::Infer(self.free_vars[idx as usize])
106 } else { 106 } else {
107 Ty::Bound(idx) 107 Ty::Bound(idx)
108 } 108 }
@@ -120,7 +120,7 @@ impl<T> Canonicalized<T> {
120 let new_vars = 120 let new_vars =
121 (0..solution.num_vars).map(|_| ctx.new_type_var()).collect::<Vec<_>>().into(); 121 (0..solution.num_vars).map(|_| ctx.new_type_var()).collect::<Vec<_>>().into();
122 for (i, ty) in solution.value.into_iter().enumerate() { 122 for (i, ty) in solution.value.into_iter().enumerate() {
123 let var = self.free_vars[i].clone(); 123 let var = self.free_vars[i];
124 ctx.unify(&Ty::Infer(var), &ty.subst_bound_vars(&new_vars)); 124 ctx.unify(&Ty::Infer(var), &ty.subst_bound_vars(&new_vars));
125 } 125 }
126 } 126 }
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs
index fc5b06ca8..44216b045 100644
--- a/crates/ra_ide_api/src/db.rs
+++ b/crates/ra_ide_api/src/db.rs
@@ -72,8 +72,8 @@ impl salsa::ParallelDatabase for RootDatabase {
72 fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { 72 fn snapshot(&self) -> salsa::Snapshot<RootDatabase> {
73 salsa::Snapshot::new(RootDatabase { 73 salsa::Snapshot::new(RootDatabase {
74 runtime: self.runtime.snapshot(self), 74 runtime: self.runtime.snapshot(self),
75 last_gc: self.last_gc.clone(), 75 last_gc: self.last_gc,
76 last_gc_check: self.last_gc_check.clone(), 76 last_gc_check: self.last_gc_check,
77 }) 77 })
78 } 78 }
79} 79}
diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs
index e5b257b9b..638484a9b 100644
--- a/crates/ra_ide_api/src/display/structure.rs
+++ b/crates/ra_ide_api/src/display/structure.rs
@@ -25,7 +25,7 @@ pub fn file_structure(file: &SourceFile) -> Vec<StructureNode> {
25 match event { 25 match event {
26 WalkEvent::Enter(node) => { 26 WalkEvent::Enter(node) => {
27 if let Some(mut symbol) = structure_node(node) { 27 if let Some(mut symbol) = structure_node(node) {
28 symbol.parent = stack.last().map(|&n| n); 28 symbol.parent = stack.last().copied();
29 stack.push(res.len()); 29 stack.push(res.len());
30 res.push(symbol); 30 res.push(symbol);
31 } 31 }
diff --git a/crates/ra_ide_api/src/line_index_utils.rs b/crates/ra_ide_api/src/line_index_utils.rs
index f9073dca2..8f63db5f1 100644
--- a/crates/ra_ide_api/src/line_index_utils.rs
+++ b/crates/ra_ide_api/src/line_index_utils.rs
@@ -137,7 +137,7 @@ impl<'a> Edits<'a> {
137 Step::Newline(n) => n, 137 Step::Newline(n) => n,
138 Step::Utf16Char(r) => r.end(), 138 Step::Utf16Char(r) => r.end(),
139 }; 139 };
140 let res = match &mut self.current { 140 match &mut self.current {
141 Some(edit) => { 141 Some(edit) => {
142 if step_pos <= edit.delete.start() { 142 if step_pos <= edit.delete.start() {
143 NextSteps::Use 143 NextSteps::Use
@@ -155,8 +155,7 @@ impl<'a> Edits<'a> {
155 } 155 }
156 } 156 }
157 None => NextSteps::Use, 157 None => NextSteps::Use,
158 }; 158 }
159 res
160 } 159 }
161 160
162 fn translate_range(&self, range: TextRange) -> TextRange { 161 fn translate_range(&self, range: TextRange) -> TextRange {
diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs
index 2ca0a25d4..f4a0c6ac7 100644
--- a/crates/ra_ide_api/src/symbol_index.rs
+++ b/crates/ra_ide_api/src/symbol_index.rs
@@ -87,7 +87,7 @@ pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol>
87 let mut files = Vec::new(); 87 let mut files = Vec::new();
88 for &root in db.local_roots().iter() { 88 for &root in db.local_roots().iter() {
89 let sr = db.source_root(root); 89 let sr = db.source_root(root);
90 files.extend(sr.files.values().map(|&it| it)) 90 files.extend(sr.files.values().copied())
91 } 91 }
92 92
93 let snap = Snap(db.snapshot()); 93 let snap = Snap(db.snapshot());
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs
index c8128f55b..32e67838e 100644
--- a/crates/ra_lsp_server/src/conv.rs
+++ b/crates/ra_lsp_server/src/conv.rs
@@ -171,7 +171,7 @@ impl Conv for ra_ide_api::Documentation {
171 fn conv(self) -> Documentation { 171 fn conv(self) -> Documentation {
172 Documentation::MarkupContent(MarkupContent { 172 Documentation::MarkupContent(MarkupContent {
173 kind: MarkupKind::Markdown, 173 kind: MarkupKind::Markdown,
174 value: crate::markdown::mark_fenced_blocks_as_rust(self.as_str()).into(), 174 value: crate::markdown::mark_fenced_blocks_as_rust(self.as_str()),
175 }) 175 })
176 } 176 }
177} 177}
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index cb73e6586..cd81e226a 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -5,9 +5,7 @@ pub(crate) mod pending_requests;
5use std::{error::Error, fmt, path::PathBuf, sync::Arc, time::Instant}; 5use std::{error::Error, fmt, path::PathBuf, sync::Arc, time::Instant};
6 6
7use crossbeam_channel::{select, unbounded, Receiver, RecvError, Sender}; 7use crossbeam_channel::{select, unbounded, Receiver, RecvError, Sender};
8use gen_lsp_server::{ 8use gen_lsp_server::{handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse};
9 handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse,
10};
11use lsp_types::NumberOrString; 9use lsp_types::NumberOrString;
12use ra_ide_api::{Canceled, FileId, LibraryData}; 10use ra_ide_api::{Canceled, FileId, LibraryData};
13use ra_prof::profile; 11use ra_prof::profile;
@@ -398,7 +396,8 @@ fn on_notification(
398 Ok(mut params) => { 396 Ok(mut params) => {
399 let uri = params.text_document.uri; 397 let uri = params.text_document.uri;
400 let path = uri.to_file_path().map_err(|()| format!("invalid uri: {}", uri))?; 398 let path = uri.to_file_path().map_err(|()| format!("invalid uri: {}", uri))?;
401 let text = params.content_changes.pop().ok_or_else(|| format!("empty changes"))?.text; 399 let text =
400 params.content_changes.pop().ok_or_else(|| "empty changes".to_string())?.text;
402 state.vfs.write().change_file_overlay(path.as_path(), text); 401 state.vfs.write().change_file_overlay(path.as_path(), text);
403 return Ok(()); 402 return Ok(());
404 } 403 }
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs
index fbad8ebe2..c7c06c7fd 100644
--- a/crates/ra_mbe/src/mbe_expander.rs
+++ b/crates/ra_mbe/src/mbe_expander.rs
@@ -498,7 +498,7 @@ fn expand_tt(
498 tt::Leaf::from(tt::Ident { text: ident.text.clone(), id: TokenId::unspecified() }) 498 tt::Leaf::from(tt::Ident { text: ident.text.clone(), id: TokenId::unspecified() })
499 .into() 499 .into()
500 } 500 }
501 crate::Leaf::Punct(punct) => tt::Leaf::from(punct.clone()).into(), 501 crate::Leaf::Punct(punct) => tt::Leaf::from(*punct).into(),
502 crate::Leaf::Var(v) => { 502 crate::Leaf::Var(v) => {
503 if v.text == "crate" { 503 if v.text == "crate" {
504 // FIXME: Properly handle $crate token 504 // FIXME: Properly handle $crate token
diff --git a/crates/ra_mbe/src/mbe_parser.rs b/crates/ra_mbe/src/mbe_parser.rs
index a29885852..cddb4a7b4 100644
--- a/crates/ra_mbe/src/mbe_parser.rs
+++ b/crates/ra_mbe/src/mbe_parser.rs
@@ -56,7 +56,7 @@ fn parse_subtree(tt: &tt::Subtree, transcriber: bool) -> Result<crate::Subtree,
56 } 56 }
57 } 57 }
58 tt::Leaf::Punct(punct) => crate::Leaf::from(*punct).into(), 58 tt::Leaf::Punct(punct) => crate::Leaf::from(*punct).into(),
59 tt::Leaf::Ident(tt::Ident { text, id: _ }) => { 59 tt::Leaf::Ident(tt::Ident { text, .. }) => {
60 crate::Leaf::from(crate::Ident { text: text.clone() }).into() 60 crate::Leaf::from(crate::Ident { text: text.clone() }).into()
61 } 61 }
62 tt::Leaf::Literal(tt::Literal { text }) => { 62 tt::Leaf::Literal(tt::Literal { text }) => {
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs
index 2489c996b..e1c6e7d91 100644
--- a/crates/ra_mbe/src/subtree_source.rs
+++ b/crates/ra_mbe/src/subtree_source.rs
@@ -78,7 +78,7 @@ impl<'a> SubtreeTokenSource<'a> {
78 } 78 }
79 } 79 }
80 80
81 return cached[pos].clone(); 81 cached[pos].clone()
82 } 82 }
83} 83}
84 84
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs
index b91b0e7a5..7560d215a 100644
--- a/crates/ra_mbe/src/syntax_bridge.rs
+++ b/crates/ra_mbe/src/syntax_bridge.rs
@@ -107,7 +107,7 @@ pub fn token_tree_to_ast_item_list(tt: &tt::Subtree) -> TreeArc<ast::SourceFile>
107impl TokenMap { 107impl TokenMap {
108 pub fn relative_range_of(&self, tt: tt::TokenId) -> Option<TextRange> { 108 pub fn relative_range_of(&self, tt: tt::TokenId) -> Option<TextRange> {
109 let idx = tt.0 as usize; 109 let idx = tt.0 as usize;
110 self.tokens.get(idx).map(|&it| it) 110 self.tokens.get(idx).copied()
111 } 111 }
112 112
113 fn alloc(&mut self, relative_range: TextRange) -> tt::TokenId { 113 fn alloc(&mut self, relative_range: TextRange) -> tt::TokenId {
diff --git a/crates/ra_mbe/src/tt_cursor.rs b/crates/ra_mbe/src/tt_cursor.rs
index 503c77ef3..8e360ce0f 100644
--- a/crates/ra_mbe/src/tt_cursor.rs
+++ b/crates/ra_mbe/src/tt_cursor.rs
@@ -171,14 +171,14 @@ impl<'a> TtCursor<'a> {
171 } 171 }
172 172
173 fn eat_punct3(&mut self, p: &tt::Punct) -> Option<SmallVec<[tt::Punct; 3]>> { 173 fn eat_punct3(&mut self, p: &tt::Punct) -> Option<SmallVec<[tt::Punct; 3]>> {
174 let sec = self.eat_punct()?.clone(); 174 let sec = *self.eat_punct()?;
175 let third = self.eat_punct()?.clone(); 175 let third = *self.eat_punct()?;
176 Some(smallvec![p.clone(), sec, third]) 176 Some(smallvec![*p, sec, third])
177 } 177 }
178 178
179 fn eat_punct2(&mut self, p: &tt::Punct) -> Option<SmallVec<[tt::Punct; 3]>> { 179 fn eat_punct2(&mut self, p: &tt::Punct) -> Option<SmallVec<[tt::Punct; 3]>> {
180 let sec = self.eat_punct()?.clone(); 180 let sec = *self.eat_punct()?;
181 Some(smallvec![p.clone(), sec]) 181 Some(smallvec![*p, sec])
182 } 182 }
183 183
184 fn eat_multi_char_punct<'b, I>( 184 fn eat_multi_char_punct<'b, I>(
@@ -251,7 +251,7 @@ impl<'a> TtCursor<'a> {
251 // So we by pass that check here. 251 // So we by pass that check here.
252 let mut peekable = TokenPeek::new(self.subtree.token_trees[self.pos..].iter()); 252 let mut peekable = TokenPeek::new(self.subtree.token_trees[self.pos..].iter());
253 let puncts = self.eat_multi_char_punct(punct, &mut peekable); 253 let puncts = self.eat_multi_char_punct(punct, &mut peekable);
254 let puncts = puncts.unwrap_or_else(|| smallvec![punct.clone()]); 254 let puncts = puncts.unwrap_or_else(|| smallvec![*punct]);
255 255
256 Some(crate::Separator::Puncts(puncts)) 256 Some(crate::Separator::Puncts(puncts))
257 } 257 }
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 74b7efa9a..08e5c1c32 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -191,7 +191,7 @@ impl ProjectWorkspace {
191 } 191 }
192 } 192 }
193 193
194 let libstd = sysroot.std().and_then(|it| sysroot_crates.get(&it).map(|&it| it)); 194 let libstd = sysroot.std().and_then(|it| sysroot_crates.get(&it).copied());
195 195
196 let mut pkg_to_lib_crate = FxHashMap::default(); 196 let mut pkg_to_lib_crate = FxHashMap::default();
197 let mut pkg_crates = FxHashMap::default(); 197 let mut pkg_crates = FxHashMap::default();
diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs
index a419b81e8..4f6e880dd 100644
--- a/crates/ra_project_model/src/sysroot.rs
+++ b/crates/ra_project_model/src/sysroot.rs
@@ -94,7 +94,7 @@ impl SysrootCrate {
94 self.root(sysroot).parent().unwrap() 94 self.root(sysroot).parent().unwrap()
95 } 95 }
96 pub fn deps<'a>(self, sysroot: &'a Sysroot) -> impl Iterator<Item = SysrootCrate> + 'a { 96 pub fn deps<'a>(self, sysroot: &'a Sysroot) -> impl Iterator<Item = SysrootCrate> + 'a {
97 sysroot.crates[self].deps.iter().map(|&it| it) 97 sysroot.crates[self].deps.iter().copied()
98 } 98 }
99} 99}
100 100
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs
index 87dbb0ea5..4355e3587 100644
--- a/crates/ra_syntax/src/ast/expr_extensions.rs
+++ b/crates/ra_syntax/src/ast/expr_extensions.rs
@@ -260,7 +260,7 @@ impl ast::Literal {
260 .iter() 260 .iter()
261 .find(|&s| text.ends_with(s)) 261 .find(|&s| text.ends_with(s))
262 .map(|&suf| SmolStr::new(suf)); 262 .map(|&suf| SmolStr::new(suf));
263 LiteralKind::FloatNumber { suffix: suffix } 263 LiteralKind::FloatNumber { suffix }
264 } 264 }
265 STRING | RAW_STRING => LiteralKind::String, 265 STRING | RAW_STRING => LiteralKind::String,
266 T![true] | T![false] => LiteralKind::Bool, 266 T![true] | T![false] => LiteralKind::Bool,
diff --git a/crates/ra_syntax/src/fuzz.rs b/crates/ra_syntax/src/fuzz.rs
index 6d114aad4..00039f970 100644
--- a/crates/ra_syntax/src/fuzz.rs
+++ b/crates/ra_syntax/src/fuzz.rs
@@ -21,8 +21,8 @@ pub struct CheckReparse {
21 21
22impl CheckReparse { 22impl CheckReparse {
23 pub fn from_data(data: &[u8]) -> Option<Self> { 23 pub fn from_data(data: &[u8]) -> Option<Self> {
24 const PREFIX: &'static str = "fn main(){\n\t"; 24 const PREFIX: &str = "fn main(){\n\t";
25 const SUFFIX: &'static str = "\n}"; 25 const SUFFIX: &str = "\n}";
26 26
27 let data = str::from_utf8(data).ok()?; 27 let data = str::from_utf8(data).ok()?;
28 let mut lines = data.lines(); 28 let mut lines = data.lines();
diff --git a/crates/ra_syntax/src/parsing/text_token_source.rs b/crates/ra_syntax/src/parsing/text_token_source.rs
index f592b499f..64cb20ae8 100644
--- a/crates/ra_syntax/src/parsing/text_token_source.rs
+++ b/crates/ra_syntax/src/parsing/text_token_source.rs
@@ -28,7 +28,7 @@ pub(crate) struct TextTokenSource<'t> {
28 28
29impl<'t> TokenSource for TextTokenSource<'t> { 29impl<'t> TokenSource for TextTokenSource<'t> {
30 fn current(&self) -> PToken { 30 fn current(&self) -> PToken {
31 return self.curr.0; 31 self.curr.0
32 } 32 }
33 33
34 fn lookahead_nth(&self, n: usize) -> PToken { 34 fn lookahead_nth(&self, n: usize) -> PToken {
diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs
index 80c8639c8..a1f9a59b6 100644
--- a/crates/ra_syntax/src/syntax_node.rs
+++ b/crates/ra_syntax/src/syntax_node.rs
@@ -357,7 +357,7 @@ impl SyntaxNode {
357 // `range` private afterwards 357 // `range` private afterwards
358 let mut ptr = SyntaxNodePtr::new(self); 358 let mut ptr = SyntaxNodePtr::new(self);
359 ptr.range = TextRange::offset_len(ptr.range().start(), len); 359 ptr.range = TextRange::offset_len(ptr.range().start(), len);
360 return ptr.to_node(file.syntax()).to_owned(); 360 ptr.to_node(file.syntax()).to_owned()
361 } 361 }
362 362
363 fn position_of_child(&self, child: SyntaxElement) -> usize { 363 fn position_of_child(&self, child: SyntaxElement) -> usize {
diff --git a/crates/ra_syntax/src/validation/unescape.rs b/crates/ra_syntax/src/validation/unescape.rs
index 4c3a7effc..1cb2433f3 100644
--- a/crates/ra_syntax/src/validation/unescape.rs
+++ b/crates/ra_syntax/src/validation/unescape.rs
@@ -173,7 +173,7 @@ fn scan_escape(first_char: char, chars: &mut Chars<'_>, mode: Mode) -> Result<ch
173 } 173 }
174 174
175 break std::char::from_u32(value).ok_or_else(|| { 175 break std::char::from_u32(value).ok_or_else(|| {
176 if value > 0x10FFFF { 176 if value > 0x0010_FFFF {
177 EscapeError::OutOfRangeUnicodeEscape 177 EscapeError::OutOfRangeUnicodeEscape
178 } else { 178 } else {
179 EscapeError::LoneSurrogateUnicodeEscape 179 EscapeError::LoneSurrogateUnicodeEscape