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

using extern-prelude does not allow use of std/core #50605

Closed
nikomatsakis opened this issue May 10, 2018 · 5 comments
Closed

using extern-prelude does not allow use of std/core #50605

nikomatsakis opened this issue May 10, 2018 · 5 comments
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

nikomatsakis commented May 10, 2018

Example (play):

#![feature(extern_prelude)]

mod foo {
    pub fn test() {
        let x = std::cmp::min(2, 3);
        assert_eq!(x, 2);
    }
}

fn main() {
    foo::test();
}

I would expect this to work. (I presume it doesn't because cargo doesn't pass --extern std.)

cc @petrochenkov @Manishearth

@nikomatsakis nikomatsakis added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 10, 2018
@petrochenkov
Copy link
Contributor

std is not passed via --extern, so it can't work through extern prelude.

It needs a separate (library!) addition - pub use crate as std; in libstd prelude (which unfortunately doesn't work right now due to some bug I haven't had time to investigate yet).

@nikomatsakis
Copy link
Contributor Author

@petrochenkov

can't work through extern prelude

Can't is a strong word. =) Linking in std is "well known" to rustc so we certainly could make it work, I would imagine. However, I don't really care how we implement it, I just want the example to work. =)

@Manishearth
Copy link
Member

We should just insert std in extern-prelude if the crate is not no-std? (and something similar for core)

@mbrubeck mbrubeck changed the title using extern-prelude does not allow use of std using extern-prelude does not allow use of std/core May 29, 2018
@mbrubeck
Copy link
Contributor

Similarly core should work if the crate is no_std (unless it is also no_core).

CC #44660

@petrochenkov
Copy link
Contributor

petrochenkov commented May 29, 2018

I think we can do this in the compiler temporarily and then move to the library prelude once bugs are fixed.

mbrubeck added a commit to mbrubeck/rust that referenced this issue May 31, 2018
bors added a commit that referenced this issue Jun 1, 2018
Add std/core to prelude if extern_prelude enabled

Fixes #50605
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants