File tree 3 files changed +39
-1
lines changed
compiler/rustc_builtin_macros/src/deriving
3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ fn extract_default_variant<'a>(
145
145
let suggestion = default_variants
146
146
. iter ( )
147
147
. filter_map ( |v| {
148
- if v. ident == variant. ident {
148
+ if v. span == variant. span {
149
149
None
150
150
} else {
151
151
Some ( ( cx. sess . find_by_name ( & v. attrs , kw:: Default ) ?. span , String :: new ( ) ) )
Original file line number Diff line number Diff line change
1
+ // compile-flags: --crate-type=lib
2
+
3
+ #[ derive( Default ) ] //~ ERROR multiple declared defaults
4
+ enum E {
5
+ #[ default]
6
+ A ,
7
+ #[ default]
8
+ A , //~ ERROR defined multiple times
9
+ }
Original file line number Diff line number Diff line change
1
+ error: multiple declared defaults
2
+ --> $DIR/issue-105101.rs:3:10
3
+ |
4
+ LL | #[derive(Default)]
5
+ | ^^^^^^^
6
+ ...
7
+ LL | A,
8
+ | - first default
9
+ LL | #[default]
10
+ LL | A,
11
+ | - additional default
12
+ |
13
+ = note: only one variant can be default
14
+ = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
15
+
16
+ error[E0428]: the name `A` is defined multiple times
17
+ --> $DIR/issue-105101.rs:8:5
18
+ |
19
+ LL | A,
20
+ | - previous definition of the type `A` here
21
+ LL | #[default]
22
+ LL | A,
23
+ | ^ `A` redefined here
24
+ |
25
+ = note: `A` must be defined only once in the type namespace of this enum
26
+
27
+ error: aborting due to 2 previous errors
28
+
29
+ For more information about this error, try `rustc --explain E0428`.
You can’t perform that action at this time.
0 commit comments