mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 05:13:35 +00:00
Remove unnecessary predefined symbol clones
Now that they're const it's no longer needed. Nothing manual was performed: only a regexp search of `sym::([\w][\w\d]*)\.clone\(\)` and replace by `sym::$1`.
This commit is contained in:
parent
9477e46bec
commit
0f325c7ff8
55 changed files with 312 additions and 361 deletions
|
|
@ -2056,7 +2056,7 @@ impl DefWithBody {
|
|||
continue;
|
||||
}
|
||||
let mut need_mut = &mol[local];
|
||||
if body[binding_id].name == sym::self_.clone()
|
||||
if body[binding_id].name == sym::self_
|
||||
&& need_mut == &mir::MutabilityReason::Unused
|
||||
{
|
||||
need_mut = &mir::MutabilityReason::Not;
|
||||
|
|
@ -3045,7 +3045,7 @@ pub struct StaticLifetime;
|
|||
|
||||
impl StaticLifetime {
|
||||
pub fn name(self) -> Name {
|
||||
Name::new_symbol_root(sym::tick_static.clone())
|
||||
Name::new_symbol_root(sym::tick_static)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3871,7 +3871,7 @@ impl Local {
|
|||
}
|
||||
|
||||
pub fn is_self(self, db: &dyn HirDatabase) -> bool {
|
||||
self.name(db) == sym::self_.clone()
|
||||
self.name(db) == sym::self_
|
||||
}
|
||||
|
||||
pub fn is_mut(self, db: &dyn HirDatabase) -> bool {
|
||||
|
|
@ -4987,9 +4987,8 @@ impl Type {
|
|||
return None;
|
||||
}
|
||||
|
||||
let output_assoc_type = db
|
||||
.trait_items(trait_)
|
||||
.associated_type_by_name(&Name::new_symbol_root(sym::Output.clone()))?;
|
||||
let output_assoc_type =
|
||||
db.trait_items(trait_).associated_type_by_name(&Name::new_symbol_root(sym::Output))?;
|
||||
self.normalize_trait_assoc_type(db, &[], output_assoc_type.into())
|
||||
}
|
||||
|
||||
|
|
@ -5005,7 +5004,7 @@ impl Type {
|
|||
let iterator_trait = db.lang_item(self.env.krate, LangItem::Iterator)?.as_trait()?;
|
||||
let iterator_item = db
|
||||
.trait_items(iterator_trait)
|
||||
.associated_type_by_name(&Name::new_symbol_root(sym::Item.clone()))?;
|
||||
.associated_type_by_name(&Name::new_symbol_root(sym::Item))?;
|
||||
self.normalize_trait_assoc_type(db, &[], iterator_item.into())
|
||||
}
|
||||
|
||||
|
|
@ -5037,7 +5036,7 @@ impl Type {
|
|||
|
||||
let into_iter_assoc_type = db
|
||||
.trait_items(trait_)
|
||||
.associated_type_by_name(&Name::new_symbol_root(sym::IntoIter.clone()))?;
|
||||
.associated_type_by_name(&Name::new_symbol_root(sym::IntoIter))?;
|
||||
self.normalize_trait_assoc_type(db, &[], into_iter_assoc_type.into())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2058,7 +2058,7 @@ impl SemanticsScope<'_> {
|
|||
ast::PathSegmentKind::Name(name_ref) => segments.push(name_ref.as_name()),
|
||||
ast::PathSegmentKind::Type { .. } => continue,
|
||||
ast::PathSegmentKind::SelfTypeKw => {
|
||||
segments.push(Name::new_symbol_root(sym::Self_.clone()))
|
||||
segments.push(Name::new_symbol_root(sym::Self_))
|
||||
}
|
||||
ast::PathSegmentKind::SelfKw => kind = PathKind::Super(0),
|
||||
ast::PathSegmentKind::SuperKw => match kind {
|
||||
|
|
|
|||
|
|
@ -540,7 +540,7 @@ impl SourceAnalyzer {
|
|||
let items = into_future_trait.items(db);
|
||||
let into_future_type = items.into_iter().find_map(|item| match item {
|
||||
AssocItem::TypeAlias(alias)
|
||||
if alias.name(db) == Name::new_symbol_root(sym::IntoFuture.clone()) =>
|
||||
if alias.name(db) == Name::new_symbol_root(sym::IntoFuture) =>
|
||||
{
|
||||
Some(alias)
|
||||
}
|
||||
|
|
@ -569,11 +569,8 @@ impl SourceAnalyzer {
|
|||
// This can be either `Deref::deref` or `DerefMut::deref_mut`.
|
||||
// Since deref kind is inferenced and stored in `InferenceResult.method_resolution`,
|
||||
// use that result to find out which one it is.
|
||||
let (deref_trait, deref) = self.lang_trait_fn(
|
||||
db,
|
||||
LangItem::Deref,
|
||||
&Name::new_symbol_root(sym::deref.clone()),
|
||||
)?;
|
||||
let (deref_trait, deref) =
|
||||
self.lang_trait_fn(db, LangItem::Deref, &Name::new_symbol_root(sym::deref))?;
|
||||
self.infer()
|
||||
.and_then(|infer| {
|
||||
let expr = self.expr_id(prefix_expr.clone().into())?.as_expr()?;
|
||||
|
|
@ -581,17 +578,17 @@ impl SourceAnalyzer {
|
|||
let (deref_mut_trait, deref_mut) = self.lang_trait_fn(
|
||||
db,
|
||||
LangItem::DerefMut,
|
||||
&Name::new_symbol_root(sym::deref_mut.clone()),
|
||||
&Name::new_symbol_root(sym::deref_mut),
|
||||
)?;
|
||||
if func == deref_mut { Some((deref_mut_trait, deref_mut)) } else { None }
|
||||
})
|
||||
.unwrap_or((deref_trait, deref))
|
||||
}
|
||||
ast::UnaryOp::Not => {
|
||||
self.lang_trait_fn(db, LangItem::Not, &Name::new_symbol_root(sym::not.clone()))?
|
||||
self.lang_trait_fn(db, LangItem::Not, &Name::new_symbol_root(sym::not))?
|
||||
}
|
||||
ast::UnaryOp::Neg => {
|
||||
self.lang_trait_fn(db, LangItem::Neg, &Name::new_symbol_root(sym::neg.clone()))?
|
||||
self.lang_trait_fn(db, LangItem::Neg, &Name::new_symbol_root(sym::neg))?
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -613,7 +610,7 @@ impl SourceAnalyzer {
|
|||
let index_ty = self.ty_of_expr(index_expr.index()?)?;
|
||||
|
||||
let (index_trait, index_fn) =
|
||||
self.lang_trait_fn(db, LangItem::Index, &Name::new_symbol_root(sym::index.clone()))?;
|
||||
self.lang_trait_fn(db, LangItem::Index, &Name::new_symbol_root(sym::index))?;
|
||||
let (op_trait, op_fn) = self
|
||||
.infer()
|
||||
.and_then(|infer| {
|
||||
|
|
@ -622,7 +619,7 @@ impl SourceAnalyzer {
|
|||
let (index_mut_trait, index_mut_fn) = self.lang_trait_fn(
|
||||
db,
|
||||
LangItem::IndexMut,
|
||||
&Name::new_symbol_root(sym::index_mut.clone()),
|
||||
&Name::new_symbol_root(sym::index_mut),
|
||||
)?;
|
||||
if func == index_mut_fn { Some((index_mut_trait, index_mut_fn)) } else { None }
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue