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

Stabilize `extern_crate_item_prelude` #56032

Merged
merged 2 commits into from Nov 21, 2018

Conversation

@petrochenkov
Contributor

petrochenkov commented Nov 17, 2018

Closes #55599

@petrochenkov

This comment has been minimized.

Contributor

petrochenkov commented Nov 17, 2018

@petrochenkov

This comment has been minimized.

Contributor

petrochenkov commented Nov 17, 2018

Stabilization report

Feature name: #![feature(extern_crate_item_prelude)]
Version target: 1.31 (2018-12-07) aka 2018 edition release

Implemented in #54658 and landed 23 days ago.
Tracking issue is #55599.
Documentation issue is rust-lang-nursery/reference#466.
Tests for the feature can be found in src/test/ui/imports/extern-prelude-extern-crate-*.rs and src/test/ui-fulldeps/proc-macro/extern-prelude-extern-crate-*.rs.

Why it's desirable to stabilize for the edition release

The feature provides the same usage model for "normal" crates (passed with --extern or core/std) and crates that cannot be passed with --extern on stable like proc_macro, alloc or rustc_* crates.

As a result this code "just works" on 2018 edition:

extern crate proc_macro;

use proc_macro::TokenStream;

If this is not stabilized for the edition release, nothing too terrible happens, but users of the aforementioned crates will have to use them like something from the local crate for some time (e.g. until the next release).

extern crate proc_macro;

use crate::proc_macro::TokenStream;

What is being stabilized

If item extern crate orig_name as rename; is placed into the crate root, then it adds name rename into the "extern prelude".
If item extern crate orig_name; is placed into the crate root, then it adds name orig_name into the "extern prelude".

If the name foo is in extern prelude, then 1) it's in scope in the whole crate including inner modules and 2) absolute paths on 2018 edition can refer to it.

extern crate foo;

mod m  {
    use foo; // OK
    use ::foo; // OK

    let x = foo::bar; // OK
    let x = ::foo::bar; // OK
}

Some details and corner cases

If extern crate is placed in non-root module, then it doesn't add anything into extern prelude.
This means there's opt-out from this feature:

mod inner {
    pub(crate) extern crate foo;
}
use inner::foo;

If name is first added to extern prelude with --extern name and then with extern crate other_totally_unrelated_crate as name;, then the second one wins and name will refer to the other totally unrelated crate.

Macro expanded extern crate items still add names to extern prelude, however such items cannot override names passes with --extern (there's a dedicated error). This is a special case of a more general rule.

Interactions of the feature with unstable macros 2.0 are were buggy (#55668), but the bug is already fixed in #55884.

@Centril

This comment has been minimized.

Contributor

Centril commented Nov 19, 2018

I propose that we stabilize #![feature(extern_crate_item_prelude)] in 1.31 (-> beta branch) per the report given in #56032 (comment).

@rfcbot merge

@rfcbot

This comment has been minimized.

rfcbot commented Nov 19, 2018

Team member @Centril has proposed to merge this. The next step is review by the rest of the tagged teams:

No concerns currently listed.

Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@bors

This comment has been minimized.

Contributor

bors commented Nov 19, 2018

☔️ The latest upstream changes (presumably #56042) made this pull request unmergeable. Please resolve the merge conflicts.

@Centril Centril added this to the Rust 2018 Release milestone Nov 19, 2018

@alexcrichton

This comment has been minimized.

Member

alexcrichton commented Nov 19, 2018

@bors: p=1

beta nominated

@nikomatsakis

This comment has been minimized.

Contributor

nikomatsakis commented Nov 20, 2018

(I checked @pnkfelix as they are on PTO)

@rfcbot

This comment has been minimized.

rfcbot commented Nov 20, 2018

🔔 This is now entering its final comment period, as per the review above. 🔔

@nikomatsakis nikomatsakis referenced this pull request Nov 20, 2018

Merged

beta backport rollup #56102

20 of 20 tasks complete

@petrochenkov petrochenkov force-pushed the petrochenkov:stabecip branch from e3f8134 to d4934c7 Nov 20, 2018

@petrochenkov

This comment has been minimized.

Contributor

petrochenkov commented Nov 20, 2018

@bors r=nikomatsakis

@bors

This comment has been minimized.

Contributor

bors commented Nov 20, 2018

📌 Commit d4934c7 has been approved by nikomatsakis

bors added a commit that referenced this pull request Nov 20, 2018

Auto merge of #56102 - nikomatsakis:beta, r=alexcrichton
beta backport rollup

Backports of some beta-approved PRs

- [x] #55385: NLL: cast causes failure to promote to static
- [x] #56043: remove "approx env bounds" if we already know from trait
- [x] #56003: do not propagate inferred bounds on trait objects if they involve `Self`
- [x] #55852: Rewrite `...` as `..=` as a `MachineApplicable` 2018 idiom lint
- [x] #55804: rustdoc: don't inline `pub use some_crate` unless directly asked to
- [x] #56059: Increase `Duration` approximate equal threshold to 1us
- [x]  Keep resolved defs in path prefixes and emit them in save-analysis #54145
- [x]  Adjust Ids of path segments in visibility modifiers #55487
- [x]  save-analysis: bug fix and optimisation. #55521
- [x]   save-analysis: be even more aggressive about ignorning macro-generated defs #55936
- [x]  save-analysis: fallback to using path id #56060
- [x]  save-analysis: Don't panic for macro-generated use globs #55879
- [x]  Add temporary renames to manifests for rustfmt/clippy #56081
- [x] Revert #51601 #56049
- [x]  Fix stability hole with `static _` #55983
- [x] #56077
- [x] Fix Rustdoc ICE when checking blanket impls #55258
- [x]  Updated RELEASES.md for 1.31.0 #55678
- [x] ~~#56061~~ #56111
- [x]  Stabilize `extern_crate_item_prelude` #56032

Still running tests locally, and I plan to backport @nrc's other PRs too

(cc @petrochenkov -- thanks for the advice)
@bors

This comment has been minimized.

Contributor

bors commented Nov 21, 2018

⌛️ Testing commit d4934c7 with merge 780658a...

bors added a commit that referenced this pull request Nov 21, 2018

Auto merge of #56032 - petrochenkov:stabecip, r=nikomatsakis
Stabilize `extern_crate_item_prelude`

Closes #55599
@bors

This comment has been minimized.

Contributor

bors commented Nov 21, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 780658a to master...

@bors bors merged commit d4934c7 into rust-lang:master Nov 21, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@Centril Centril added the relnotes label Nov 22, 2018

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