Skip to content

"Duplicate method" error should point to previous definition #32971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jonas-schievink opened this issue Apr 14, 2016 · 0 comments
Closed

"Duplicate method" error should point to previous definition #32971

jonas-schievink opened this issue Apr 14, 2016 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@jonas-schievink
Copy link
Contributor

(same goes for "duplicate associated function" and similar errors)

I was playing around with macro-generated methods, and stumbled upon a bad diagnostic:

struct S;

macro_rules! methods {
    ( $($name:ident)* ) => {
        $( fn $name(&self) {} )*
    }
}

impl S {
    fn a(&self) {}

    methods!(a b c);
}

fn main() {}

gives:

<anon>:5:12: 5:30 error: duplicate method [E0201]
<anon>:5         $( fn $name(&self) {} )*
                    ^~~~~~~~~~~~~~~~~~
<anon>:12:5: 12:21 note: in this expansion of methods! (defined in <anon>)

Rustc should print a note: previous definition here and include the name of the method in the diagnostic (since both could be defined by macros, in which case the name will not be obvious).

@sfackler sfackler added the A-diagnostics Area: Messages for errors, warnings, and lints label Apr 14, 2016
Manishearth added a commit to Manishearth/rust that referenced this issue Apr 25, 2016
Show previous definition of duplicate impl item

Fix rust-lang#32971.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

2 participants