Skip to content
New issue

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

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

Already on GitHub? # to your account

Unit/tuple structs with the same name as a module are allowed. #29185

Closed
eddyb opened this issue Oct 20, 2015 · 3 comments
Closed

Unit/tuple structs with the same name as a module are allowed. #29185

eddyb opened this issue Oct 20, 2015 · 3 comments
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically

Comments

@eddyb
Copy link
Member

eddyb commented Oct 20, 2015

The following two type-definition/module conflicts cause errors:

enum Foo {}
mod Foo {}
struct Bar { x: bool }
mod Bar {}

But unit and tuple structs, due to the special-casing to check for value conflicts, end up not checking for module conflicts, resulting in the following two examples compiling:

struct Foo;
mod Foo {}
struct Bar(bool);
mod Bar {}
@eddyb eddyb added the A-resolve Area: Name/path resolution done by `rustc_resolve` specifically label Oct 20, 2015
@WildCryptoFox
Copy link
Contributor

I found this issue when using a struct with fields. This only causes the error when the module is defined first.

https://play.rust-lang.org/?gist=f66e0f4649a86c845270&version=stable

The error does not occur with unit structs or tuple structs.

https://play.rust-lang.org/?gist=55e9c9cd9938220a1031&version=stable

@alexcrichton
Copy link
Member

This is in theory being fixed by #26421, but it looks like progress is slow there

@eddyb
Copy link
Member Author

eddyb commented Oct 20, 2015

Closing as duplicate of #21546.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically
Projects
None yet
Development

No branches or pull requests

3 participants