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

Stabilize extern_crate_item_prelude #56032

Merged
merged 2 commits into from
Nov 21, 2018
Merged

Conversation

petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Nov 17, 2018

Closes #55599

@petrochenkov petrochenkov added beta-nominated Nominated for backporting to the compiler in the beta channel. T-lang Relevant to the language team, which will review and decide on the PR/issue. S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Nov 17, 2018
@petrochenkov
Copy link
Contributor Author

r? @Centril

@petrochenkov
Copy link
Contributor Author

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/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
Copy link
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
Copy link

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.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Nov 19, 2018
@bors
Copy link
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
@nikomatsakis nikomatsakis added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Nov 19, 2018
@alexcrichton
Copy link
Member

@bors: p=1

beta nominated

@nikomatsakis
Copy link
Contributor

(I checked @pnkfelix as they are on PTO)

@rfcbot
Copy link

rfcbot commented Nov 20, 2018

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

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Nov 20, 2018
@nikomatsakis nikomatsakis mentioned this pull request Nov 20, 2018
20 tasks
@petrochenkov
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Nov 20, 2018

📌 Commit d4934c7 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Nov 20, 2018
bors added a commit that referenced this pull request Nov 20, 2018
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
Copy link
Contributor

bors commented Nov 21, 2018

⌛ Testing commit d4934c7 with merge 780658a...

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

Closes #55599
@bors
Copy link
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
@alexcrichton alexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 21, 2018
@Centril Centril added the relnotes Marks issues that should be documented in the release notes of the next release. label Nov 22, 2018
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Nov 30, 2018
@petrochenkov petrochenkov deleted the stabecip branch June 5, 2019 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants