diff options
| author | Cameron Steffen <cam.steffen94@gmail.com> | 2021-01-18 13:29:37 -0600 |
|---|---|---|
| committer | Cameron Steffen <cam.steffen94@gmail.com> | 2021-01-18 13:38:14 -0600 |
| commit | 21fb586c0c72a546bae445df1588cef464502ada (patch) | |
| tree | 5fc9f625856afbc7b6ede5b517ccb131199aff80 | |
| parent | 63a1eeea234105fd9c1ed30ac2b6e0d9bf41a1e9 (diff) | |
| download | rust-21fb586c0c72a546bae445df1588cef464502ada.tar.gz rust-21fb586c0c72a546bae445df1588cef464502ada.zip | |
Query for TypeckResults in LateContext::qpath_res
Actually fulfills the documented guarantees.
| -rw-r--r-- | compiler/rustc_lint/src/context.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 3971a309982..3f92d66d88b 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -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)), } |
