Skip to content
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

A type with static methods with the same name as a module generates incorrect error message #14564

Closed
huonw opened this issue May 31, 2014 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@huonw
Copy link
Member

huonw commented May 31, 2014

mod Foo { fn x() {} }

struct Foo;

impl Foo { fn y() {} }

fn main() {}
<anon>:5:1: 5:23 error: duplicate definition of module `Foo`
<anon>:5 impl Foo { fn y() {} }
         ^~~~~~~~~~~~~~~~~~~~~~
<anon>:3:1: 3:12 note: first definition of module `Foo` here
<anon>:3 struct Foo;
         ^~~~~~~~~~~
error: aborting due to previous error

The "first definition" error should be pointing to the mod Foo.

@lht
Copy link
Contributor

lht commented Jul 21, 2014

The unit-like struct is more like the culprit. A reduced test case:

mod Foo { }
struct Foo;
impl Foo {}
fn main() { }

@tamird
Copy link
Contributor

tamird commented Apr 22, 2015

This no longer errors at all. Compiling @lht's code:

$ rustc main.rs
main.rs:1:1: 1:12 warning: module `Foo` should have a snake case name such as `foo`, #[warn(non_snake_case)] on by default
main.rs:1 mod Foo { }
          ^~~~~~~~~~~
main.rs:2:1: 2:12 warning: struct is never used: `Foo`, #[warn(dead_code)] on by default
main.rs:2 struct Foo;
          ^~~~~~~~~~~

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 22, 2015
@jooert
Copy link
Contributor

jooert commented May 5, 2015

Test added in d0e5948, I did reference the wrong issue in the commit message, can be closed now.

@Aatch Aatch closed this as completed Jun 18, 2015
@Aatch
Copy link
Contributor

Aatch commented Jun 18, 2015

Fixed a while it seems.

@pnkfelix
Copy link
Member

cc #21546 #29185 #26421 ;)

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 E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

7 participants