Skip to content

Commit

Permalink
Query for TypeckResults in LateContext::qpath_res
Browse files Browse the repository at this point in the history
Actually fulfills the documented guarantees.
  • Loading branch information
camsteffen committed Jan 18, 2021
1 parent 63a1eee commit 21fb586
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,14 @@ impl<'tcx> LateContext<'tcx> {
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)),
}
Expand Down

0 comments on commit 21fb586

Please sign in to comment.