From ab946dd3e702d6bfd50d876976b7c62c673c204e Mon Sep 17 00:00:00 2001 From: kadmin Date: Sun, 1 Nov 2020 22:31:19 +0000 Subject: [PATCH] Add delay_span_bug to no longer ICE --- compiler/rustc_typeck/src/collect/type_of.rs | 8 +++++++- src/test/ui/issues/issue-78622.rs | 7 +++++++ src/test/ui/issues/issue-78622.stderr | 9 +++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/issues/issue-78622.rs create mode 100644 src/test/ui/issues/issue-78622.stderr diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index a754d4dbac713..61d1efc837b03 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -79,7 +79,13 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option< let _tables = tcx.typeck(body_owner); &*path } - _ => span_bug!(DUMMY_SP, "unexpected const parent path {:?}", parent_node), + _ => { + tcx.sess.delay_span_bug( + tcx.def_span(def_id), + &format!("unexpected const parent path {:?}", parent_node), + ); + return None; + } }; // We've encountered an `AnonConst` in some path, so we need to diff --git a/src/test/ui/issues/issue-78622.rs b/src/test/ui/issues/issue-78622.rs new file mode 100644 index 0000000000000..c00fd26606367 --- /dev/null +++ b/src/test/ui/issues/issue-78622.rs @@ -0,0 +1,7 @@ +#![crate_type = "lib"] + +struct S; +fn f() { + S::A:: {} + //~^ ERROR ambiguous associated type +} diff --git a/src/test/ui/issues/issue-78622.stderr b/src/test/ui/issues/issue-78622.stderr new file mode 100644 index 0000000000000..f13073da0a36e --- /dev/null +++ b/src/test/ui/issues/issue-78622.stderr @@ -0,0 +1,9 @@ +error[E0223]: ambiguous associated type + --> $DIR/issue-78622.rs:5:5 + | +LL | S::A:: {} + | ^^^^^^^^^ help: use fully-qualified syntax: `::A` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0223`.