another related case that deserved a test

This commit is contained in:
Jana Dönszelmann 2025-12-17 17:57:04 +01:00
parent 1cd7cb1e8d
commit 08b7d34e06
No known key found for this signature in database
2 changed files with 44 additions and 0 deletions

View file

@ -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

View file

@ -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`.