From 88d39673d7147af0d33705ffe06a83876e70aa2d Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 25 Oct 2020 18:33:13 +0900 Subject: [PATCH 1/2] Use its own `TypeckResults` to avoid ICE --- compiler/rustc_save_analysis/src/lib.rs | 11 ++++++++--- ...stderr => bound-normalization-pass.default.stderr} | 2 +- src/test/ui/impl-trait/bound-normalization-pass.rs | 3 +++ .../ui/impl-trait/bound-normalization-pass.sa.stderr | 11 +++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) rename src/test/ui/impl-trait/{bound-normalization-pass.stderr => bound-normalization-pass.default.stderr} (89%) create mode 100644 src/test/ui/impl-trait/bound-normalization-pass.sa.stderr diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs index f6434689fec01..48d15370ee320 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 similarity index 89% rename from src/test/ui/impl-trait/bound-normalization-pass.stderr rename to src/test/ui/impl-trait/bound-normalization-pass.default.stderr index afc181a906ac7..ef3cb7401128e 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 fff17667fdae1..3e6884ef10fa6 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 0000000000000..ef3cb7401128e --- /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 for more information + +warning: 1 warning emitted + From 4f345377082ab564cd83d0cb7f805e2a97594366 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 25 Oct 2020 18:33:22 +0900 Subject: [PATCH 2/2] Fix small typos --- compiler/rustc_save_analysis/src/sig.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_save_analysis/src/sig.rs b/compiler/rustc_save_analysis/src/sig.rs index 747e198cd9324..1bf8160e4c384 100644 --- a/compiler/rustc_save_analysis/src/sig.rs +++ b/compiler/rustc_save_analysis/src/sig.rs @@ -262,7 +262,7 @@ impl<'hir> Sig for hir::Ty<'hir> { } else { let start = offset + prefix.len() + 5; let end = start + name.len(); - // FIXME should put the proper path in there, not elipses. + // FIXME should put the proper path in there, not ellipsis. Ok(Signature { text: prefix + "...::" + &name, defs: vec![], @@ -272,7 +272,7 @@ impl<'hir> Sig for hir::Ty<'hir> { } hir::TyKind::Path(hir::QPath::TypeRelative(ty, segment)) => { let nested_ty = ty.make(offset + 1, id, scx)?; - let prefix = format!("<{}>::", nested_ty.text,); + let prefix = format!("<{}>::", nested_ty.text); let name = path_segment_to_string(segment); let res = scx.get_path_res(id.ok_or("Missing id for Path")?); @@ -551,7 +551,7 @@ impl<'hir> Sig for hir::Item<'hir> { // FIXME where clause } hir::ItemKind::ForeignMod(_) => Err("extern mod"), - hir::ItemKind::GlobalAsm(_) => Err("glboal asm"), + hir::ItemKind::GlobalAsm(_) => Err("global asm"), hir::ItemKind::ExternCrate(_) => Err("extern crate"), hir::ItemKind::OpaqueTy(..) => Err("opaque type"), // FIXME should implement this (e.g., pub use).