From 966c23f5290275ce17564f6027a17ec20cd6078f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 17 Mar 2021 01:27:56 +0100 Subject: avoid converting types into themselves via .into() (clippy::useless-conversion) example: let x: String = String::from("hello world").into(); --- crates/hir/src/attrs.rs | 2 +- crates/hir/src/lib.rs | 12 ++++++------ crates/hir/src/semantics.rs | 2 +- crates/hir/src/source_analyzer.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/hir/src') 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( Some(Namespace::Macros) => return None, None => resolved.iter_items().find_map(|it| it.as_module_def_id())?, }; - Some(def.into()) + Some(def) } 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 { // FIXME: why is this an option? It shouldn't be? pub fn name(self, db: &dyn HirDatabase) -> Option { - let body = db.body(self.parent.into()); + let body = db.body(self.parent); match &body[self.pat_id] { Pat::Bind { name, .. } => Some(name.clone()), _ => None, @@ -1347,7 +1347,7 @@ impl Local { } pub fn is_mut(self, db: &dyn HirDatabase) -> bool { - let body = db.body(self.parent.into()); + let body = db.body(self.parent); matches!(&body[self.pat_id], Pat::Bind { mode: BindingAnnotation::Mutable, .. }) } @@ -1360,7 +1360,7 @@ impl Local { } pub fn ty(self, db: &dyn HirDatabase) -> Type { - let def = DefWithBodyId::from(self.parent); + let def = self.parent; let infer = db.infer(def); let ty = infer[self.pat_id].clone(); let krate = def.module(db.upcast()).krate(); @@ -1368,7 +1368,7 @@ impl Local { } pub fn source(self, db: &dyn HirDatabase) -> InFile> { - let (_body, source_map) = db.body_with_source_map(self.parent.into()); + let (_body, source_map) = db.body_with_source_map(self.parent); let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm... let root = src.file_syntax(db.upcast()); src.map(|ast| { @@ -1393,12 +1393,12 @@ impl Label { } pub fn name(self, db: &dyn HirDatabase) -> Name { - let body = db.body(self.parent.into()); + let body = db.body(self.parent); body[self.label_id].name.clone() } pub fn source(self, db: &dyn HirDatabase) -> InFile { - let (_body, source_map) = db.body_with_source_map(self.parent.into()); + let (_body, source_map) = db.body_with_source_map(self.parent); let src = source_map.label_syntax(self.label_id); let root = src.file_syntax(db.upcast()); 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> { resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(id.into()), resolver::ScopeDef::Local(pat_id) => { - let parent = resolver.body_owner().unwrap().into(); + let parent = resolver.body_owner().unwrap(); ScopeDef::Local(Local { parent, pat_id }) } }; 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_( resolver.resolve_path_in_value_ns_fully(db.upcast(), path.mod_path()).and_then(|val| { let res = match val { ValueNs::LocalBinding(pat_id) => { - let var = Local { parent: body_owner?.into(), pat_id }; + let var = Local { parent: body_owner?, pat_id }; PathResolution::Local(var) } ValueNs::FunctionId(it) => PathResolution::Def(Function::from(it).into()), -- cgit v1.2.3