mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
simplify??
This commit is contained in:
parent
a1b2d25810
commit
fec2d39f3c
1 changed files with 8 additions and 8 deletions
|
@ -15,8 +15,8 @@ use hir_def::{
|
||||||
},
|
},
|
||||||
expr::{ExprId, Pat, PatId},
|
expr::{ExprId, Pat, PatId},
|
||||||
path::{ModPath, Path, PathKind},
|
path::{ModPath, Path, PathKind},
|
||||||
resolver::{resolver_for_scope, HasResolver, Resolver, TypeNs, ValueNs},
|
resolver::{resolver_for_scope, Resolver, TypeNs, ValueNs},
|
||||||
AsMacroCall, DefWithBodyId, FieldId, FunctionId, LocalFieldId, VariantId,
|
AsMacroCall, DefWithBodyId, FieldId, FunctionId, LocalFieldId, ModuleDefId, VariantId,
|
||||||
};
|
};
|
||||||
use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile};
|
use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile};
|
||||||
use hir_ty::{
|
use hir_ty::{
|
||||||
|
@ -545,13 +545,13 @@ fn resolve_hir_path_(
|
||||||
}
|
}
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
if let (Some(_), TypeNs::TraitId(trait_id)) = (&unresolved, &ty) {
|
// If we are in a TypeNs for a Trait, and we have an unresolved name, try to resolve it as a type
|
||||||
let resolver = trait_id.resolver(db.upcast());
|
// within the trait's associated types.
|
||||||
if let Some(module_def_id) = resolver
|
if let (Some(unresolved), &TypeNs::TraitId(trait_id)) = (&unresolved, &ty) {
|
||||||
.resolve_module_path_in_trait_assoc_items(db.upcast(), path.mod_path())
|
if let Some(type_alias_id) =
|
||||||
.and_then(|ns| ns.take_types())
|
db.trait_data(trait_id).associated_type_by_name(&unresolved.name)
|
||||||
{
|
{
|
||||||
return Some(PathResolution::Def(module_def_id.into()));
|
return Some(PathResolution::Def(ModuleDefId::from(type_alias_id).into()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue