-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't require extern crate
#57288
Comments
Requiring |
Is there a tracking issue for this? It seems like there is some design work that needs to be done, but it's not clear who is responsible (cargo, lang, or compiler). |
@cramertj Are you saying this is more blocked on some sort of std-aware cargo? Also, I get that concern for |
No, std-aware cargo is completely unrelated. This is about exposing the existing, but unstable, |
Also please include tracking here for removing the need for |
@dekellum Indeed-- same issue. |
You only need to Automatically injecting EDIT: Actually, rechecking #54116 it appears that |
For whatever reason, I have needed to do |
The issue should probably use |
These are both unstable crates so IMO lower priority than |
Also, this is not only about sysroot, but about any crates in library search directories. |
Ah, my mistake I went back and looked at the code, and it was |
I just ran into this in a proc macro crate. Notwithstanding the possibility that [dependencies]
proc_macro = { builtin = true } I know it's not technically builtin, it's actually provided by the distribution. But to a user it feels like it's a builtin. |
@alercah This isn't only for builtin crates, but for anything that should be pulled in from library search directories (could be arbitrary crates). |
What is the next required step for this, does it require an RFC, or can it be implemented as an unstable feature in Cargo without that? If the latter, should there be a separate Cargo issue opened to track actually getting some feature implemented there that will solve this? (Somewhat related to this issue, should there be a tracking issue for what is happening around |
extern crate
for sysroot cratesextern crate
for sysroot crates
cc @rust-lang/cargo |
As far as I understand this issue applies to the |
Tracking issue note: At the same time, EDIT: you need to say |
Would people be for or against stabilizing the bare This doesn't immediately help for other crates, but would pave the way for future changes in cargo that might allow making these dependencies explicit. |
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
extern crate
for sysroot cratesextern crate
What is the status of this now that |
The status is largely unchanged. Cargo uses
|
Breaking out from #53128
Currently,
extern crate
is still required for sysroot crates, liketest
,proc_macro
,core
orstd
. One needs toextern crate
themfor use inunless they are implicitly imported (likeno_std
cratesstd
is without#![no_std]
, orcore
with it).This is the tracking issue for making them not require
extern crate
.The text was updated successfully, but these errors were encountered: