Skip to content

Confusing error message when including a module recursively #34157

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
jethrogb opened this issue Jun 8, 2016 · 1 comment
Closed

Confusing error message when including a module recursively #34157

jethrogb opened this issue Jun 8, 2016 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@jethrogb
Copy link
Contributor

jethrogb commented Jun 8, 2016

Executing the following:

cargo new --bin x
cd x
touch src/a.rs
echo 'mod a;' >> src/main.rs 
echo 'mod main;' >> src/main.rs 
cargo build

Results in this error message:

src/main.rs:4:5: 4:6 error: cannot declare a new module at this location
src/main.rs:4 mod a;
                  ^
src/main.rs:4:5: 4:6 note: maybe move this module `main` to its own directory via `main/mod.rs`
src/main.rs:4 mod a;
                  ^
src/main.rs:4:5: 4:6 note: ... or maybe `use` the module `a` instead of possibly redeclaring it
src/main.rs:4 mod a;
                  ^

None of which indicates that main.rs is being included recursively. Removing the mod main; line builds succesfully.

@sanxiyn sanxiyn added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 8, 2016
@jseyfried
Copy link
Contributor

Closing as duplicate of #36146.

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