avoid converting types into themselves via .into() (clippy::useless-conversion)

example: let x: String = String::from("hello world").into();
This commit is contained in:
Matthias Krüger 2021-03-17 01:27:56 +01:00
parent 83e6940efb
commit 966c23f529
24 changed files with 56 additions and 61 deletions

View file

@ -1335,7 +1335,7 @@ impl Local {
// FIXME: why is this an option? It shouldn't be?
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
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<Either<ast::IdentPat, ast::SelfParam>> {
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<ast::Label> {
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))