Skip to content

Commit 1cd7cb1

Browse files
committed
turn panic into span_delayed_bug
1 parent bd137df commit 1cd7cb1

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

compiler/rustc_passes/src/eii.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ pub(crate) fn check_externally_implementable_items<'tcx>(tcx: TyCtxt<'tcx>, ():
116116
}
117117

118118
if default_impls.len() > 1 {
119-
panic!("multiple not supported right now");
119+
let decl_span = tcx.def_ident_span(decl_did).unwrap();
120+
tcx.dcx().span_delayed_bug(decl_span, "multiple not supported right now");
120121
}
121122

122123
let (local_impl, is_default) =
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
#![crate_type = "lib"]
22
#![feature(extern_item_impls)]
3+
// `eii` expands to, among other things, `macro eii() {}`.
4+
// If we have two eiis named the same thing, we have a duplicate definition
5+
// for that macro. The compiler happily continues compiling on duplicate
6+
// definitions though, to emit as many diagnostics as possible.
7+
// However, in the case of eiis, this can break the assumption that every
8+
// eii has only one default implementation, since the default for both eiis will
9+
// name resolve to the same eii definiton (since the other definition was duplicate)
10+
// This test tests for the previously-ICE that occurred when this assumption
11+
// (of 1 default) was broken which was reported in #149982.
312

413
#[eii(eii1)]
514
fn a() {}
615

716
#[eii(eii1)]
17+
//~^ ERROR the name `eii1` is defined multiple times
818
fn b() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0428]: the name `eii1` is defined multiple times
2+
--> $DIR/multiple-default-impls.rs:16:1
3+
|
4+
LL | #[eii(eii1)]
5+
| ------------ previous definition of the macro `eii1` here
6+
...
7+
LL | #[eii(eii1)]
8+
| ^^^^^^^^^^^^ `eii1` redefined here
9+
|
10+
= note: `eii1` must be defined only once in the macro namespace of this module
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0428`.

0 commit comments

Comments
 (0)