Skip to content

unstable alloc crate can be used without feature gates on the 2018 edition #54006

Closed

Description

@japaric

STR

This compiles when edition = "2018"

// crate-type: lib
#![no_std]

use alloc::vec;

fn foo() {
    let mut xs = vec![];
    xs.push(0);
}

This doesn't compile when edition = "2015" because it needs a feature gate.

// crate-type: lib
#![no_std]

extern crate alloc; //~ ERROR use of unstable library feature `alloc`

use alloc::vec;

fn foo() {
    let mut xs = vec![];
    xs.push(0);
}

Meta

$ rustc -V
rustc 1.30.0-nightly (6e0f1cc15 2018-09-05)

Activity

  1. added
    P-highHigh priority
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Sep 7, 2018
  2. Centril commented on Sep 7, 2018

    @Centril
    Contributor

    Marking as P-high due to edition urgency.

  3. alexcrichton commented on Sep 10, 2018

    @alexcrichton
    Member

    This sounds the same as #52489, curious! cc @eddyb

  4. eddyb commented on Sep 10, 2018

    @eddyb
    Contributor

    @alexcrichton Uhhhh this is because we can't stability-check intermediary path components.
    alloc::vec is stable, it's just alloc that's not - this is the same as std::intrinsics::transmute.

    cc @petrochenkov This seems much worse than usual.

    OTOH, I do have a branch where you have to use extern crate alloc; or pass --extern alloc to the compiler, that I'm working on right now. Would that alleviate the issue for now?

  5. alexcrichton commented on Sep 10, 2018

    @alexcrichton
    Member

    Ah yes, indeed!

    The "intermediary path components stability doesn't work" has never been high priority because the root crate always had to be listed as extern crate foo. I would agree that if you don't have to write extern crate foo this is definitely much higher priority now

  6. nikomatsakis commented on Sep 13, 2018

    @nikomatsakis
    Contributor

    Can't we check the stability when we do the lazy path resolution?

  7. nikomatsakis commented on Sep 13, 2018

    @nikomatsakis
    Contributor

    Sorry, that's not very clear. What I meant is:

    Can we do the stability checking when we first load the crate?

  8. pnkfelix commented on Sep 13, 2018

    @pnkfelix
    Contributor

    Visited for triage. Assigning to @eddyb, who sounds like they are on the case.

  9. nikomatsakis commented on Sep 13, 2018

    @nikomatsakis
    Contributor

    Another question:

    Can you specify --extern to access alloc without a feature gate?

  10. nikomatsakis commented on Sep 13, 2018

    @nikomatsakis
    Contributor

    (If you invoke rustc manually, or maybe by cajoling cargo sufficiently)

  11. eddyb commented on Sep 13, 2018

    @eddyb
    Contributor

    @nikomatsakis The only way you can access the sysroot crate without knowing its path is the new --extern alloc (without a path), that's being added in #54116, which is unstable.

    We can't check stability when we load the crate, because that happens before the query engine is set up, and it's a pretty messy right now to get any useful information across.

    What we could do is try to get a stability check into #54145.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions