From 6cc6dee9e96d55dbbd8593523551a9981a691147 Mon Sep 17 00:00:00 2001 From: Maan2003 Date: Sun, 13 Jun 2021 09:25:55 +0530 Subject: clippy::useless_conversion --- crates/hir_def/src/item_tree/pretty.rs | 2 +- crates/hir_def/src/lib.rs | 9 +++------ crates/hir_def/src/test_db.rs | 2 +- crates/hir_expand/src/builtin_derive.rs | 2 +- crates/hir_expand/src/builtin_macro.rs | 8 ++++---- crates/hir_expand/src/db.rs | 2 +- crates/hir_expand/src/eager.rs | 8 +++----- crates/hir_ty/src/builder.rs | 2 +- xtask/src/codegen/gen_lint_completions.rs | 3 +-- 9 files changed, 16 insertions(+), 22 deletions(-) diff --git a/crates/hir_def/src/item_tree/pretty.rs b/crates/hir_def/src/item_tree/pretty.rs index cc9944a22..b1e1b70d0 100644 --- a/crates/hir_def/src/item_tree/pretty.rs +++ b/crates/hir_def/src/item_tree/pretty.rs @@ -426,7 +426,7 @@ impl<'a> Printer<'a> { w!(self, " {{"); self.indented(|this| { for item in &**items { - this.print_mod_item((*item).into()); + this.print_mod_item(*item); } }); wln!(self, "}}"); diff --git a/crates/hir_def/src/lib.rs b/crates/hir_def/src/lib.rs index 987485acc..3e7d496d5 100644 --- a/crates/hir_def/src/lib.rs +++ b/crates/hir_def/src/lib.rs @@ -736,8 +736,7 @@ fn macro_call_as_call_id( db.upcast(), krate, MacroCallKind::FnLike { ast_id: call.ast_id, fragment }, - ) - .into()) + )) }; Ok(res) } @@ -765,8 +764,7 @@ fn derive_macro_as_call_id( derive_name: last_segment.to_string(), derive_attr_index: derive_attr.ast_index, }, - ) - .into(); + ); Ok(res) } @@ -804,7 +802,6 @@ fn attr_macro_as_call_id( attr_args: arg, invoc_attr_index: macro_attr.id.ast_index, }, - ) - .into(); + ); Ok(res) } diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs index b20b066e2..a16203fdb 100644 --- a/crates/hir_def/src/test_db.rs +++ b/crates/hir_def/src/test_db.rs @@ -325,7 +325,7 @@ impl TestDB { for diag in source_map.diagnostics() { let (ptr, message): (InFile, &str) = match diag { BodyDiagnostic::InactiveCode { node, .. } => { - (node.clone().map(|it| it.into()), "InactiveCode") + (node.clone().map(|it| it), "InactiveCode") } BodyDiagnostic::MacroError { node, message } => { (node.clone().map(|it| it.into()), message.as_str()) diff --git a/crates/hir_expand/src/builtin_derive.rs b/crates/hir_expand/src/builtin_derive.rs index fe9497b50..4610f6f91 100644 --- a/crates/hir_expand/src/builtin_derive.rs +++ b/crates/hir_expand/src/builtin_derive.rs @@ -325,7 +325,7 @@ $0 }, }; - let id: MacroCallId = db.intern_macro(loc).into(); + let id: MacroCallId = db.intern_macro(loc); let parsed = db.parse_or_expand(id.as_file()).unwrap(); // FIXME text() for syntax nodes parsed from token tree looks weird diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs index 51572226e..f24d1d919 100644 --- a/crates/hir_expand/src/builtin_macro.rs +++ b/crates/hir_expand/src/builtin_macro.rs @@ -430,7 +430,7 @@ fn include_expand( ) -> ExpandResult> { let res = (|| { let path = parse_string(tt)?; - let file_id = relative_file(db, arg_id.into(), &path, false)?; + let file_id = relative_file(db, arg_id, &path, false)?; let subtree = parse_to_token_tree(&db.file_text(file_id)) .ok_or_else(|| mbe::ExpandError::ConversionError)? @@ -480,7 +480,7 @@ fn include_str_expand( // it's unusual to `include_str!` a Rust file), but we can return an empty string. // Ideally, we'd be able to offer a precise expansion if the user asks for macro // expansion. - let file_id = match relative_file(db, arg_id.into(), &path, true) { + let file_id = match relative_file(db, arg_id, &path, true) { Ok(file_id) => file_id, Err(_) => { return ExpandResult::ok(Some(ExpandedEager::new(quote!("")))); @@ -598,7 +598,7 @@ mod tests { }, }; - let id: MacroCallId = db.intern_macro(loc).into(); + let id: MacroCallId = db.intern_macro(loc); id.as_file() } Either::Right(expander) => { @@ -635,7 +635,7 @@ mod tests { kind: MacroCallKind::FnLike { ast_id: call_id, fragment }, }; - let id: MacroCallId = db.intern_macro(loc).into(); + let id: MacroCallId = db.intern_macro(loc); id.as_file() } }; diff --git a/crates/hir_expand/src/db.rs b/crates/hir_expand/src/db.rs index 45e6e446a..4aecf4af5 100644 --- a/crates/hir_expand/src/db.rs +++ b/crates/hir_expand/src/db.rs @@ -57,7 +57,7 @@ impl TokenExpander { // We store the result in salsa db to prevent non-deterministic behavior in // some proc-macro implementation // See #4315 for details - db.expand_proc_macro(id.into()).into() + db.expand_proc_macro(id).into() } } } diff --git a/crates/hir_expand/src/eager.rs b/crates/hir_expand/src/eager.rs index 9093255f4..07799ed2f 100644 --- a/crates/hir_expand/src/eager.rs +++ b/crates/hir_expand/src/eager.rs @@ -128,7 +128,7 @@ pub fn expand_eager_macro( }), kind: MacroCallKind::FnLike { ast_id: call_id, fragment: FragmentKind::Expr }, }); - let arg_file_id: MacroCallId = arg_id.into(); + let arg_file_id: MacroCallId = arg_id; let parsed_args = diagnostic_sink.result(mbe::token_tree_to_syntax_node(&parsed_args, FragmentKind::Expr))?.0; @@ -182,8 +182,7 @@ fn lazy_expand( db, krate, MacroCallKind::FnLike { ast_id: macro_call.with_value(ast_id), fragment }, - ) - .into(); + ); let err = db.macro_expand_error(id); let value = db.parse_or_expand(id.as_file()).map(|node| InFile::new(id.as_file(), node)); @@ -216,8 +215,7 @@ fn eager_macro_recur( def, macro_resolver, diagnostic_sink, - )? - .into(); + )?; db.parse_or_expand(id.as_file()) .expect("successful macro expansion should be parseable") .clone_for_update() diff --git a/crates/hir_ty/src/builder.rs b/crates/hir_ty/src/builder.rs index 893e727c2..bb9d84246 100644 --- a/crates/hir_ty/src/builder.rs +++ b/crates/hir_ty/src/builder.rs @@ -202,7 +202,7 @@ impl + Fold> TyBuilder> impl TyBuilder> { pub fn def_ty(db: &dyn HirDatabase, def: TyDefId) -> TyBuilder> { - TyBuilder::subst_binders(db.ty(def.into())) + TyBuilder::subst_binders(db.ty(def)) } pub fn impl_self_ty(db: &dyn HirDatabase, def: hir_def::ImplId) -> TyBuilder> { diff --git a/xtask/src/codegen/gen_lint_completions.rs b/xtask/src/codegen/gen_lint_completions.rs index 4aebb02bd..54fcaa0e6 100644 --- a/xtask/src/codegen/gen_lint_completions.rs +++ b/xtask/src/codegen/gen_lint_completions.rs @@ -140,8 +140,7 @@ fn generate_descriptor_clippy(buf: &mut String, path: &Path) -> Result<()> { .expect("should be prefixed by what it does") .strip_suffix(suffix_to_strip) .map(unescape) - .expect("should be suffixed by comma") - .into(); + .expect("should be suffixed by comma"); } } clippy_lints.sort_by(|lint, lint2| lint.id.cmp(&lint2.id)); -- cgit v1.2.3