-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
@bors r+ I'm still unhappy about forever hardcoding |
📌 Commit 0bde629b8df4412b210fed0ef4b8b81592a35278 has been approved by |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
LGTM |
0bde629
to
59716b9
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
59716b9
to
d9c1f50
Compare
This comment has been minimized.
This comment has been minimized.
5b0a246
to
cb26bfe
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cb26bfe
to
94ec027
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
94ec027
to
b781d57
Compare
This comment has been minimized.
This comment has been minimized.
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
☀️ Test successful - status-appveyor, status-travis |
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.
cc @rust-lang/release I believe this was the last blocker for RC. |
This change (I assume) affects benchmarks as |
@Nemo157 |
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
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
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
As per #53166 (comment):
::foo
won't load a crate namedfoo
unlessfoo
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 optioncrate_name
to the "extern prelude" (see above)extern crate crate_name
.Cargo
support will be added latercore
,std
andproc_macro
meta
are always available in the extern preludeno_std
/no_core
will be added laterproc_macro
was replaced bymeta
, see std-using paths work just fine in 2018 edition #![no_std] #53166 (comment)meta
being added, souse meta::...;
will fail, we're only whitelisting it so we can start producinguniform_paths
compatibility errorsFixes #54006 (as the example now requires
--extern alloc
, which is unstable).Fixes #54253 (hit during fixing RLS).
r? @petrochenkov cc @aturon @alexcrichton @Centril @joshtriplett