Ident sanitization causes name conflicts
dschoepe opened this issue · comments
Deduplicating consecutive underscores in sanitize_ident
causes automatic derives to fail if one attempts to derive an implementation for a type Foo
and _Foo
. Here's a small example using abomonation_derive
:
#[derive(Abomonation)]
pub struct Foo {
x: String,
}
#[derive(Abomonation)]
pub struct _Foo {
x: String,
}
Trying to compile this fails with the following error:
error[E0428]: the name `_DERIVE_abomonation_Abomonation_FOR_Foo` is defined multiple times
--> dusty_example/src/main.rs:155:10
|
149 | #[derive(Abomonation)]
| ----------- previous definition of the value `_DERIVE_abomonation_Abomonation_FOR_Foo` here
...
155 | #[derive(Abomonation)]
| ^^^^^^^^^^^ `_DERIVE_abomonation_Abomonation_FOR_Foo` redefined here
|
= note: `_DERIVE_abomonation_Abomonation_FOR_Foo` must be defined only once in the value namespace of this module
This would also be fixed by #41 allowing avoiding generating a custom _DERIVE_
name.