Refine search for const and function assoc items

This commit is contained in:
Lukas Wirth 2023-01-11 17:10:04 +01:00
parent f32f64bffc
commit bb4e272d8a
7 changed files with 319 additions and 36 deletions

View file

@ -504,7 +504,7 @@ impl SourceAnalyzer {
AssocItemId::ConstId(const_id) => {
self.resolve_impl_const_or_trait_def(db, const_id, subs).into()
}
_ => assoc,
assoc => assoc,
};
return Some(PathResolution::Def(AssocItem::from(assoc).into()));
@ -517,7 +517,13 @@ impl SourceAnalyzer {
prefer_value_ns = true;
} else if let Some(path_pat) = parent().and_then(ast::PathPat::cast) {
let pat_id = self.pat_id(&path_pat.into())?;
if let Some((assoc, _)) = infer.assoc_resolutions_for_pat(pat_id) {
if let Some((assoc, subs)) = infer.assoc_resolutions_for_pat(pat_id) {
let assoc = match assoc {
AssocItemId::ConstId(const_id) => {
self.resolve_impl_const_or_trait_def(db, const_id, subs).into()
}
assoc => assoc,
};
return Some(PathResolution::Def(AssocItem::from(assoc).into()));
}
if let Some(VariantId::EnumVariantId(variant)) =