Skip to content

Commit 88d3967

Browse files
committed
Use its own TypeckResults to avoid ICE
1 parent f58ffc9 commit 88d3967

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

compiler/rustc_save_analysis/src/lib.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,14 @@ impl<'tcx> SaveContext<'tcx> {
630630
})
631631
| Node::Ty(&hir::Ty { kind: hir::TyKind::Path(ref qpath), .. }) => match qpath {
632632
hir::QPath::Resolved(_, path) => path.res,
633-
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self
634-
.maybe_typeck_results
635-
.map_or(Res::Err, |typeck_results| typeck_results.qpath_res(qpath, hir_id)),
633+
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => {
634+
// #75962: `self.typeck_results` may be different from the `hir_id`'s result.
635+
if self.tcx.has_typeck_results(hir_id.owner.to_def_id()) {
636+
self.tcx.typeck(hir_id.owner).qpath_res(qpath, hir_id)
637+
} else {
638+
Res::Err
639+
}
640+
}
636641
},
637642

638643
Node::Binding(&hir::Pat {

src/test/ui/impl-trait/bound-normalization-pass.stderr renamed to src/test/ui/impl-trait/bound-normalization-pass.default.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/bound-normalization-pass.rs:5:12
2+
--> $DIR/bound-normalization-pass.rs:8:12
33
|
44
LL | #![feature(impl_trait_in_bindings)]
55
| ^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/impl-trait/bound-normalization-pass.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// check-pass
22
// edition:2018
3+
// revisions: default sa
4+
//[sa] compile-flags: -Z save-analysis
5+
//-^ To make this the regression test for #75962.
36

47
#![feature(type_alias_impl_trait)]
58
#![feature(impl_trait_in_bindings)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/bound-normalization-pass.rs:8:12
3+
|
4+
LL | #![feature(impl_trait_in_bindings)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
9+
10+
warning: 1 warning emitted
11+

0 commit comments

Comments
 (0)