mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
avoid converting types into themselves via .into() (clippy::useless-conversion)
example: let x: String = String::from("hello world").into();
This commit is contained in:
parent
83e6940efb
commit
966c23f529
24 changed files with 56 additions and 61 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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 })
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue