mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Use Symbol in Name
This commit is contained in:
parent
843806b79f
commit
3fe815b0f3
75 changed files with 750 additions and 755 deletions
|
@ -25,11 +25,8 @@ use hir_def::{
|
|||
};
|
||||
use hir_expand::{
|
||||
mod_path::path,
|
||||
name::{AsName, Name},
|
||||
HirFileId, InFile, InMacroFile, MacroFileId, MacroFileIdExt,
|
||||
{
|
||||
name,
|
||||
name::{AsName, Name},
|
||||
},
|
||||
};
|
||||
use hir_ty::{
|
||||
diagnostics::{
|
||||
|
@ -40,6 +37,7 @@ use hir_ty::{
|
|||
method_resolution, Adjustment, InferenceResult, Interner, Substitution, Ty, TyExt, TyKind,
|
||||
TyLoweringContext,
|
||||
};
|
||||
use intern::sym;
|
||||
use itertools::Itertools;
|
||||
use smallvec::SmallVec;
|
||||
use syntax::{
|
||||
|
@ -368,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) == hir_expand::name![IntoFuture] =>
|
||||
if alias.name(db) == Name::new_symbol_root(sym::IntoFuture) =>
|
||||
{
|
||||
Some(alias)
|
||||
}
|
||||
|
@ -398,14 +396,17 @@ impl SourceAnalyzer {
|
|||
// 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![deref])?;
|
||||
self.lang_trait_fn(db, LangItem::Deref, &Name::new_symbol_root(sym::deref))?;
|
||||
self.infer
|
||||
.as_ref()
|
||||
.and_then(|infer| {
|
||||
let expr = self.expr_id(db, &prefix_expr.clone().into())?;
|
||||
let (func, _) = infer.method_resolution(expr)?;
|
||||
let (deref_mut_trait, deref_mut) =
|
||||
self.lang_trait_fn(db, LangItem::DerefMut, &name![deref_mut])?;
|
||||
let (deref_mut_trait, deref_mut) = self.lang_trait_fn(
|
||||
db,
|
||||
LangItem::DerefMut,
|
||||
&Name::new_symbol_root(sym::deref_mut),
|
||||
)?;
|
||||
if func == deref_mut {
|
||||
Some((deref_mut_trait, deref_mut))
|
||||
} else {
|
||||
|
@ -414,8 +415,12 @@ impl SourceAnalyzer {
|
|||
})
|
||||
.unwrap_or((deref_trait, deref))
|
||||
}
|
||||
ast::UnaryOp::Not => self.lang_trait_fn(db, LangItem::Not, &name![not])?,
|
||||
ast::UnaryOp::Neg => self.lang_trait_fn(db, LangItem::Neg, &name![neg])?,
|
||||
ast::UnaryOp::Not => {
|
||||
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))?
|
||||
}
|
||||
};
|
||||
|
||||
let ty = self.ty_of_expr(db, &prefix_expr.expr()?)?;
|
||||
|
@ -435,15 +440,19 @@ impl SourceAnalyzer {
|
|||
let base_ty = self.ty_of_expr(db, &index_expr.base()?)?;
|
||||
let index_ty = self.ty_of_expr(db, &index_expr.index()?)?;
|
||||
|
||||
let (index_trait, index_fn) = self.lang_trait_fn(db, LangItem::Index, &name![index])?;
|
||||
let (index_trait, index_fn) =
|
||||
self.lang_trait_fn(db, LangItem::Index, &Name::new_symbol_root(sym::index))?;
|
||||
let (op_trait, op_fn) = self
|
||||
.infer
|
||||
.as_ref()
|
||||
.and_then(|infer| {
|
||||
let expr = self.expr_id(db, &index_expr.clone().into())?;
|
||||
let (func, _) = infer.method_resolution(expr)?;
|
||||
let (index_mut_trait, index_mut_fn) =
|
||||
self.lang_trait_fn(db, LangItem::IndexMut, &name![index_mut])?;
|
||||
let (index_mut_trait, index_mut_fn) = self.lang_trait_fn(
|
||||
db,
|
||||
LangItem::IndexMut,
|
||||
&Name::new_symbol_root(sym::index_mut),
|
||||
)?;
|
||||
if func == index_mut_fn {
|
||||
Some((index_mut_trait, index_mut_fn))
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue