Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/rustc_passes/src/eii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ pub(crate) fn check_externally_implementable_items<'tcx>(tcx: TyCtxt<'tcx>, ():
}

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

let (local_impl, is_default) =
Expand Down
19 changes: 19 additions & 0 deletions tests/ui/eii/default/multiple-default-impls-same-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![crate_type = "lib"]
#![feature(extern_item_impls)]
// `eii` expands to, among other things, `macro eii() {}`.
// If we have two eiis named the same thing, we have a duplicate definition
// for that macro. The compiler happily continues compiling on duplicate
// definitions though, to emit as many diagnostics as possible.
// However, in the case of eiis, this can break the assumption that every
// eii has only one default implementation, since the default for both eiis will
// name resolve to the same eii definiton (since the other definition was duplicate)
// This test tests for the previously-ICE that occurred when this assumption
// (of 1 default) was broken which was reported in #149982.

#[eii(eii1)]
fn a() {}

#[eii(eii1)]
//~^ ERROR the name `eii1` is defined multiple times
fn a() {}
//~^ ERROR the name `a` is defined multiple times
25 changes: 25 additions & 0 deletions tests/ui/eii/default/multiple-default-impls-same-name.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error[E0428]: the name `a` is defined multiple times
--> $DIR/multiple-default-impls-same-name.rs:18:1
|
LL | fn a() {}
| ------ previous definition of the value `a` here
...
LL | fn a() {}
| ^^^^^^ `a` redefined here
|
= note: `a` must be defined only once in the value namespace of this module

error[E0428]: the name `eii1` is defined multiple times
--> $DIR/multiple-default-impls-same-name.rs:16:1
|
LL | #[eii(eii1)]
| ------------ previous definition of the macro `eii1` here
...
LL | #[eii(eii1)]
| ^^^^^^^^^^^^ `eii1` redefined here
|
= note: `eii1` must be defined only once in the macro namespace of this module

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0428`.
18 changes: 18 additions & 0 deletions tests/ui/eii/default/multiple-default-impls.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![crate_type = "lib"]
#![feature(extern_item_impls)]
// `eii` expands to, among other things, `macro eii() {}`.
// If we have two eiis named the same thing, we have a duplicate definition
// for that macro. The compiler happily continues compiling on duplicate
// definitions though, to emit as many diagnostics as possible.
// However, in the case of eiis, this can break the assumption that every
// eii has only one default implementation, since the default for both eiis will
// name resolve to the same eii definiton (since the other definition was duplicate)
// This test tests for the previously-ICE that occurred when this assumption
// (of 1 default) was broken which was reported in #149982.

#[eii(eii1)]
fn a() {}

#[eii(eii1)]
//~^ ERROR the name `eii1` is defined multiple times
fn b() {}
14 changes: 14 additions & 0 deletions tests/ui/eii/default/multiple-default-impls.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0428]: the name `eii1` is defined multiple times
--> $DIR/multiple-default-impls.rs:16:1
|
LL | #[eii(eii1)]
| ------------ previous definition of the macro `eii1` here
...
LL | #[eii(eii1)]
| ^^^^^^^^^^^^ `eii1` redefined here
|
= note: `eii1` must be defined only once in the macro namespace of this module

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0428`.
Loading