Skip to content

Commit 21fb586

Browse files
committed
Query for TypeckResults in LateContext::qpath_res
Actually fulfills the documented guarantees.
1 parent 63a1eee commit 21fb586

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

compiler/rustc_lint/src/context.rs

+8
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,14 @@ impl<'tcx> LateContext<'tcx> {
746746
hir::QPath::Resolved(_, ref path) => path.res,
747747
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self
748748
.maybe_typeck_results()
749+
.filter(|typeck_results| typeck_results.hir_owner == id.owner)
750+
.or_else(|| {
751+
if self.tcx.has_typeck_results(id.owner.to_def_id()) {
752+
Some(self.tcx.typeck(id.owner))
753+
} else {
754+
None
755+
}
756+
})
749757
.and_then(|typeck_results| typeck_results.type_dependent_def(id))
750758
.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id)),
751759
}

0 commit comments

Comments
 (0)