-
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
(Modules) Tracking issue for (use) crate_name::
paths without extern crate
#53128
Comments
I feel that the deprecation of Note that while we're still talking about the final system for paths in @rfcbot fcp merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged teams: Concerns:
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 concern macros We shouldn't stabilize this until we first stabilize the macro system changes needed to deprecate |
Not really a concern, but some tradeoffs about automatic inclusion of external crates in the prelude, mostly from internals thread. In Rust 2015, there are two ways to refer to extern crate
Extern crates in prelude adds a third one:
This third variant is easier to type, but it gives the least amount of information to the reader.
It is also seems to be the case that adding extern crates to the prelude is not required to make other module systems changes "work". Specifically, ergonimics is not regressed compared to Rust 2015: It is true that some use statements might be dropped with this feature in 2018. The original motivation for this feature was to fix path confusion: the fact that paths in use statements and everywhere else work differently. This is only a partial fix though:
TL;DR extern crates in prelude
|
#53130 is about paths in use statements. The addition of crates to prelude affects paths outside of use statements. I.e., even with |
Ah, right. I am only commenting as production user of Rust and haven’t paid close attention to the whole discussion/RFCs so please bear with me. 🙂 |
The devil is in the details, and the most devilish detail here is which syntax to pick to refer to external crates. The two options are
|
I second that the second solution is obviously right, vis-à-vis. It’s a pity some programmers dislike verbosity so much they would rather introduce ambiguity... But there’s a discrepancy still, given Update
I’m sure this idea isn’t specified carefully enough yet, but I hope we can have fruitful discussion at least. |
Would for example |
@SimonSapin
|
@SimonSapin @petrochenkov So there's one more concern, that @aturon and @joshtriplett raised when discussing #52923 (that I'm not sure is written down anywhere else), around the fact that
Alternatively, we can make |
@eddyb For the record, for the moment I'd favor the solution of having the |
I haven’t followed the details of the different path proposals, I mostly wanted to remind that there can be more crate than Cargo dependencies and |
@SimonSapin to clarify, @joshtriplett is talking specifically about "sysroot" crates (like |
@aturon Are you suggesting that all sysroot crates would always be specified through |
Not automatically; they'd need to be specified explicitly in order to use them, via some "allow the use of this sysroot crate" option (and equivalent in
That's exactly the concern, and we want to avoid that. In the short term, we'll probably just continue requiring |
I just encountered another case where you still require some explicit inclusion of a dependency with this new system: crates which have a public API of only a lang item like |
This isn't changing. You still have |
@spearman Because the build system has to know about it, and it shouldn't appear in two places. Regarding fmod, and other crates that differ from their package names, I wonder if it might be worth going through those and working with their authors to transition to having the two match, for simplicity's sake alone? |
@joshtriplett: Yes please! There’s also the difference in acceptance of |
@joshtriplett I'm arguing it should appear in both places because they do different things: extern crate in a root module declares an external dependency, and the dependency entry in the cargo manifest tells the build system where to find that dependency (whether it's on crates.io, is a git repository, or a local path, etc.) |
@sanmai-NL so does this become this? or this |
The latter. It remains unambiguous though that |
@rust-lang/lang From what I can tell there's nothing left to do here? Shall we close this issue? |
This generates a warning on nightly, not on stable: |
@spearman It's correct to generate a warning for that code-- the use of |
Previously warn(unused_extern_crates) was a way to detect unused dependencies. How can I:
As it is now, cargo builds all dependencies and does not warn if they are unused. |
@spearman You cannot currently do what you describe. |
That seems unfortunate... perhaps its worth it's own issue? |
@mark-i-m Yeah, I'd create one. A PR to add a new lint for this probably wouldn't be too hard. |
Opened #57274 |
I believe this is done now so I'll close this out. |
@Centril Was this issue supposed to cover getting rid of extern crate altogether? Because we have not done that yet; you still need it for core, std, etc |
@mark-i-m Are you referring to how std-surfaced macro intrinsics aren't yet usable by their std paths? e.g. This code only works if you remove fn main() {
println!("{}", std::format_args!("{}", 5));
}
|
@cramertj Not sure. It might be related. I was thinking more about how one must do things like |
@mark-i-m Could you create targeted issues for the remaining work if there is any? That way it's easier to triage... :) |
@mark-i-m It is a different issue. Sure, if you would that would be great! |
Done. #57289 :) |
This is a sub-tracking issue for the RFC "Clarify and streamline paths and visibility" (rust-lang/rfcs#2126)
dealing with the deprecation of
extern crate
as well as havinguse crate_name::foo::bar
andcrate_name::foo::bar
Just Work™.#[macro_use] extern crate
.#[macro_export(local_inner_macros)]
(a solution for the macro helper import problem) #51496Unresolved questions:
None
The text was updated successfully, but these errors were encountered: