Query for TypeckResults in LateContext::qpath_res
Actually fulfills the documented guarantees.
This commit is contained in:
parent
63a1eeea23
commit
21fb586c0c
@ -746,6 +746,14 @@ pub fn qpath_res(&self, qpath: &hir::QPath<'_>, id: hir::HirId) -> Res {
|
||||
hir::QPath::Resolved(_, ref path) => path.res,
|
||||
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self
|
||||
.maybe_typeck_results()
|
||||
.filter(|typeck_results| typeck_results.hir_owner == id.owner)
|
||||
.or_else(|| {
|
||||
if self.tcx.has_typeck_results(id.owner.to_def_id()) {
|
||||
Some(self.tcx.typeck(id.owner))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.and_then(|typeck_results| typeck_results.type_dependent_def(id))
|
||||
.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id)),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user