about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_save_analysis/src/lib.rs11
-rw-r--r--src/test/ui/impl-trait/bound-normalization-pass.default.stderr (renamed from src/test/ui/impl-trait/bound-normalization-pass.stderr)2
-rw-r--r--src/test/ui/impl-trait/bound-normalization-pass.rs3
-rw-r--r--src/test/ui/impl-trait/bound-normalization-pass.sa.stderr11
4 files changed, 23 insertions, 4 deletions
diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs
index f6434689fec..48d15370ee3 100644
--- a/compiler/rustc_save_analysis/src/lib.rs
+++ b/compiler/rustc_save_analysis/src/lib.rs
@@ -630,9 +630,14 @@ impl<'tcx> SaveContext<'tcx> {
             })
             | Node::Ty(&hir::Ty { kind: hir::TyKind::Path(ref qpath), .. }) => match qpath {
                 hir::QPath::Resolved(_, path) => path.res,
-                hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self
-                    .maybe_typeck_results
-                    .map_or(Res::Err, |typeck_results| typeck_results.qpath_res(qpath, hir_id)),
+                hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => {
+                    // #75962: `self.typeck_results` may be different from the `hir_id`'s result.
+                    if self.tcx.has_typeck_results(hir_id.owner.to_def_id()) {
+                        self.tcx.typeck(hir_id.owner).qpath_res(qpath, hir_id)
+                    } else {
+                        Res::Err
+                    }
+                }
             },
 
             Node::Binding(&hir::Pat {
diff --git a/src/test/ui/impl-trait/bound-normalization-pass.stderr b/src/test/ui/impl-trait/bound-normalization-pass.default.stderr
index afc181a906a..ef3cb740112 100644
--- a/src/test/ui/impl-trait/bound-normalization-pass.stderr
+++ b/src/test/ui/impl-trait/bound-normalization-pass.default.stderr
@@ -1,5 +1,5 @@
 warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/bound-normalization-pass.rs:5:12
+  --> $DIR/bound-normalization-pass.rs:8:12
    |
 LL | #![feature(impl_trait_in_bindings)]
    |            ^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/test/ui/impl-trait/bound-normalization-pass.rs b/src/test/ui/impl-trait/bound-normalization-pass.rs
index fff17667fda..3e6884ef10f 100644
--- a/src/test/ui/impl-trait/bound-normalization-pass.rs
+++ b/src/test/ui/impl-trait/bound-normalization-pass.rs
@@ -1,5 +1,8 @@
 // check-pass
 // edition:2018
+// revisions: default sa
+//[sa] compile-flags: -Z save-analysis
+//-^ To make this the regression test for #75962.
 
 #![feature(type_alias_impl_trait)]
 #![feature(impl_trait_in_bindings)]
diff --git a/src/test/ui/impl-trait/bound-normalization-pass.sa.stderr b/src/test/ui/impl-trait/bound-normalization-pass.sa.stderr
new file mode 100644
index 00000000000..ef3cb740112
--- /dev/null
+++ b/src/test/ui/impl-trait/bound-normalization-pass.sa.stderr
@@ -0,0 +1,11 @@
+warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/bound-normalization-pass.rs:8:12
+   |
+LL | #![feature(impl_trait_in_bindings)]
+   |            ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+   = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
+
+warning: 1 warning emitted
+