Skip to content

Commit 6abd2a5

Browse files
authored
Rollup merge of #78349 - JohnTitor:issue-75962, r=davidtwco
Use its own `TypeckResults` to avoid ICE Fixes #75962
2 parents ae54425 + 4f34537 commit 6abd2a5

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
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 {

compiler/rustc_save_analysis/src/sig.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<'hir> Sig for hir::Ty<'hir> {
262262
} else {
263263
let start = offset + prefix.len() + 5;
264264
let end = start + name.len();
265-
// FIXME should put the proper path in there, not elipses.
265+
// FIXME should put the proper path in there, not ellipsis.
266266
Ok(Signature {
267267
text: prefix + "...::" + &name,
268268
defs: vec![],
@@ -272,7 +272,7 @@ impl<'hir> Sig for hir::Ty<'hir> {
272272
}
273273
hir::TyKind::Path(hir::QPath::TypeRelative(ty, segment)) => {
274274
let nested_ty = ty.make(offset + 1, id, scx)?;
275-
let prefix = format!("<{}>::", nested_ty.text,);
275+
let prefix = format!("<{}>::", nested_ty.text);
276276

277277
let name = path_segment_to_string(segment);
278278
let res = scx.get_path_res(id.ok_or("Missing id for Path")?);
@@ -551,7 +551,7 @@ impl<'hir> Sig for hir::Item<'hir> {
551551
// FIXME where clause
552552
}
553553
hir::ItemKind::ForeignMod(_) => Err("extern mod"),
554-
hir::ItemKind::GlobalAsm(_) => Err("glboal asm"),
554+
hir::ItemKind::GlobalAsm(_) => Err("global asm"),
555555
hir::ItemKind::ExternCrate(_) => Err("extern crate"),
556556
hir::ItemKind::OpaqueTy(..) => Err("opaque type"),
557557
// FIXME should implement this (e.g., pub use).

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)