Skip to content

Commit 08b7d34

Browse files
committed
another related case that deserved a test
1 parent 1cd7cb1 commit 08b7d34

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![crate_type = "lib"]
2+
#![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.
12+
13+
#[eii(eii1)]
14+
fn a() {}
15+
16+
#[eii(eii1)]
17+
//~^ ERROR the name `eii1` is defined multiple times
18+
fn a() {}
19+
//~^ ERROR the name `a` is defined multiple times
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0428]: the name `a` is defined multiple times
2+
--> $DIR/multiple-default-impls-same-name.rs:18:1
3+
|
4+
LL | fn a() {}
5+
| ------ previous definition of the value `a` here
6+
...
7+
LL | fn a() {}
8+
| ^^^^^^ `a` redefined here
9+
|
10+
= note: `a` must be defined only once in the value namespace of this module
11+
12+
error[E0428]: the name `eii1` is defined multiple times
13+
--> $DIR/multiple-default-impls-same-name.rs:16:1
14+
|
15+
LL | #[eii(eii1)]
16+
| ------------ previous definition of the macro `eii1` here
17+
...
18+
LL | #[eii(eii1)]
19+
| ^^^^^^^^^^^^ `eii1` redefined here
20+
|
21+
= note: `eii1` must be defined only once in the macro namespace of this module
22+
23+
error: aborting due to 2 previous errors
24+
25+
For more information about this error, try `rustc --explain E0428`.

0 commit comments

Comments
 (0)