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

Can't 'use' from an 'extern crate' defined in a function #23314

Closed
brson opened this issue Mar 12, 2015 · 4 comments
Closed

Can't 'use' from an 'extern crate' defined in a function #23314

brson opened this issue Mar 12, 2015 · 4 comments
Labels
A-typesystem Area: The type system

Comments

@brson
Copy link
Contributor

brson commented Mar 12, 2015

I never realized this before:

fn main() {
    extern crate core;

    // Can't write this because 'self' refers to the outer module.
    use self::core::str;
}

Seems pretty strange.

@steveklabnik steveklabnik added the A-typesystem Area: The type system label Mar 19, 2015
@shepmaster
Copy link
Member

I believe this to be the root cause of #27301.

A doc test with

/// ```
/// extern crate bignum;
/// use bignum::inits::Zero;
///
/// let a = bignum::BigNum::new(Zero::zero());
/// ```

becomes

fn main() {
    extern crate bignum;
    use bignum::inits::Zero;

    let a = bignum::BigNum::new(Zero::zero());
}

Which then suggests to use self::bignum::..., but that also fails to work due to this issue. It then suggests to use self::self::bignum::..., which is crazier.

nabijaczleweli added a commit to nabijaczleweli/blake-rs that referenced this issue Aug 16, 2016
Here's what I get for not compiling :v

Related: rust-lang/rust#23314
@steveklabnik
Copy link
Member

Triage: this is rust-lang/rfcs#959, and we'd need an RFC to change this stuff, so I'm going to give it a close.

@shepmaster
Copy link
Member

@steveklabnik do you want to close #27301 as well then?

@steveklabnik
Copy link
Member

Let's leave it open for now; I believe we could fix this by changing where the fn main is inserted, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

3 participants