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

rustc_resolve: allow only core, std, meta and --extern in Rust 2018 paths. #54116

Merged
merged 7 commits into from
Sep 15, 2018

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Sep 11, 2018

As per #53166 (comment):

  • Rust 2018 imports can no longer refer to crates not in "extern prelude"
    • ::foo won't load a crate named foo unless foo is in the "extern prelude"
    • extern crate foo;, however, remains unchanged (can load arbitrary crates)
  • --extern crate_name is added (note the lack of =path) as an unstable option
    • adds crate_name to the "extern prelude" (see above)
    • crate is searched in sysroot & library paths, just like extern crate crate_name.
    • Cargo support will be added later
  • core, std and proc_macro meta are always available in the extern prelude

Fixes #54006 (as the example now requires --extern alloc, which is unstable).
Fixes #54253 (hit during fixing RLS).

r? @petrochenkov cc @aturon @alexcrichton @Centril @joshtriplett

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 11, 2018
@petrochenkov
Copy link
Contributor

@bors r+

I'm still unhappy about forever hardcoding proc_macro, which can't be off-loaded to the library prelude unlike core/std, in the compiler, but at least it's already hardcoded for other reasons.

@bors
Copy link
Contributor

bors commented Sep 11, 2018

📌 Commit 0bde629b8df4412b210fed0ef4b8b81592a35278 has been approved by petrochenkov

@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-review Status: Awaiting review from the assignee but also interested parties. labels Sep 11, 2018
@eddyb

This comment has been minimized.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 11, 2018
@eddyb

This comment has been minimized.

@aturon
Copy link
Member

aturon commented Sep 11, 2018

LGTM

@rust-highfive

This comment has been minimized.

@eddyb

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@eddyb

This comment has been minimized.

@bors

This comment has been minimized.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 11, 2018
@rust-highfive

This comment has been minimized.

@eddyb eddyb changed the title rustc_resolve: allow only core, std, proc_macro and --extern in Rust 2018 paths. rustc_resolve: allow only core, std and --extern in Rust 2018 paths. Sep 12, 2018
@eddyb

This comment has been minimized.

@bors

This comment has been minimized.

@eddyb eddyb changed the title rustc_resolve: allow only core, std and --extern in Rust 2018 paths. rustc_resolve: allow only core, std, meta and --extern in Rust 2018 paths. Sep 13, 2018
@eddyb

This comment has been minimized.

bors added a commit that referenced this pull request Sep 15, 2018
rustc_resolve: allow only core, std, meta and --extern in Rust 2018 paths.

As per #53166 (comment):
* Rust 2018 imports can no longer refer to crates not in "extern prelude"
  * `::foo` won't load a crate named `foo` unless `foo` is in the "extern prelude"
  * `extern crate foo;`, however, remains unchanged (can load arbitrary crates)
* `--extern crate_name` is added (note the lack of `=path`) as an unstable option
  * adds `crate_name` to the "extern prelude" (see above)
  * crate is searched in sysroot & library paths, just like `extern crate crate_name`.
  * `Cargo` support will be added later
* `core`, `std` and ~~`proc_macro`~~ `meta` are *always* available in the extern prelude
  * warning for interaction with `no_std` / `no_core` will be added later
  * **EDIT**: `proc_macro` was replaced by `meta`, see #53166 (comment)
    * note that there is no crate named `meta` being added, so `use meta::...;` will fail, we're only whitelisting it so we can start producing `uniform_paths` compatibility errors

Fixes #54006 (as the example now requires `--extern alloc`, which is unstable).
Fixes #54253 (hit during fixing RLS).

r? @petrochenkov cc @aturon @alexcrichton @Centril @joshtriplett
@bors
Copy link
Contributor

bors commented Sep 15, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing e4ba1d4 to master...

@bors bors merged commit bde0a54 into rust-lang:master Sep 15, 2018
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #54116!

Tested on commit e4ba1d4.
Direct link to PR: #54116

🎉 clippy-driver on windows: test-fail → test-pass.
🎉 clippy-driver on linux: test-fail → test-pass.

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Sep 15, 2018
Tested on commit rust-lang/rust@e4ba1d4.
Direct link to PR: <rust-lang/rust#54116>

🎉 clippy-driver on windows: test-fail → test-pass.
🎉 clippy-driver on linux: test-fail → test-pass.
@eddyb eddyb deleted the extern-prelude branch September 15, 2018 22:15
@eddyb
Copy link
Member Author

eddyb commented Sep 15, 2018

cc @rust-lang/release I believe this was the last blocker for RC.

@Nemo157
Copy link
Member

Nemo157 commented Sep 18, 2018

This change (I assume) affects benchmarks as use test::Bencher; no longer finds the test crate. Presumable any test using test::black_box is similarly affected. Should the test crate also be included for test targets, or should these still use extern crate test;? (I’m not sure which tracking issue actually covers the extern prelude stuff, so I’ll just leave this here).

@eddyb
Copy link
Member Author

eddyb commented Sep 18, 2018

@Nemo157 extern crate until we get something else like [dependencies] test = "builtin" into Cargo.

tikue added a commit to tikue/tarpc that referenced this pull request Sep 19, 2018
bors added a commit that referenced this pull request Oct 27, 2018
Add option to run all tests, again

This is a repeat of #53527, which had to be reverted to land #54116. It will break clippy until `compiletest-rs` can be updated and I believe we're closing on a new release date, so this may need to be delayed again until after 1.30 is out (?)

Closes #50363 again
@Centril Centril mentioned this pull request Jun 2, 2019
Centril added a commit to Centril/rust that referenced this pull request Nov 7, 2019
Stabilize --extern flag without a path.

This stabilizes the `--extern` flag without a path, implemented in rust-lang#54116.

This flag is used to add a crate that may be found in the search path to the extern prelude. The intent of stabilizing this now is to change Cargo to emit this flag for `proc_macro` when building a proc-macro crate. This will allow the ability to elide `extern crate proc_macro;` for proc-macros, one of the few places where it is still necessary.

It is intended that Cargo may also use this flag for other cases in the future as part of the [std-aware work](https://github.com/rust-lang/wg-cargo-std-aware/). There will likely be some kind of syntax where users may declare dependencies on other crates (such as `alloc`), and Cargo will use this flag so that they may be used like any other crate. At this time there are no short-term plans to use it for anything other than proc-macro.

This will not help for non-proc-macro crates that use `proc_macro`, which I believe is not too common?

An alternate approach for proc-macro is to use the `meta` crate, but from my inquiries there doesn't appear to be anyone interested in pushing that forward. The `meta` crate also doesn't help with things like `alloc` or `test`.

cc rust-lang#57288
Centril added a commit to Centril/rust that referenced this pull request Nov 7, 2019
Stabilize --extern flag without a path.

This stabilizes the `--extern` flag without a path, implemented in rust-lang#54116.

This flag is used to add a crate that may be found in the search path to the extern prelude. The intent of stabilizing this now is to change Cargo to emit this flag for `proc_macro` when building a proc-macro crate. This will allow the ability to elide `extern crate proc_macro;` for proc-macros, one of the few places where it is still necessary.

It is intended that Cargo may also use this flag for other cases in the future as part of the [std-aware work](https://github.com/rust-lang/wg-cargo-std-aware/). There will likely be some kind of syntax where users may declare dependencies on other crates (such as `alloc`), and Cargo will use this flag so that they may be used like any other crate. At this time there are no short-term plans to use it for anything other than proc-macro.

This will not help for non-proc-macro crates that use `proc_macro`, which I believe is not too common?

An alternate approach for proc-macro is to use the `meta` crate, but from my inquiries there doesn't appear to be anyone interested in pushing that forward. The `meta` crate also doesn't help with things like `alloc` or `test`.

cc rust-lang#57288
bors added a commit that referenced this pull request Nov 8, 2019
Stabilize --extern flag without a path.

This stabilizes the `--extern` flag without a path, implemented in #54116.

This flag is used to add a crate that may be found in the search path to the extern prelude. The intent of stabilizing this now is to change Cargo to emit this flag for `proc_macro` when building a proc-macro crate. This will allow the ability to elide `extern crate proc_macro;` for proc-macros, one of the few places where it is still necessary.

It is intended that Cargo may also use this flag for other cases in the future as part of the [std-aware work](https://github.com/rust-lang/wg-cargo-std-aware/). There will likely be some kind of syntax where users may declare dependencies on other crates (such as `alloc`), and Cargo will use this flag so that they may be used like any other crate. At this time there are no short-term plans to use it for anything other than proc-macro.

This will not help for non-proc-macro crates that use `proc_macro`, which I believe is not too common?

An alternate approach for proc-macro is to use the `meta` crate, but from my inquiries there doesn't appear to be anyone interested in pushing that forward. The `meta` crate also doesn't help with things like `alloc` or `test`.

cc #57288
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
8 participants