Skip to content

trait declaration + bare impl on that trait give error messages mentioning "duplication modules" #12569

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
huonw opened this issue Feb 26, 2014 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@huonw
Copy link
Member

huonw commented Feb 26, 2014

trait Foo {} impl Foo {} fn main() {}

Gives

<anon>:1:14: 1:25 error: duplicate definition of module `Foo`
<anon>:1 trait Foo {} impl Foo {} fn main() {}
                      ^~~~~~~~~~~
<anon>:1:1: 1:13 note: first definition of module `Foo` here
<anon>:1 trait Foo {} impl Foo {} fn main() {}
         ^~~~~~~~~~~~
error: aborting due to previous error

There's no mention of mods in the code, so it would be nice if the error message didn't mention modules at all; and preferably if it just complained that the Foo in impl Foo {} wasn't a type. (Of course, the latter point may change with DST.)

@lilyball
Copy link
Contributor

lilyball commented Apr 9, 2014

This exact same error is triggered if you have a module and a type impl of the same name:

struct Foo;

impl Foo {
    pub fn foo() -> uint { 1 }
}

mod Foo {
    pub fn foo() -> uint { 2 }
}

or a trait and a mod:

trait Foo { pub fn foo() -> uint { 1 } }

mod Foo {
    pub fn foo() -> uint { 2 }
}

@alexcrichton
Copy link
Member

Due to many language changes in the meantime since this was opened, all examples here now give reasonable errors, and I'm fairly certain that tests exist for all of them, so I'm going to close this out of old age basically.

flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 4, 2024
fix [`manual_unwrap_or_default`] suggestion ignoring side-effects

fixes: rust-lang#12569
closes: rust-lang#12580

change applicability to `MaybeIncorrect` base on suggestion in [this zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/.60manual_unwrap_or_default.60.20suggestion.20removes.20comments)

---

changelog: fix [`manual_unwrap_or_default`] suggestion ignoring side-effects, and adjust its applicability.
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

3 participants