mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
Use statics + clone instead of const until const can access statics
This commit is contained in:
parent
dd626e78c7
commit
f2d51073d2
49 changed files with 389 additions and 362 deletions
|
@ -366,7 +366,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) =>
|
||||
if alias.name(db) == Name::new_symbol_root(sym::IntoFuture.clone()) =>
|
||||
{
|
||||
Some(alias)
|
||||
}
|
||||
|
@ -395,8 +395,11 @@ 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))?;
|
||||
let (deref_trait, deref) = self.lang_trait_fn(
|
||||
db,
|
||||
LangItem::Deref,
|
||||
&Name::new_symbol_root(sym::deref.clone()),
|
||||
)?;
|
||||
self.infer
|
||||
.as_ref()
|
||||
.and_then(|infer| {
|
||||
|
@ -405,7 +408,7 @@ impl SourceAnalyzer {
|
|||
let (deref_mut_trait, deref_mut) = self.lang_trait_fn(
|
||||
db,
|
||||
LangItem::DerefMut,
|
||||
&Name::new_symbol_root(sym::deref_mut),
|
||||
&Name::new_symbol_root(sym::deref_mut.clone()),
|
||||
)?;
|
||||
if func == deref_mut {
|
||||
Some((deref_mut_trait, deref_mut))
|
||||
|
@ -416,10 +419,10 @@ impl SourceAnalyzer {
|
|||
.unwrap_or((deref_trait, deref))
|
||||
}
|
||||
ast::UnaryOp::Not => {
|
||||
self.lang_trait_fn(db, LangItem::Not, &Name::new_symbol_root(sym::not))?
|
||||
self.lang_trait_fn(db, LangItem::Not, &Name::new_symbol_root(sym::not.clone()))?
|
||||
}
|
||||
ast::UnaryOp::Neg => {
|
||||
self.lang_trait_fn(db, LangItem::Neg, &Name::new_symbol_root(sym::neg))?
|
||||
self.lang_trait_fn(db, LangItem::Neg, &Name::new_symbol_root(sym::neg.clone()))?
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -441,7 +444,7 @@ impl SourceAnalyzer {
|
|||
let index_ty = self.ty_of_expr(db, &index_expr.index()?)?;
|
||||
|
||||
let (index_trait, index_fn) =
|
||||
self.lang_trait_fn(db, LangItem::Index, &Name::new_symbol_root(sym::index))?;
|
||||
self.lang_trait_fn(db, LangItem::Index, &Name::new_symbol_root(sym::index.clone()))?;
|
||||
let (op_trait, op_fn) = self
|
||||
.infer
|
||||
.as_ref()
|
||||
|
@ -451,7 +454,7 @@ impl SourceAnalyzer {
|
|||
let (index_mut_trait, index_mut_fn) = self.lang_trait_fn(
|
||||
db,
|
||||
LangItem::IndexMut,
|
||||
&Name::new_symbol_root(sym::index_mut),
|
||||
&Name::new_symbol_root(sym::index_mut.clone()),
|
||||
)?;
|
||||
if func == index_mut_fn {
|
||||
Some((index_mut_trait, index_mut_fn))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue