about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCameron Steffen <cam.steffen94@gmail.com>2021-01-18 13:29:37 -0600
committerCameron Steffen <cam.steffen94@gmail.com>2021-01-18 13:38:14 -0600
commit21fb586c0c72a546bae445df1588cef464502ada (patch)
tree5fc9f625856afbc7b6ede5b517ccb131199aff80
parent63a1eeea234105fd9c1ed30ac2b6e0d9bf41a1e9 (diff)
downloadrust-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.rs8
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)),
         }