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

resolve: report duplicate-module errors #7325

Merged
merged 2 commits into from
Jun 25, 2013
Merged

resolve: report duplicate-module errors #7325

merged 2 commits into from
Jun 25, 2013

Conversation

artagnon
Copy link
Contributor

Fix #7322.

I started out with a band-aid approach to special-case the duplicate module error using is_duplicate_module, but thought this would be better in the long term.

@artagnon
Copy link
Contributor Author

@cmr Any idea what happened? The compile error seems to be completely unrelated to the change.

@emberian
Copy link
Member

@artagnon unfortunately the buildbot seems to be a bit eccentric right now. Only one build failed, and it was a test failure:


error: unexpected compiler error or warning: '/home/rustbuild/src/rust-buildbot/slave/auto-linux-32-opt/build/src/test/compile-fail/issue-3099-b.rs:13:0: 13:12 error: duplicate definition of module `a`'
command: i686-unknown-linux-gnu/stage2/bin/rustc /home/rustbuild/src/rust-buildbot/slave/auto-linux-32-opt/build/src/test/compile-fail/issue-3099-b.rs -o i686-unknown-linux-gnu/test/compile-fail/issue-3099-b.stage2-i686-unknown-linux-gnu -L i686-unknown-linux-gnu/test/compile-fail -L i686-unknown-linux-gnu/test/compile-fail/issue-3099-b.libaux -O --target=i686-unknown-linux-gnu
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
/home/rustbuild/src/rust-buildbot/slave/auto-linux-32-opt/build/src/test/compile-fail/issue-3099-b.rs:13:0: 13:12 error: duplicate definition of module `a`
/home/rustbuild/src/rust-buildbot/slave/auto-linux-32-opt/build/src/test/compile-fail/issue-3099-b.rs:13 pub mod a {} //~ ERROR duplicate definition of type `a`
                                                                                                         ^~~~~~~~~~~~
/home/rustbuild/src/rust-buildbot/slave/auto-linux-32-opt/build/src/test/compile-fail/issue-3099-b.rs:11:0: 11:12 note: first definition of module `a` here
/home/rustbuild/src/rust-buildbot/slave/auto-linux-32-opt/build/src/test/compile-fail/issue-3099-b.rs:11 pub mod a {}
                                                                                                         ^~~~~~~~~~~~
error: aborting due to previous error

------------------------------------------

So, gotta go in and fix that one.

artagnon added 2 commits June 25, 2013 23:58
add_child() is responsible for reporting errors about type, value, and
module duplicate definitions.  Although it checks for all three, it uses
namespace_to_str() to convert a Namespace value into a string before
printing an error like:

  error: duplicate definition of type `foo`
                                 ^^^^
  note: first definition of type foo here:
                            ^^^^

Unfortunately, this string can only be one of "type" or
"value" (corresponding to TypeNS and ValueNS respectively), and it
reports duplicate modules as duplicate types.

To alleviate the problem, define a special NamespaceError enum to define
more specialized errors, and use it instead of attempting to reuse the
Namespace enum.

Reported-by: Corey Richardson <[email protected]>
Signed-off-by: Ramkumar Ramachandra <[email protected]>
The "first definition of ..." error string reported by add_child() looks
different from similar messages reported by other functions.  Fix this.

Signed-off-by: Ramkumar Ramachandra <[email protected]>
@artagnon
Copy link
Contributor Author

@cmr Thanks for digging it out. But I still didn't understand what the failure is: it was expected to compile-fail, and it actually did compile-fail; or did it try to compare the actual error message with that comment (?) string?

@emberian
Copy link
Member

@artagnon Yes, it compares to the exact error message in the comment. It's a way to make sure we don't break or remove error messages.

@artagnon
Copy link
Contributor Author

@cmr Okay, thanks. Can you re-approve the new version?

bors added a commit that referenced this pull request Jun 25, 2013
Fix #7322.

I started out with a band-aid approach to special-case the duplicate module error using `is_duplicate_module`, but thought this would be better in the long term.
@bors bors closed this Jun 25, 2013
@bors bors merged commit f982f42 into rust-lang:master Jun 25, 2013
@artagnon artagnon deleted the resolve-module branch June 26, 2013 06:56
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 17, 2021
Fix FP in `default_numeric_fallback` with external macro expansion

fixes rust-lang#7304

changelog: Fix `default_numeric_fallback` FP with external macro expansion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix error message for duplicate mods
3 participants