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

Box::new requires use std::boxed::Box despite prelude injection #20730

Closed
pnkfelix opened this issue Jan 8, 2015 · 3 comments
Closed

Box::new requires use std::boxed::Box despite prelude injection #20730

pnkfelix opened this issue Jan 8, 2015 · 3 comments
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Jan 8, 2015

In my branch that has #20723 landed, this oddity comes up:

#[cfg(workaround)]
use std::boxed::Box;

fn main() {
    let x: Box<char>;
    x = Box::new('c');
    println!(" x: {}", x);
}

Ready? Watch this:

% ./x86_64-apple-darwin/stage2/bin/rustc /tmp/boxnew2.rs
/tmp/boxnew2.rs:6:9: 6:17 error: unresolved name `Box::new`
/tmp/boxnew2.rs:6     x = Box::new('c');
                          ^~~~~~~~
error: aborting due to previous error
% ./x86_64-apple-darwin/stage2/bin/rustc /tmp/boxnew2.rs --cfg workaround
% 

That is, the Box::new call fails, unless one includes a use std::boxed::Box in one's code. Truly weird.

I spent much time today trying to dig into this (when I should have been dealing with the other fallout from feature gating box), but in the end I decided that this is "just a bug" and its an easy enough work around for the purposes of the alpha.

@kmcallister kmcallister added the A-resolve Area: Name/path resolution done by `rustc_resolve` specifically label Jan 8, 2015
@alexcrichton
Copy link
Member

I ended up fixing this in the rollup, so the bug never actually hit master!

@alexcrichton
Copy link
Member

fix

@pnkfelix
Copy link
Member Author

pnkfelix commented Jan 8, 2015

i wish i understood the bug well enough to see how that change to coherence is the true fix, but I will trust you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically
Projects
None yet
Development

No branches or pull requests

3 participants