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

Glob imports ignore extern crate items of parent modules #22146

Closed
crumblingstatue opened this issue Feb 10, 2015 · 4 comments · Fixed by #32850
Closed

Glob imports ignore extern crate items of parent modules #22146

crumblingstatue opened this issue Feb 10, 2015 · 4 comments · Fixed by #32850
Labels
A-resolve Area: Name resolution

Comments

@crumblingstatue
Copy link
Contributor

It doesn't matter if the extern crate item is public or private, it's ignored in both cases.

Example:

#![feature(libc)]

pub mod foo {
    pub extern crate libc;
    pub mod bar {
        // use foo::libc; // Direct import works
        use foo::*; // Glob import doesn't work
        pub fn bar_fn() {
            let _: libc::c_int;
        }
    }
}

fn main() {
    foo::bar::bar_fn();
}

This gives the error:

<anon>:9:20: 9:31 error: failed to resolve. Use of undeclared type or module `libc`
<anon>:9             let _: libc::c_int;
                            ^~~~~~~~~~~
<anon>:9:20: 9:31 error: use of undeclared type name `libc::c_int`
<anon>:9             let _: libc::c_int;
                            ^~~~~~~~~~~

Note that this is not the same issue as #22145, as it doesn't matter whether the item is public or private.

@kmcallister kmcallister added the A-resolve Area: Name resolution label Feb 10, 2015
@durka
Copy link
Contributor

durka commented Dec 1, 2015

This seems to be fixed in nightly!

@crumblingstatue
Copy link
Contributor Author

It indeed seems to be fixed.
Can I close this, or should regression tests be added first?

@durka
Copy link
Contributor

durka commented Dec 1, 2015

Glob imports are famously wonky, so a regression test sounds like a great idea to me. Especially since this seems to have been "fixed by accident" unless I missed another issue.

@jseyfried
Copy link
Contributor

This was fixed in #31362, after which extern crates are treated the same as non-import items.
cc @steveklabnik

jseyfried added a commit to jseyfried/rust that referenced this issue Apr 9, 2016
Manishearth added a commit to Manishearth/rust that referenced this issue Apr 10, 2016
resolve: Add regression tests for fixed issues

This adds regression tests for fixed issues in resolve (closes rust-lang#22146, closes rust-lang#24883, closes rust-lang#26930).
r? @eddyb
bors added a commit that referenced this issue Apr 11, 2016
resolve: Add regression tests for fixed issues

This adds regression tests for fixed issues in resolve (closes #22146, closes #24883, closes #26930).
r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name resolution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants