aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-17 08:12:34 +0000
committerGitHub <[email protected]>2021-03-17 08:12:34 +0000
commitf7fbea509f1e5f840e715c912ee38aa997d1bfbc (patch)
tree2b4932678fc83624c278ca93cdf0f1d3a28346c2 /crates
parent6fcb5d772f16af0d1f62dad55fbde75072fb9e89 (diff)
parentff5f90d8ae2da8e4856d5c78f55e5cd02b178325 (diff)
Merge #8063
8063: couple clippy::complexity fixes r=matklad a=matthiaskrgr avoid redundant `.into()` calls to convert T into identical T (`let x: String = String::from("hello").into();`) use `if let Some(x)` instead of `.is_some()` + `.unwrap()` don't clone Copy types remove redundant wrapped ?s: `Some(Some(3)?)` can just be `Some(3)` use `.map(|x| y)` instead of `and_then(|x| Some(y)` on `Option`s Co-authored-by: Matthias Krüger <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/base_db/src/fixture.rs2
-rw-r--r--crates/hir/src/attrs.rs2
-rw-r--r--crates/hir/src/lib.rs12
-rw-r--r--crates/hir/src/semantics.rs2
-rw-r--r--crates/hir/src/source_analyzer.rs2
-rw-r--r--crates/hir_def/src/attr.rs2
-rw-r--r--crates/hir_expand/src/hygiene.rs7
-rw-r--r--crates/hir_expand/src/lib.rs4
-rw-r--r--crates/hir_ty/src/diagnostics/decl_check.rs18
-rw-r--r--crates/hir_ty/src/diagnostics/expr.rs18
-rw-r--r--crates/hir_ty/src/diagnostics/unsafe_check.rs2
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs2
-rw-r--r--crates/ide/src/diagnostics/fixes.rs2
-rw-r--r--crates/ide/src/doc_links.rs4
-rw-r--r--crates/ide/src/goto_definition.rs2
-rw-r--r--crates/ide/src/syntax_highlighting/inject.rs2
-rw-r--r--crates/ide_assists/src/handlers/expand_glob_import.rs4
-rw-r--r--crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs7
-rw-r--r--crates/ide_completion/src/completions.rs2
-rw-r--r--crates/ide_completion/src/completions/pattern.rs4
-rw-r--r--crates/ide_completion/src/completions/postfix/format_like.rs2
-rw-r--r--crates/ide_completion/src/render.rs2
-rw-r--r--crates/ide_db/src/defs.rs2
-rw-r--r--crates/ide_db/src/helpers/insert_use.rs2
-rw-r--r--crates/ide_db/src/search.rs34
-rw-r--r--crates/ide_ssr/src/lib.rs7
-rw-r--r--crates/ide_ssr/src/matching.rs2
-rw-r--r--crates/mbe/src/benchmark.rs21
-rw-r--r--crates/mbe/src/expander/matcher.rs14
-rw-r--r--crates/mbe/src/parser.rs2
-rw-r--r--crates/mbe/src/syntax_bridge.rs4
-rw-r--r--crates/mbe/src/tests.rs2
-rw-r--r--crates/proc_macro_api/src/process.rs2
-rw-r--r--crates/proc_macro_api/src/rpc.rs11
-rw-r--r--crates/rust-analyzer/src/diagnostics/to_proto.rs2
-rw-r--r--crates/rust-analyzer/src/handlers.rs2
-rw-r--r--crates/rust-analyzer/src/lsp_utils.rs2
-rw-r--r--crates/rust-analyzer/src/to_proto.rs2
-rw-r--r--crates/syntax/src/ast/edit.rs2
-rw-r--r--crates/syntax/src/ted.rs2
40 files changed, 97 insertions, 122 deletions
diff --git a/crates/base_db/src/fixture.rs b/crates/base_db/src/fixture.rs
index cad6866aa..8d4641355 100644
--- a/crates/base_db/src/fixture.rs
+++ b/crates/base_db/src/fixture.rs
@@ -197,7 +197,7 @@ impl ChangeFixture {
197 197
198 change.change_file(file_id, Some(Arc::new(text))); 198 change.change_file(file_id, Some(Arc::new(text)));
199 let path = VfsPath::new_virtual_path(meta.path); 199 let path = VfsPath::new_virtual_path(meta.path);
200 file_set.insert(file_id, path.into()); 200 file_set.insert(file_id, path);
201 files.push(file_id); 201 files.push(file_id);
202 file_id.0 += 1; 202 file_id.0 += 1;
203 } 203 }
diff --git a/crates/hir/src/attrs.rs b/crates/hir/src/attrs.rs
index 9e6a3e155..b9c695921 100644
--- a/crates/hir/src/attrs.rs
+++ b/crates/hir/src/attrs.rs
@@ -124,5 +124,5 @@ fn resolve_doc_path(
124 Some(Namespace::Macros) => return None, 124 Some(Namespace::Macros) => return None,
125 None => resolved.iter_items().find_map(|it| it.as_module_def_id())?, 125 None => resolved.iter_items().find_map(|it| it.as_module_def_id())?,
126 }; 126 };
127 Some(def.into()) 127 Some(def)
128} 128}
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 12dd5fb38..861b7329e 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1335,7 +1335,7 @@ impl Local {
1335 1335
1336 // FIXME: why is this an option? It shouldn't be? 1336 // FIXME: why is this an option? It shouldn't be?
1337 pub fn name(self, db: &dyn HirDatabase) -> Option<Name> { 1337 pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
1338 let body = db.body(self.parent.into()); 1338 let body = db.body(self.parent);
1339 match &body[self.pat_id] { 1339 match &body[self.pat_id] {
1340 Pat::Bind { name, .. } => Some(name.clone()), 1340 Pat::Bind { name, .. } => Some(name.clone()),
1341 _ => None, 1341 _ => None,
@@ -1347,7 +1347,7 @@ impl Local {
1347 } 1347 }
1348 1348
1349 pub fn is_mut(self, db: &dyn HirDatabase) -> bool { 1349 pub fn is_mut(self, db: &dyn HirDatabase) -> bool {
1350 let body = db.body(self.parent.into()); 1350 let body = db.body(self.parent);
1351 matches!(&body[self.pat_id], Pat::Bind { mode: BindingAnnotation::Mutable, .. }) 1351 matches!(&body[self.pat_id], Pat::Bind { mode: BindingAnnotation::Mutable, .. })
1352 } 1352 }
1353 1353
@@ -1360,7 +1360,7 @@ impl Local {
1360 } 1360 }
1361 1361
1362 pub fn ty(self, db: &dyn HirDatabase) -> Type { 1362 pub fn ty(self, db: &dyn HirDatabase) -> Type {
1363 let def = DefWithBodyId::from(self.parent); 1363 let def = self.parent;
1364 let infer = db.infer(def); 1364 let infer = db.infer(def);
1365 let ty = infer[self.pat_id].clone(); 1365 let ty = infer[self.pat_id].clone();
1366 let krate = def.module(db.upcast()).krate(); 1366 let krate = def.module(db.upcast()).krate();
@@ -1368,7 +1368,7 @@ impl Local {
1368 } 1368 }
1369 1369
1370 pub fn source(self, db: &dyn HirDatabase) -> InFile<Either<ast::IdentPat, ast::SelfParam>> { 1370 pub fn source(self, db: &dyn HirDatabase) -> InFile<Either<ast::IdentPat, ast::SelfParam>> {
1371 let (_body, source_map) = db.body_with_source_map(self.parent.into()); 1371 let (_body, source_map) = db.body_with_source_map(self.parent);
1372 let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm... 1372 let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm...
1373 let root = src.file_syntax(db.upcast()); 1373 let root = src.file_syntax(db.upcast());
1374 src.map(|ast| { 1374 src.map(|ast| {
@@ -1393,12 +1393,12 @@ impl Label {
1393 } 1393 }
1394 1394
1395 pub fn name(self, db: &dyn HirDatabase) -> Name { 1395 pub fn name(self, db: &dyn HirDatabase) -> Name {
1396 let body = db.body(self.parent.into()); 1396 let body = db.body(self.parent);
1397 body[self.label_id].name.clone() 1397 body[self.label_id].name.clone()
1398 } 1398 }
1399 1399
1400 pub fn source(self, db: &dyn HirDatabase) -> InFile<ast::Label> { 1400 pub fn source(self, db: &dyn HirDatabase) -> InFile<ast::Label> {
1401 let (_body, source_map) = db.body_with_source_map(self.parent.into()); 1401 let (_body, source_map) = db.body_with_source_map(self.parent);
1402 let src = source_map.label_syntax(self.label_id); 1402 let src = source_map.label_syntax(self.label_id);
1403 let root = src.file_syntax(db.upcast()); 1403 let root = src.file_syntax(db.upcast());
1404 src.map(|ast| ast.to_node(&root)) 1404 src.map(|ast| ast.to_node(&root))
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 03c9371b5..00b076175 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -835,7 +835,7 @@ impl<'a> SemanticsScope<'a> {
835 resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), 835 resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()),
836 resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(id.into()), 836 resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(id.into()),
837 resolver::ScopeDef::Local(pat_id) => { 837 resolver::ScopeDef::Local(pat_id) => {
838 let parent = resolver.body_owner().unwrap().into(); 838 let parent = resolver.body_owner().unwrap();
839 ScopeDef::Local(Local { parent, pat_id }) 839 ScopeDef::Local(Local { parent, pat_id })
840 } 840 }
841 }; 841 };
diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs
index 117f32a9e..37d162b32 100644
--- a/crates/hir/src/source_analyzer.rs
+++ b/crates/hir/src/source_analyzer.rs
@@ -484,7 +484,7 @@ fn resolve_hir_path_(
484 resolver.resolve_path_in_value_ns_fully(db.upcast(), path.mod_path()).and_then(|val| { 484 resolver.resolve_path_in_value_ns_fully(db.upcast(), path.mod_path()).and_then(|val| {
485 let res = match val { 485 let res = match val {
486 ValueNs::LocalBinding(pat_id) => { 486 ValueNs::LocalBinding(pat_id) => {
487 let var = Local { parent: body_owner?.into(), pat_id }; 487 let var = Local { parent: body_owner?, pat_id };
488 PathResolution::Local(var) 488 PathResolution::Local(var)
489 } 489 }
490 ValueNs::FunctionId(it) => PathResolution::Def(Function::from(it).into()), 490 ValueNs::FunctionId(it) => PathResolution::Def(Function::from(it).into()),
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs
index 7b41b148c..b0b4b5052 100644
--- a/crates/hir_def/src/attr.rs
+++ b/crates/hir_def/src/attr.rs
@@ -325,7 +325,7 @@ impl Attrs {
325 if docs.is_empty() { 325 if docs.is_empty() {
326 None 326 None
327 } else { 327 } else {
328 Some(Documentation(docs.into())) 328 Some(Documentation(docs))
329 } 329 }
330 } 330 }
331} 331}
diff --git a/crates/hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs
index c8ea81210..87cad326d 100644
--- a/crates/hir_expand/src/hygiene.rs
+++ b/crates/hir_expand/src/hygiene.rs
@@ -23,7 +23,7 @@ pub struct Hygiene {
23 23
24impl Hygiene { 24impl Hygiene {
25 pub fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Hygiene { 25 pub fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Hygiene {
26 Hygiene { frames: Some(HygieneFrames::new(db, file_id.clone())) } 26 Hygiene { frames: Some(HygieneFrames::new(db, file_id)) }
27 } 27 }
28 28
29 pub fn new_unhygienic() -> Hygiene { 29 pub fn new_unhygienic() -> Hygiene {
@@ -129,10 +129,7 @@ impl HygieneInfo {
129 mbe::Origin::Call => (&self.macro_arg.1, self.arg_start), 129 mbe::Origin::Call => (&self.macro_arg.1, self.arg_start),
130 mbe::Origin::Def => ( 130 mbe::Origin::Def => (
131 &self.macro_def.1, 131 &self.macro_def.1,
132 self.def_start 132 *self.def_start.as_ref().expect("`Origin::Def` used with non-`macro_rules!` macro"),
133 .as_ref()
134 .expect("`Origin::Def` used with non-`macro_rules!` macro")
135 .clone(),
136 ), 133 ),
137 }; 134 };
138 135
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs
index eee430af1..7532d00b8 100644
--- a/crates/hir_expand/src/lib.rs
+++ b/crates/hir_expand/src/lib.rs
@@ -475,7 +475,7 @@ fn original_range_opt(
475 let single = skip_trivia_token(node.value.first_token()?, Direction::Next)? 475 let single = skip_trivia_token(node.value.first_token()?, Direction::Next)?
476 == skip_trivia_token(node.value.last_token()?, Direction::Prev)?; 476 == skip_trivia_token(node.value.last_token()?, Direction::Prev)?;
477 477
478 Some(node.value.descendants().find_map(|it| { 478 node.value.descendants().find_map(|it| {
479 let first = skip_trivia_token(it.first_token()?, Direction::Next)?; 479 let first = skip_trivia_token(it.first_token()?, Direction::Next)?;
480 let first = ascend_call_token(db, &expansion, node.with_value(first))?; 480 let first = ascend_call_token(db, &expansion, node.with_value(first))?;
481 481
@@ -487,7 +487,7 @@ fn original_range_opt(
487 } 487 }
488 488
489 Some(first.with_value(first.value.text_range().cover(last.value.text_range()))) 489 Some(first.with_value(first.value.text_range().cover(last.value.text_range())))
490 })?) 490 })
491} 491}
492 492
493fn ascend_call_token( 493fn ascend_call_token(
diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs
index 982ad5b9e..bfe239793 100644
--- a/crates/hir_ty/src/diagnostics/decl_check.rs
+++ b/crates/hir_ty/src/diagnostics/decl_check.rs
@@ -203,7 +203,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
203 let diagnostic = IncorrectCase { 203 let diagnostic = IncorrectCase {
204 file: fn_src.file_id, 204 file: fn_src.file_id,
205 ident_type: IdentType::Function, 205 ident_type: IdentType::Function,
206 ident: AstPtr::new(&ast_ptr).into(), 206 ident: AstPtr::new(&ast_ptr),
207 expected_case: replacement.expected_case, 207 expected_case: replacement.expected_case,
208 ident_text: replacement.current_name.to_string(), 208 ident_text: replacement.current_name.to_string(),
209 suggested_text: replacement.suggested_text, 209 suggested_text: replacement.suggested_text,
@@ -261,7 +261,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
261 let diagnostic = IncorrectCase { 261 let diagnostic = IncorrectCase {
262 file: fn_src.file_id, 262 file: fn_src.file_id,
263 ident_type: IdentType::Argument, 263 ident_type: IdentType::Argument,
264 ident: AstPtr::new(&ast_ptr).into(), 264 ident: AstPtr::new(&ast_ptr),
265 expected_case: param_to_rename.expected_case, 265 expected_case: param_to_rename.expected_case,
266 ident_text: param_to_rename.current_name.to_string(), 266 ident_text: param_to_rename.current_name.to_string(),
267 suggested_text: param_to_rename.suggested_text, 267 suggested_text: param_to_rename.suggested_text,
@@ -313,7 +313,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
313 let diagnostic = IncorrectCase { 313 let diagnostic = IncorrectCase {
314 file: source_ptr.file_id, 314 file: source_ptr.file_id,
315 ident_type: IdentType::Variable, 315 ident_type: IdentType::Variable,
316 ident: AstPtr::new(&name_ast).into(), 316 ident: AstPtr::new(&name_ast),
317 expected_case: replacement.expected_case, 317 expected_case: replacement.expected_case,
318 ident_text: replacement.current_name.to_string(), 318 ident_text: replacement.current_name.to_string(),
319 suggested_text: replacement.suggested_text, 319 suggested_text: replacement.suggested_text,
@@ -403,7 +403,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
403 let diagnostic = IncorrectCase { 403 let diagnostic = IncorrectCase {
404 file: struct_src.file_id, 404 file: struct_src.file_id,
405 ident_type: IdentType::Structure, 405 ident_type: IdentType::Structure,
406 ident: AstPtr::new(&ast_ptr).into(), 406 ident: AstPtr::new(&ast_ptr),
407 expected_case: replacement.expected_case, 407 expected_case: replacement.expected_case,
408 ident_text: replacement.current_name.to_string(), 408 ident_text: replacement.current_name.to_string(),
409 suggested_text: replacement.suggested_text, 409 suggested_text: replacement.suggested_text,
@@ -448,7 +448,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
448 let diagnostic = IncorrectCase { 448 let diagnostic = IncorrectCase {
449 file: struct_src.file_id, 449 file: struct_src.file_id,
450 ident_type: IdentType::Field, 450 ident_type: IdentType::Field,
451 ident: AstPtr::new(&ast_ptr).into(), 451 ident: AstPtr::new(&ast_ptr),
452 expected_case: field_to_rename.expected_case, 452 expected_case: field_to_rename.expected_case,
453 ident_text: field_to_rename.current_name.to_string(), 453 ident_text: field_to_rename.current_name.to_string(),
454 suggested_text: field_to_rename.suggested_text, 454 suggested_text: field_to_rename.suggested_text,
@@ -527,7 +527,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
527 let diagnostic = IncorrectCase { 527 let diagnostic = IncorrectCase {
528 file: enum_src.file_id, 528 file: enum_src.file_id,
529 ident_type: IdentType::Enum, 529 ident_type: IdentType::Enum,
530 ident: AstPtr::new(&ast_ptr).into(), 530 ident: AstPtr::new(&ast_ptr),
531 expected_case: replacement.expected_case, 531 expected_case: replacement.expected_case,
532 ident_text: replacement.current_name.to_string(), 532 ident_text: replacement.current_name.to_string(),
533 suggested_text: replacement.suggested_text, 533 suggested_text: replacement.suggested_text,
@@ -572,7 +572,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
572 let diagnostic = IncorrectCase { 572 let diagnostic = IncorrectCase {
573 file: enum_src.file_id, 573 file: enum_src.file_id,
574 ident_type: IdentType::Variant, 574 ident_type: IdentType::Variant,
575 ident: AstPtr::new(&ast_ptr).into(), 575 ident: AstPtr::new(&ast_ptr),
576 expected_case: variant_to_rename.expected_case, 576 expected_case: variant_to_rename.expected_case,
577 ident_text: variant_to_rename.current_name.to_string(), 577 ident_text: variant_to_rename.current_name.to_string(),
578 suggested_text: variant_to_rename.suggested_text, 578 suggested_text: variant_to_rename.suggested_text,
@@ -617,7 +617,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
617 let diagnostic = IncorrectCase { 617 let diagnostic = IncorrectCase {
618 file: const_src.file_id, 618 file: const_src.file_id,
619 ident_type: IdentType::Constant, 619 ident_type: IdentType::Constant,
620 ident: AstPtr::new(&ast_ptr).into(), 620 ident: AstPtr::new(&ast_ptr),
621 expected_case: replacement.expected_case, 621 expected_case: replacement.expected_case,
622 ident_text: replacement.current_name.to_string(), 622 ident_text: replacement.current_name.to_string(),
623 suggested_text: replacement.suggested_text, 623 suggested_text: replacement.suggested_text,
@@ -665,7 +665,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
665 let diagnostic = IncorrectCase { 665 let diagnostic = IncorrectCase {
666 file: static_src.file_id, 666 file: static_src.file_id,
667 ident_type: IdentType::StaticVariable, 667 ident_type: IdentType::StaticVariable,
668 ident: AstPtr::new(&ast_ptr).into(), 668 ident: AstPtr::new(&ast_ptr),
669 expected_case: replacement.expected_case, 669 expected_case: replacement.expected_case,
670 ident_text: replacement.current_name.to_string(), 670 ident_text: replacement.current_name.to_string(),
671 suggested_text: replacement.suggested_text, 671 suggested_text: replacement.suggested_text,
diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs
index b2bfd68d4..71b2cade0 100644
--- a/crates/hir_ty/src/diagnostics/expr.rs
+++ b/crates/hir_ty/src/diagnostics/expr.rs
@@ -44,7 +44,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
44 pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) { 44 pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) {
45 self.check_for_filter_map_next(db); 45 self.check_for_filter_map_next(db);
46 46
47 let body = db.body(self.owner.into()); 47 let body = db.body(self.owner);
48 48
49 for (id, expr) in body.exprs.iter() { 49 for (id, expr) in body.exprs.iter() {
50 if let Some((variant_def, missed_fields, true)) = 50 if let Some((variant_def, missed_fields, true)) =
@@ -98,7 +98,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
98 missed_fields: Vec<LocalFieldId>, 98 missed_fields: Vec<LocalFieldId>,
99 ) { 99 ) {
100 // XXX: only look at source_map if we do have missing fields 100 // XXX: only look at source_map if we do have missing fields
101 let (_, source_map) = db.body_with_source_map(self.owner.into()); 101 let (_, source_map) = db.body_with_source_map(self.owner);
102 102
103 if let Ok(source_ptr) = source_map.expr_syntax(id) { 103 if let Ok(source_ptr) = source_map.expr_syntax(id) {
104 let root = source_ptr.file_syntax(db.upcast()); 104 let root = source_ptr.file_syntax(db.upcast());
@@ -128,7 +128,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
128 missed_fields: Vec<LocalFieldId>, 128 missed_fields: Vec<LocalFieldId>,
129 ) { 129 ) {
130 // XXX: only look at source_map if we do have missing fields 130 // XXX: only look at source_map if we do have missing fields
131 let (_, source_map) = db.body_with_source_map(self.owner.into()); 131 let (_, source_map) = db.body_with_source_map(self.owner);
132 132
133 if let Ok(source_ptr) = source_map.pat_syntax(id) { 133 if let Ok(source_ptr) = source_map.pat_syntax(id) {
134 if let Some(expr) = source_ptr.value.as_ref().left() { 134 if let Some(expr) = source_ptr.value.as_ref().left() {
@@ -175,7 +175,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
175 }; 175 };
176 176
177 // Search function body for instances of .filter_map(..).next() 177 // Search function body for instances of .filter_map(..).next()
178 let body = db.body(self.owner.into()); 178 let body = db.body(self.owner);
179 let mut prev = None; 179 let mut prev = None;
180 for (id, expr) in body.exprs.iter() { 180 for (id, expr) in body.exprs.iter() {
181 if let Expr::MethodCall { receiver, .. } = expr { 181 if let Expr::MethodCall { receiver, .. } = expr {
@@ -192,7 +192,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
192 if function_id == *next_function_id { 192 if function_id == *next_function_id {
193 if let Some(filter_map_id) = prev { 193 if let Some(filter_map_id) = prev {
194 if *receiver == filter_map_id { 194 if *receiver == filter_map_id {
195 let (_, source_map) = db.body_with_source_map(self.owner.into()); 195 let (_, source_map) = db.body_with_source_map(self.owner);
196 if let Ok(next_source_ptr) = source_map.expr_syntax(id) { 196 if let Ok(next_source_ptr) = source_map.expr_syntax(id) {
197 self.sink.push(ReplaceFilterMapNextWithFindMap { 197 self.sink.push(ReplaceFilterMapNextWithFindMap {
198 file: next_source_ptr.file_id, 198 file: next_source_ptr.file_id,
@@ -262,7 +262,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
262 let mut arg_count = args.len(); 262 let mut arg_count = args.len();
263 263
264 if arg_count != param_count { 264 if arg_count != param_count {
265 let (_, source_map) = db.body_with_source_map(self.owner.into()); 265 let (_, source_map) = db.body_with_source_map(self.owner);
266 if let Ok(source_ptr) = source_map.expr_syntax(call_id) { 266 if let Ok(source_ptr) = source_map.expr_syntax(call_id) {
267 if is_method_call { 267 if is_method_call {
268 param_count -= 1; 268 param_count -= 1;
@@ -287,7 +287,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
287 infer: Arc<InferenceResult>, 287 infer: Arc<InferenceResult>,
288 ) { 288 ) {
289 let (body, source_map): (Arc<Body>, Arc<BodySourceMap>) = 289 let (body, source_map): (Arc<Body>, Arc<BodySourceMap>) =
290 db.body_with_source_map(self.owner.into()); 290 db.body_with_source_map(self.owner);
291 291
292 let match_expr_ty = if infer.type_of_expr[match_expr].is_unknown() { 292 let match_expr_ty = if infer.type_of_expr[match_expr].is_unknown() {
293 return; 293 return;
@@ -393,7 +393,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
393 }; 393 };
394 394
395 if params.len() > 0 && params[0] == mismatch.actual { 395 if params.len() > 0 && params[0] == mismatch.actual {
396 let (_, source_map) = db.body_with_source_map(self.owner.into()); 396 let (_, source_map) = db.body_with_source_map(self.owner);
397 397
398 if let Ok(source_ptr) = source_map.expr_syntax(id) { 398 if let Ok(source_ptr) = source_map.expr_syntax(id) {
399 self.sink.push(MissingOkOrSomeInTailExpr { 399 self.sink.push(MissingOkOrSomeInTailExpr {
@@ -425,7 +425,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
425 return; 425 return;
426 } 426 }
427 427
428 let (_, source_map) = db.body_with_source_map(self.owner.into()); 428 let (_, source_map) = db.body_with_source_map(self.owner);
429 429
430 if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) { 430 if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) {
431 self.sink 431 self.sink
diff --git a/crates/hir_ty/src/diagnostics/unsafe_check.rs b/crates/hir_ty/src/diagnostics/unsafe_check.rs
index 44a7e5506..1f49a4909 100644
--- a/crates/hir_ty/src/diagnostics/unsafe_check.rs
+++ b/crates/hir_ty/src/diagnostics/unsafe_check.rs
@@ -29,7 +29,7 @@ impl<'a, 'b> UnsafeValidator<'a, 'b> {
29 } 29 }
30 30
31 pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) { 31 pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) {
32 let def = self.owner.into(); 32 let def = self.owner;
33 let unsafe_expressions = unsafe_expressions(db, self.infer.as_ref(), def); 33 let unsafe_expressions = unsafe_expressions(db, self.infer.as_ref(), def);
34 let is_unsafe = match self.owner { 34 let is_unsafe = match self.owner {
35 DefWithBodyId::FunctionId(it) => db.function_data(it).qualifier.is_unsafe, 35 DefWithBodyId::FunctionId(it) => db.function_data(it).qualifier.is_unsafe,
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 524814f43..d969527dc 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -52,7 +52,7 @@ impl ToChalk for Ty {
52 52
53 TyKind::Tuple(cardinality, substs) => { 53 TyKind::Tuple(cardinality, substs) => {
54 let substitution = substs.to_chalk(db); 54 let substitution = substs.to_chalk(db);
55 chalk_ir::TyKind::Tuple(cardinality.into(), substitution).intern(&Interner) 55 chalk_ir::TyKind::Tuple(cardinality, substitution).intern(&Interner)
56 } 56 }
57 TyKind::Raw(mutability, ty) => { 57 TyKind::Raw(mutability, ty) => {
58 let ty = ty.to_chalk(db); 58 let ty = ty.to_chalk(db);
diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs
index cbfc66ab3..2f840909c 100644
--- a/crates/ide/src/diagnostics/fixes.rs
+++ b/crates/ide/src/diagnostics/fixes.rs
@@ -180,7 +180,7 @@ fn missing_record_expr_field_fix(
180 let def_id = sema.resolve_variant(record_lit)?; 180 let def_id = sema.resolve_variant(record_lit)?;
181 let module; 181 let module;
182 let def_file_id; 182 let def_file_id;
183 let record_fields = match VariantDef::from(def_id) { 183 let record_fields = match def_id {
184 VariantDef::Struct(s) => { 184 VariantDef::Struct(s) => {
185 module = s.module(sema.db); 185 module = s.module(sema.db);
186 let source = s.source(sema.db)?; 186 let source = s.source(sema.db)?;
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs
index 461e11060..5ea9fc4fb 100644
--- a/crates/ide/src/doc_links.rs
+++ b/crates/ide/src/doc_links.rs
@@ -93,7 +93,7 @@ pub(crate) fn remove_links(markdown: &str) -> String {
93 93
94 let mut cb = |_: BrokenLink| { 94 let mut cb = |_: BrokenLink| {
95 let empty = InlineStr::try_from("").unwrap(); 95 let empty = InlineStr::try_from("").unwrap();
96 Some((CowStr::Inlined(empty.clone()), CowStr::Inlined(empty))) 96 Some((CowStr::Inlined(empty), CowStr::Inlined(empty)))
97 }; 97 };
98 let doc = Parser::new_with_broken_link_callback(markdown, opts, Some(&mut cb)); 98 let doc = Parser::new_with_broken_link_callback(markdown, opts, Some(&mut cb));
99 let doc = doc.filter_map(move |evt| match evt { 99 let doc = doc.filter_map(move |evt| match evt {
@@ -147,7 +147,7 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
147 _ => return None, 147 _ => return None,
148 }; 148 };
149 149
150 let ns = ItemInNs::from(target_def.clone()); 150 let ns = ItemInNs::from(target_def);
151 151
152 let module = definition.module(db)?; 152 let module = definition.module(db)?;
153 let krate = module.krate(); 153 let krate = module.krate();
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index 6986477a5..b71f4917c 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -102,7 +102,7 @@ fn extract_positioned_link_from_comment(
102 None => comment_range.end(), 102 None => comment_range.end(),
103 } 103 }
104 })?; 104 })?;
105 Some((def_link.to_string(), ns.clone())) 105 Some((def_link.to_string(), *ns))
106} 106}
107 107
108fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> { 108fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> {
diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs
index 8cdc3688f..4f825523c 100644
--- a/crates/ide/src/syntax_highlighting/inject.rs
+++ b/crates/ide/src/syntax_highlighting/inject.rs
@@ -56,7 +56,7 @@ pub(super) fn ra_fixture(
56 for range in inj.map_range_up(hl_range.range) { 56 for range in inj.map_range_up(hl_range.range) {
57 if let Some(range) = literal.map_range_up(range) { 57 if let Some(range) = literal.map_range_up(range) {
58 hl_range.range = range; 58 hl_range.range = range;
59 hl.add(hl_range.clone()); 59 hl.add(hl_range);
60 } 60 }
61 } 61 }
62 } 62 }
diff --git a/crates/ide_assists/src/handlers/expand_glob_import.rs b/crates/ide_assists/src/handlers/expand_glob_import.rs
index 5b540df5c..83aa11d52 100644
--- a/crates/ide_assists/src/handlers/expand_glob_import.rs
+++ b/crates/ide_assists/src/handlers/expand_glob_import.rs
@@ -73,8 +73,8 @@ fn find_parent_and_path(
73) -> Option<(Either<ast::UseTree, ast::UseTreeList>, ast::Path)> { 73) -> Option<(Either<ast::UseTree, ast::UseTreeList>, ast::Path)> {
74 return star.ancestors().find_map(|n| { 74 return star.ancestors().find_map(|n| {
75 find_use_tree_list(n.clone()) 75 find_use_tree_list(n.clone())
76 .and_then(|(u, p)| Some((Either::Right(u), p))) 76 .map(|(u, p)| (Either::Right(u), p))
77 .or_else(|| find_use_tree(n).and_then(|(u, p)| Some((Either::Left(u), p)))) 77 .or_else(|| find_use_tree(n).map(|(u, p)| (Either::Left(u), p)))
78 }); 78 });
79 79
80 fn find_use_tree_list(n: SyntaxNode) -> Option<(ast::UseTreeList, ast::Path)> { 80 fn find_use_tree_list(n: SyntaxNode) -> Option<(ast::UseTreeList, ast::Path)> {
diff --git a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs
index 335e0ed95..596c536a7 100644
--- a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -145,11 +145,8 @@ fn insert_import(
145 variant_hir_name: &Name, 145 variant_hir_name: &Name,
146) -> Option<()> { 146) -> Option<()> {
147 let db = ctx.db(); 147 let db = ctx.db();
148 let mod_path = module.find_use_path_prefixed( 148 let mod_path =
149 db, 149 module.find_use_path_prefixed(db, *enum_module_def, ctx.config.insert_use.prefix_kind);
150 enum_module_def.clone(),
151 ctx.config.insert_use.prefix_kind,
152 );
153 if let Some(mut mod_path) = mod_path { 150 if let Some(mut mod_path) = mod_path {
154 mod_path.pop_segment(); 151 mod_path.pop_segment();
155 mod_path.push_segment(variant_hir_name.clone()); 152 mod_path.push_segment(variant_hir_name.clone());
diff --git a/crates/ide_completion/src/completions.rs b/crates/ide_completion/src/completions.rs
index 3b582ed07..09882c4f3 100644
--- a/crates/ide_completion/src/completions.rs
+++ b/crates/ide_completion/src/completions.rs
@@ -56,7 +56,7 @@ impl Builder {
56 56
57impl Completions { 57impl Completions {
58 pub(crate) fn add(&mut self, item: CompletionItem) { 58 pub(crate) fn add(&mut self, item: CompletionItem) {
59 self.buf.push(item.into()) 59 self.buf.push(item)
60 } 60 }
61 61
62 pub(crate) fn add_all<I>(&mut self, items: I) 62 pub(crate) fn add_all<I>(&mut self, items: I)
diff --git a/crates/ide_completion/src/completions/pattern.rs b/crates/ide_completion/src/completions/pattern.rs
index 46cef58f0..476eecff0 100644
--- a/crates/ide_completion/src/completions/pattern.rs
+++ b/crates/ide_completion/src/completions/pattern.rs
@@ -26,11 +26,11 @@ pub(crate) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) {
26 let add_resolution = match &res { 26 let add_resolution = match &res {
27 hir::ScopeDef::ModuleDef(def) => match def { 27 hir::ScopeDef::ModuleDef(def) => match def {
28 hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => { 28 hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => {
29 acc.add_struct_pat(ctx, strukt.clone(), Some(name.clone())); 29 acc.add_struct_pat(ctx, *strukt, Some(name.clone()));
30 true 30 true
31 } 31 }
32 hir::ModuleDef::Variant(variant) if !ctx.is_irrefutable_pat_binding => { 32 hir::ModuleDef::Variant(variant) if !ctx.is_irrefutable_pat_binding => {
33 acc.add_variant_pat(ctx, variant.clone(), Some(name.clone())); 33 acc.add_variant_pat(ctx, *variant, Some(name.clone()));
34 true 34 true
35 } 35 }
36 hir::ModuleDef::Adt(hir::Adt::Enum(..)) 36 hir::ModuleDef::Adt(hir::Adt::Enum(..))
diff --git a/crates/ide_completion/src/completions/postfix/format_like.rs b/crates/ide_completion/src/completions/postfix/format_like.rs
index cee4eec10..3f1c6730b 100644
--- a/crates/ide_completion/src/completions/postfix/format_like.rs
+++ b/crates/ide_completion/src/completions/postfix/format_like.rs
@@ -89,7 +89,7 @@ enum State {
89impl FormatStrParser { 89impl FormatStrParser {
90 pub(crate) fn new(input: String) -> Self { 90 pub(crate) fn new(input: String) -> Self {
91 Self { 91 Self {
92 input: input.into(), 92 input: input,
93 output: String::new(), 93 output: String::new(),
94 extracted_expressions: Vec::new(), 94 extracted_expressions: Vec::new(),
95 state: State::NotExpr, 95 state: State::NotExpr,
diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs
index 4e4923e0d..12921e12b 100644
--- a/crates/ide_completion/src/render.rs
+++ b/crates/ide_completion/src/render.rs
@@ -81,7 +81,7 @@ impl<'a> RenderContext<'a> {
81 } 81 }
82 82
83 fn snippet_cap(&self) -> Option<SnippetCap> { 83 fn snippet_cap(&self) -> Option<SnippetCap> {
84 self.completion.config.snippet_cap.clone() 84 self.completion.config.snippet_cap
85 } 85 }
86 86
87 fn db(&self) -> &'a RootDatabase { 87 fn db(&self) -> &'a RootDatabase {
diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs
index f86e5ce93..75167ff39 100644
--- a/crates/ide_db/src/defs.rs
+++ b/crates/ide_db/src/defs.rs
@@ -181,7 +181,7 @@ impl NameClass {
181 }, 181 },
182 ast::SelfParam(it) => { 182 ast::SelfParam(it) => {
183 let def = sema.to_def(&it)?; 183 let def = sema.to_def(&it)?;
184 Some(NameClass::Definition(Definition::Local(def.into()))) 184 Some(NameClass::Definition(Definition::Local(def)))
185 }, 185 },
186 ast::RecordField(it) => { 186 ast::RecordField(it) => {
187 let field: hir::Field = sema.to_def(&it)?; 187 let field: hir::Field = sema.to_def(&it)?;
diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs
index df66d8ea0..9e0cb91c3 100644
--- a/crates/ide_db/src/helpers/insert_use.rs
+++ b/crates/ide_db/src/helpers/insert_use.rs
@@ -80,7 +80,7 @@ impl ImportScope {
80 }) 80 })
81 .last() 81 .last()
82 .map(|last_inner_element| { 82 .map(|last_inner_element| {
83 (InsertPosition::After(last_inner_element.into()), AddBlankLine::BeforeTwice) 83 (InsertPosition::After(last_inner_element), AddBlankLine::BeforeTwice)
84 }) 84 })
85 .unwrap_or_else(|| self.first_insert_pos()) 85 .unwrap_or_else(|| self.first_insert_pos())
86 } 86 }
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs
index f56221a6c..324817cd0 100644
--- a/crates/ide_db/src/search.rs
+++ b/crates/ide_db/src/search.rs
@@ -161,15 +161,9 @@ impl Definition {
161 161
162 if let Definition::Local(var) = self { 162 if let Definition::Local(var) = self {
163 let range = match var.parent(db) { 163 let range = match var.parent(db) {
164 DefWithBody::Function(f) => { 164 DefWithBody::Function(f) => f.source(db).map(|src| src.value.syntax().text_range()),
165 f.source(db).and_then(|src| Some(src.value.syntax().text_range())) 165 DefWithBody::Const(c) => c.source(db).map(|src| src.value.syntax().text_range()),
166 } 166 DefWithBody::Static(s) => s.source(db).map(|src| src.value.syntax().text_range()),
167 DefWithBody::Const(c) => {
168 c.source(db).and_then(|src| Some(src.value.syntax().text_range()))
169 }
170 DefWithBody::Static(s) => {
171 s.source(db).and_then(|src| Some(src.value.syntax().text_range()))
172 }
173 }; 167 };
174 let mut res = FxHashMap::default(); 168 let mut res = FxHashMap::default();
175 res.insert(file_id, range); 169 res.insert(file_id, range);
@@ -179,33 +173,29 @@ impl Definition {
179 if let Definition::GenericParam(hir::GenericParam::LifetimeParam(param)) = self { 173 if let Definition::GenericParam(hir::GenericParam::LifetimeParam(param)) = self {
180 let range = match param.parent(db) { 174 let range = match param.parent(db) {
181 hir::GenericDef::Function(it) => { 175 hir::GenericDef::Function(it) => {
182 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 176 it.source(db).map(|src| src.value.syntax().text_range())
183 } 177 }
184 hir::GenericDef::Adt(it) => match it { 178 hir::GenericDef::Adt(it) => match it {
185 hir::Adt::Struct(it) => { 179 hir::Adt::Struct(it) => {
186 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 180 it.source(db).map(|src| src.value.syntax().text_range())
187 }
188 hir::Adt::Union(it) => {
189 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
190 }
191 hir::Adt::Enum(it) => {
192 it.source(db).and_then(|src| Some(src.value.syntax().text_range()))
193 } 181 }
182 hir::Adt::Union(it) => it.source(db).map(|src| src.value.syntax().text_range()),
183 hir::Adt::Enum(it) => it.source(db).map(|src| src.value.syntax().text_range()),
194 }, 184 },
195 hir::GenericDef::Trait(it) => { 185 hir::GenericDef::Trait(it) => {
196 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 186 it.source(db).map(|src| src.value.syntax().text_range())
197 } 187 }
198 hir::GenericDef::TypeAlias(it) => { 188 hir::GenericDef::TypeAlias(it) => {
199 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 189 it.source(db).map(|src| src.value.syntax().text_range())
200 } 190 }
201 hir::GenericDef::Impl(it) => { 191 hir::GenericDef::Impl(it) => {
202 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 192 it.source(db).map(|src| src.value.syntax().text_range())
203 } 193 }
204 hir::GenericDef::Variant(it) => { 194 hir::GenericDef::Variant(it) => {
205 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 195 it.source(db).map(|src| src.value.syntax().text_range())
206 } 196 }
207 hir::GenericDef::Const(it) => { 197 hir::GenericDef::Const(it) => {
208 it.source(db).and_then(|src| Some(src.value.syntax().text_range())) 198 it.source(db).map(|src| src.value.syntax().text_range())
209 } 199 }
210 }; 200 };
211 let mut res = FxHashMap::default(); 201 let mut res = FxHashMap::default();
diff --git a/crates/ide_ssr/src/lib.rs b/crates/ide_ssr/src/lib.rs
index 00585f448..47434f4af 100644
--- a/crates/ide_ssr/src/lib.rs
+++ b/crates/ide_ssr/src/lib.rs
@@ -139,11 +139,8 @@ impl<'db> MatchFinder<'db> {
139 pub fn at_first_file(db: &'db ide_db::RootDatabase) -> Result<MatchFinder<'db>, SsrError> { 139 pub fn at_first_file(db: &'db ide_db::RootDatabase) -> Result<MatchFinder<'db>, SsrError> {
140 use ide_db::base_db::SourceDatabaseExt; 140 use ide_db::base_db::SourceDatabaseExt;
141 use ide_db::symbol_index::SymbolsDatabase; 141 use ide_db::symbol_index::SymbolsDatabase;
142 if let Some(first_file_id) = db 142 if let Some(first_file_id) =
143 .local_roots() 143 db.local_roots().iter().next().and_then(|root| db.source_root(*root).iter().next())
144 .iter()
145 .next()
146 .and_then(|root| db.source_root(root.clone()).iter().next())
147 { 144 {
148 Ok(MatchFinder::in_context( 145 Ok(MatchFinder::in_context(
149 db, 146 db,
diff --git a/crates/ide_ssr/src/matching.rs b/crates/ide_ssr/src/matching.rs
index e1adb381e..b3072fb9f 100644
--- a/crates/ide_ssr/src/matching.rs
+++ b/crates/ide_ssr/src/matching.rs
@@ -127,7 +127,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
127 restrict_range: &Option<FileRange>, 127 restrict_range: &Option<FileRange>,
128 sema: &'sema Semantics<'db, ide_db::RootDatabase>, 128 sema: &'sema Semantics<'db, ide_db::RootDatabase>,
129 ) -> Result<Match, MatchFailed> { 129 ) -> Result<Match, MatchFailed> {
130 let match_state = Matcher { sema, restrict_range: restrict_range.clone(), rule }; 130 let match_state = Matcher { sema, restrict_range: *restrict_range, rule };
131 // First pass at matching, where we check that node types and idents match. 131 // First pass at matching, where we check that node types and idents match.
132 match_state.attempt_match_node(&mut Phase::First, &rule.pattern.node, code)?; 132 match_state.attempt_match_node(&mut Phase::First, &rule.pattern.node, code)?;
133 match_state.validate_range(&sema.original_range(code))?; 133 match_state.validate_range(&sema.original_range(code))?;
diff --git a/crates/mbe/src/benchmark.rs b/crates/mbe/src/benchmark.rs
index 503ad1355..ba814a2e1 100644
--- a/crates/mbe/src/benchmark.rs
+++ b/crates/mbe/src/benchmark.rs
@@ -120,7 +120,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt
120 Some("pat") => parent.token_trees.push(make_ident("foo")), 120 Some("pat") => parent.token_trees.push(make_ident("foo")),
121 Some("path") => parent.token_trees.push(make_ident("foo")), 121 Some("path") => parent.token_trees.push(make_ident("foo")),
122 Some("literal") => parent.token_trees.push(make_literal("1")), 122 Some("literal") => parent.token_trees.push(make_literal("1")),
123 Some("expr") => parent.token_trees.push(make_ident("foo").into()), 123 Some("expr") => parent.token_trees.push(make_ident("foo")),
124 Some("lifetime") => { 124 Some("lifetime") => {
125 parent.token_trees.push(make_punct('\'')); 125 parent.token_trees.push(make_punct('\''));
126 parent.token_trees.push(make_ident("a")); 126 parent.token_trees.push(make_ident("a"));
@@ -157,17 +157,15 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt
157 if i + 1 != cnt { 157 if i + 1 != cnt {
158 if let Some(sep) = separator { 158 if let Some(sep) = separator {
159 match sep { 159 match sep {
160 Separator::Literal(it) => parent 160 Separator::Literal(it) => {
161 .token_trees 161 parent.token_trees.push(tt::Leaf::Literal(it.clone()).into())
162 .push(tt::Leaf::Literal(it.clone().into()).into()), 162 }
163 Separator::Ident(it) => parent 163 Separator::Ident(it) => {
164 .token_trees 164 parent.token_trees.push(tt::Leaf::Ident(it.clone()).into())
165 .push(tt::Leaf::Ident(it.clone().into()).into()), 165 }
166 Separator::Puncts(puncts) => { 166 Separator::Puncts(puncts) => {
167 for it in puncts { 167 for it in puncts {
168 parent 168 parent.token_trees.push(tt::Leaf::Punct(*it).into())
169 .token_trees
170 .push(tt::Leaf::Punct(it.clone().into()).into())
171 } 169 }
172 } 170 }
173 }; 171 };
@@ -176,8 +174,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt
176 } 174 }
177 } 175 }
178 Op::Subtree { tokens, delimiter } => { 176 Op::Subtree { tokens, delimiter } => {
179 let mut subtree = 177 let mut subtree = tt::Subtree { delimiter: *delimiter, token_trees: Vec::new() };
180 tt::Subtree { delimiter: delimiter.clone(), token_trees: Vec::new() };
181 tokens.iter().for_each(|it| { 178 tokens.iter().for_each(|it| {
182 collect_from_op(it, &mut subtree, seed); 179 collect_from_op(it, &mut subtree, seed);
183 }); 180 });
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs
index 2c69e8968..b6782b4ba 100644
--- a/crates/mbe/src/expander/matcher.rs
+++ b/crates/mbe/src/expander/matcher.rs
@@ -540,7 +540,7 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match {
540 let mut src = TtIter::new(src); 540 let mut src = TtIter::new(src);
541 let mut stack: SmallVec<[TtIter; 1]> = SmallVec::new(); 541 let mut stack: SmallVec<[TtIter; 1]> = SmallVec::new();
542 let mut res = Match::default(); 542 let mut res = Match::default();
543 let mut error_reover_item = None; 543 let mut error_recover_item = None;
544 544
545 let mut bindings_builder = BindingsBuilder::default(); 545 let mut bindings_builder = BindingsBuilder::default();
546 546
@@ -579,9 +579,9 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match {
579 stdx::always!(cur_items.is_empty()); 579 stdx::always!(cur_items.is_empty());
580 580
581 if error_items.len() > 0 { 581 if error_items.len() > 0 {
582 error_reover_item = error_items.pop().map(|it| it.bindings); 582 error_recover_item = error_items.pop().map(|it| it.bindings);
583 } else if eof_items.len() > 0 { 583 } else if eof_items.len() > 0 {
584 error_reover_item = Some(eof_items[0].bindings.clone()); 584 error_recover_item = Some(eof_items[0].bindings.clone());
585 } 585 }
586 586
587 // We need to do some post processing after the `match_loop_inner`. 587 // We need to do some post processing after the `match_loop_inner`.
@@ -594,8 +594,8 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match {
594 res.bindings = bindings_builder.build(&eof_items[0].bindings); 594 res.bindings = bindings_builder.build(&eof_items[0].bindings);
595 } else { 595 } else {
596 // Error recovery 596 // Error recovery
597 if error_reover_item.is_some() { 597 if let Some(item) = error_recover_item {
598 res.bindings = bindings_builder.build(&error_reover_item.unwrap()); 598 res.bindings = bindings_builder.build(&item);
599 } 599 }
600 res.add_err(ExpandError::UnexpectedToken); 600 res.add_err(ExpandError::UnexpectedToken);
601 } 601 }
@@ -618,7 +618,7 @@ fn match_loop(pattern: &MetaTemplate, src: &tt::Subtree) -> Match {
618 } 618 }
619 res.add_err(err!("leftover tokens")); 619 res.add_err(err!("leftover tokens"));
620 620
621 if let Some(error_reover_item) = error_reover_item { 621 if let Some(error_reover_item) = error_recover_item {
622 res.bindings = bindings_builder.build(&error_reover_item); 622 res.bindings = bindings_builder.build(&error_reover_item);
623 } 623 }
624 return res; 624 return res;
@@ -722,7 +722,7 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
722 input 722 input
723 .expect_literal() 723 .expect_literal()
724 .map(|literal| { 724 .map(|literal| {
725 let lit = tt::Leaf::from(literal.clone()); 725 let lit = literal.clone();
726 match neg { 726 match neg {
727 None => Some(lit.into()), 727 None => Some(lit.into()),
728 Some(neg) => Some(tt::TokenTree::Subtree(tt::Subtree { 728 Some(neg) => Some(tt::TokenTree::Subtree(tt::Subtree {
diff --git a/crates/mbe/src/parser.rs b/crates/mbe/src/parser.rs
index 8671322e1..7b5b8ec16 100644
--- a/crates/mbe/src/parser.rs
+++ b/crates/mbe/src/parser.rs
@@ -262,7 +262,7 @@ fn parse_repeat(src: &mut TtIter) -> Result<(Option<Separator>, RepeatKind), Par
262 if puncts.len() == 3 { 262 if puncts.len() == 3 {
263 return Err(ParseError::InvalidRepeat); 263 return Err(ParseError::InvalidRepeat);
264 } 264 }
265 puncts.push(punct.clone()) 265 puncts.push(*punct)
266 } 266 }
267 _ => return Err(ParseError::InvalidRepeat), 267 _ => return Err(ParseError::InvalidRepeat),
268 } 268 }
diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs
index b715ebfc4..85163c4b3 100644
--- a/crates/mbe/src/syntax_bridge.rs
+++ b/crates/mbe/src/syntax_bridge.rs
@@ -130,7 +130,7 @@ pub fn parse_exprs_with_sep(tt: &tt::Subtree, sep: char) -> Vec<tt::Subtree> {
130 res.push(match expanded.value { 130 res.push(match expanded.value {
131 None => break, 131 None => break,
132 Some(tt @ tt::TokenTree::Leaf(_)) => { 132 Some(tt @ tt::TokenTree::Leaf(_)) => {
133 tt::Subtree { delimiter: None, token_trees: vec![tt.into()] } 133 tt::Subtree { delimiter: None, token_trees: vec![tt] }
134 } 134 }
135 Some(tt::TokenTree::Subtree(tt)) => tt, 135 Some(tt::TokenTree::Subtree(tt)) => tt,
136 }); 136 });
@@ -727,7 +727,7 @@ impl<'a> TreeSink for TtTreeSink<'a> {
727 // Note: We always assume the semi-colon would be the last token in 727 // Note: We always assume the semi-colon would be the last token in
728 // other parts of RA such that we don't add whitespace here. 728 // other parts of RA such that we don't add whitespace here.
729 if curr.spacing == tt::Spacing::Alone && curr.char != ';' { 729 if curr.spacing == tt::Spacing::Alone && curr.char != ';' {
730 self.inner.token(WHITESPACE, " ".into()); 730 self.inner.token(WHITESPACE, " ");
731 self.text_pos += TextSize::of(' '); 731 self.text_pos += TextSize::of(' ');
732 } 732 }
733 } 733 }
diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs
index eca0bcc18..25c374b9b 100644
--- a/crates/mbe/src/tests.rs
+++ b/crates/mbe/src/tests.rs
@@ -35,7 +35,7 @@ mod rule_parsing {
35 fn test_invalid_arms() { 35 fn test_invalid_arms() {
36 fn check(macro_body: &str, err: ParseError) { 36 fn check(macro_body: &str, err: ParseError) {
37 let m = parse_macro_arm(macro_body); 37 let m = parse_macro_arm(macro_body);
38 assert_eq!(m, Err(err.into())); 38 assert_eq!(m, Err(err));
39 } 39 }
40 check("invalid", ParseError::Expected("expected subtree".into())); 40 check("invalid", ParseError::Expected("expected subtree".into()));
41 41
diff --git a/crates/proc_macro_api/src/process.rs b/crates/proc_macro_api/src/process.rs
index 3ce851fe8..30bb1b687 100644
--- a/crates/proc_macro_api/src/process.rs
+++ b/crates/proc_macro_api/src/process.rs
@@ -154,5 +154,5 @@ fn send_request(
154 req: Request, 154 req: Request,
155) -> io::Result<Option<Response>> { 155) -> io::Result<Option<Response>> {
156 req.write(&mut writer)?; 156 req.write(&mut writer)?;
157 Ok(Response::read(&mut reader)?) 157 Response::read(&mut reader)
158} 158}
diff --git a/crates/proc_macro_api/src/rpc.rs b/crates/proc_macro_api/src/rpc.rs
index 64cfdafc5..9a68e2cc5 100644
--- a/crates/proc_macro_api/src/rpc.rs
+++ b/crates/proc_macro_api/src/rpc.rs
@@ -236,13 +236,10 @@ mod tests {
236 subtree 236 subtree
237 .token_trees 237 .token_trees
238 .push(TokenTree::Leaf(Ident { text: "Foo".into(), id: TokenId(1) }.into())); 238 .push(TokenTree::Leaf(Ident { text: "Foo".into(), id: TokenId(1) }.into()));
239 subtree.token_trees.push(TokenTree::Subtree( 239 subtree.token_trees.push(TokenTree::Subtree(Subtree {
240 Subtree { 240 delimiter: Some(Delimiter { id: TokenId(2), kind: DelimiterKind::Brace }),
241 delimiter: Some(Delimiter { id: TokenId(2), kind: DelimiterKind::Brace }), 241 token_trees: vec![],
242 token_trees: vec![], 242 }));
243 }
244 .into(),
245 ));
246 subtree 243 subtree
247 } 244 }
248 245
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs
index 0ad832c0e..76994de71 100644
--- a/crates/rust-analyzer/src/diagnostics/to_proto.rs
+++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs
@@ -161,7 +161,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
161 return Vec::new(); 161 return Vec::new();
162 } 162 }
163 163
164 let severity = diagnostic_severity(config, rd.level.clone(), rd.code.clone()); 164 let severity = diagnostic_severity(config, rd.level, rd.code.clone());
165 165
166 let mut source = String::from("rustc"); 166 let mut source = String::from("rustc");
167 let mut code = rd.code.as_ref().map(|c| c.code.clone()); 167 let mut code = rd.code.as_ref().map(|c| c.code.clone());
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 6fb7da79c..b6f484e51 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -1134,7 +1134,7 @@ pub(crate) fn handle_code_lens_resolve(
1134) -> Result<CodeLens> { 1134) -> Result<CodeLens> {
1135 let annotation = from_proto::annotation(&snap, code_lens)?; 1135 let annotation = from_proto::annotation(&snap, code_lens)?;
1136 1136
1137 Ok(to_proto::code_lens(&snap, snap.analysis.resolve_annotation(annotation)?)?) 1137 to_proto::code_lens(&snap, snap.analysis.resolve_annotation(annotation)?)
1138} 1138}
1139 1139
1140pub(crate) fn handle_document_highlight( 1140pub(crate) fn handle_document_highlight(
diff --git a/crates/rust-analyzer/src/lsp_utils.rs b/crates/rust-analyzer/src/lsp_utils.rs
index 3ca7f8040..2ac487632 100644
--- a/crates/rust-analyzer/src/lsp_utils.rs
+++ b/crates/rust-analyzer/src/lsp_utils.rs
@@ -36,7 +36,7 @@ impl Progress {
36 36
37impl GlobalState { 37impl GlobalState {
38 pub(crate) fn show_message(&mut self, typ: lsp_types::MessageType, message: String) { 38 pub(crate) fn show_message(&mut self, typ: lsp_types::MessageType, message: String) {
39 let message = message.into(); 39 let message = message;
40 self.send_notification::<lsp_types::notification::ShowMessage>( 40 self.send_notification::<lsp_types::notification::ShowMessage>(
41 lsp_types::ShowMessageParams { typ, message }, 41 lsp_types::ShowMessageParams { typ, message },
42 ) 42 )
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 70eaae5e8..c63fe2915 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -287,7 +287,7 @@ pub(crate) fn signature_help(
287 let params = call_info 287 let params = call_info
288 .parameter_ranges() 288 .parameter_ranges()
289 .iter() 289 .iter()
290 .map(|it| [u32::from(it.start()).into(), u32::from(it.end()).into()]) 290 .map(|it| [u32::from(it.start()), u32::from(it.end())])
291 .map(|label_offsets| lsp_types::ParameterInformation { 291 .map(|label_offsets| lsp_types::ParameterInformation {
292 label: lsp_types::ParameterLabel::LabelOffsets(label_offsets), 292 label: lsp_types::ParameterLabel::LabelOffsets(label_offsets),
293 documentation: None, 293 documentation: None,
diff --git a/crates/syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs
index 0b3b76d4a..64fac13a7 100644
--- a/crates/syntax/src/ast/edit.rs
+++ b/crates/syntax/src/ast/edit.rs
@@ -479,7 +479,7 @@ impl ast::MatchArmList {
479 Some(t) => t, 479 Some(t) => t,
480 None => return self.clone(), 480 None => return self.clone(),
481 }; 481 };
482 let position = InsertPosition::Before(r_curly.into()); 482 let position = InsertPosition::Before(r_curly);
483 let arm_ws = tokens::WsBuilder::new(" "); 483 let arm_ws = tokens::WsBuilder::new(" ");
484 let match_indent = &leading_indent(self.syntax()).unwrap_or_default(); 484 let match_indent = &leading_indent(self.syntax()).unwrap_or_default();
485 let match_ws = tokens::WsBuilder::new(&format!("\n{}", match_indent)); 485 let match_ws = tokens::WsBuilder::new(&format!("\n{}", match_indent));
diff --git a/crates/syntax/src/ted.rs b/crates/syntax/src/ted.rs
index 76f950ef9..442dfa14a 100644
--- a/crates/syntax/src/ted.rs
+++ b/crates/syntax/src/ted.rs
@@ -122,5 +122,5 @@ fn ws_between(left: &SyntaxElement, right: &SyntaxElement) -> Option<SyntaxToken
122 if right.kind() == T![;] || right.kind() == T![,] { 122 if right.kind() == T![;] || right.kind() == T![,] {
123 return None; 123 return None;
124 } 124 }
125 Some(make::tokens::single_space().into()) 125 Some(make::tokens::single_space())
126} 126}