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

Confusing error when using import globbing in test module #16597

Closed
bkoropoff opened this issue Aug 19, 2014 · 7 comments · Fixed by #16892
Closed

Confusing error when using import globbing in test module #16597

bkoropoff opened this issue Aug 19, 2014 · 7 comments · Fixed by #16892

Comments

@bkoropoff
Copy link
Contributor

Problem

Using import globbing in a test module results in a very confusing error.

Code

#![feature(globs)]

mod test {
    use super::*;

    #[test]
    fn test(){}
}

Output

$ rustc --test test.rs 
test.rs:4:9: 4:18 error: import conflicts with type in this module
test.rs:4     use super::*;
                  ^~~~~~~~~
test.rs:1:1: 1:1 note: note conflicting type here
test.rs:1 #![feature(globs)]
          ^
error: aborting due to previous error

After some digging, it turns out the conflict is on __test_reexports. I plan to submit a PR to at least print the name of the conflicting import in the above error message so there's something to go on.

bkoropoff added a commit to bkoropoff/rust that referenced this issue Aug 19, 2014
This partially alleviates the confusing behavior in issue rust-lang#16597
@samdoshi
Copy link

Is using use super::*; in test modules discouraged now? (see http://aturon.github.io/style/imports.html)

For anyone wishing to temporarily work around this issue, you can re-enable import shadowing with the following feature gate #![feature(import_shadowing)]

@SimonSapin
Copy link
Contributor

CC @pcwalton (as author of 7f928d1)

@SiegeLord
Copy link
Contributor

The error message really should mention that that gate is an option.

lifthrasiir added a commit to lifthrasiir/rust-encoding that referenced this issue Aug 19, 2014
@pcwalton
Copy link
Contributor

The gate will probably be removed in the future, so I'd rather not encourage people to depend on it.

@sfackler
Copy link
Member

@samdoshi it's just a bug.

Should be an easy-ish fix by gensyming each __test_reexports separately.

@SimonSapin
Copy link
Contributor

@sfackler what’s gensyming? Symbol generation, as in giving them different names?

@sfackler
Copy link
Member

Yeah, giving each reexport module a name that the compiler will consider distinct from everything else in the crate.

nathantypanski added a commit to nathantypanski/rustdown that referenced this issue Aug 24, 2014
rust-lang/rust#16597

Name conflicts when globbing are affected by a problem in
__test_reexports gensym.
SimonSapin added a commit to servo/rust-cssparser that referenced this issue Aug 30, 2014
bors added a commit that referenced this issue Aug 30, 2014
This partially alleviates the confusing behavior in issue #16597
bors added a commit that referenced this issue Sep 3, 2014
…ckler

Fixes #16597

I'm not 100% sure this is the correct way to handle this - but I wasn't able to find a better way without doing way more refactoring of the code that I was comfortable with.  Comments and criticism are appreciated 😄
SimonSapin added a commit to servo/rust-cssparser that referenced this issue Sep 8, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 25, 2024
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 a pull request may close this issue.

6 participants