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/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/hir/src/lib.rs') 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)) -- cgit v1.2.3