-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-syntaxextArea: Syntax extensionsArea: Syntax extensionsE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Description
This:
macro_rules! define_vec (
() => (
mod foo {
#[deriving(Eq)]
pub struct bar;
}
)
)
define_vec!()
fn main() {}
...doesn't compile:
moon.rs:4:23: 4:25 error: conflicting implementations for a trait
moon.rs:4 #[deriving(Eq)]
^~
moon.rs:4:23: 4:25 note: note conflicting implementation here
moon.rs:4 #[deriving(Eq)]
^~
moon.rs:4:23: 4:25 error: conflicting implementations for a trait
moon.rs:4 #[deriving(Eq)]
^~
moon.rs:4:23: 4:25 note: note conflicting implementation here
moon.rs:4 #[deriving(Eq)]
^~
error: aborting due to 2 previous errors
Taking a look at the expanded code:
mod foo {
#[deriving(Eq)]
pub struct bar;
#[doc = "Automatically derived."]
pub impl ::std::cmp::Eq for bar {
pub fn eq(&self, __arg_0: &bar) -> ::bool {
match *__arg_0 { bar => match *self { bar => true } }
}
pub fn ne(&self, __arg_0: &bar) -> ::bool {
match *__arg_0 { bar => match *self { bar => false } }
}
}
#[doc = "Automatically derived."]
pub impl ::std::cmp::Eq for bar {
pub fn eq(&self, __arg_0: &bar) -> ::bool {
match *__arg_0 { bar => match *self { bar => true } }
}
pub fn ne(&self, __arg_0: &bar) -> ::bool {
match *__arg_0 { bar => match *self { bar => false } }
}
}
}
fn main() { }
Notice that it's generating a second identical impl for the given trait. I've tested that this happens with both Eq
and ToStr
, so I presume it applies to the deriving code in general.
Metadata
Metadata
Assignees
Labels
A-syntaxextArea: Syntax extensionsArea: Syntax extensionsE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.