Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up(Modules) Tracking issue for `(use) crate_name::` paths without `extern crate` #53128
Comments
Centril
added
B-RFC-approved
T-lang
C-tracking-issue
labels
Aug 6, 2018
Centril
referenced this issue
Aug 6, 2018
Closed
Tracking issue for RFC 2126: Clarify and streamline paths and visibility #44660
This comment has been minimized.
This comment has been minimized.
|
I feel that the deprecation of Note that while we're still talking about the final system for paths in @rfcbot fcp merge |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Aug 6, 2018
•
|
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
added
proposed-final-comment-period
disposition-merge
labels
Aug 6, 2018
This comment has been minimized.
This comment has been minimized.
|
@rfcbot concern macros We shouldn't stabilize this until we first stabilize the macro system changes needed to deprecate |
rfcbot
added
proposed-final-comment-period
disposition-merge
labels
Aug 6, 2018
Centril
added this to the Rust 2018 RC milestone
Aug 6, 2018
This comment has been minimized.
This comment has been minimized.
|
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
|
This comment has been minimized.
This comment has been minimized.
sanmai-NL
commented
Aug 7, 2018
This comment has been minimized.
This comment has been minimized.
|
#53130 is about paths in use statements. The addition of crates to prelude affects paths outside of use statements. I.e., even with |
This comment has been minimized.
This comment has been minimized.
sanmai-NL
commented
Aug 7, 2018
|
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. |
This comment has been minimized.
This comment has been minimized.
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
|
This comment has been minimized.
This comment has been minimized.
sanmai-NL
commented
Aug 7, 2018
•
|
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. |
This comment has been minimized.
This comment has been minimized.
rfcbot
added
proposed-final-comment-period
disposition-merge
labels
Aug 7, 2018
This comment has been minimized.
This comment has been minimized.
|
Would for example |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin
|
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
@eddyb For the record, for the moment I'd favor the solution of having the |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin to clarify, @joshtriplett is talking specifically about "sysroot" crates (like |
This comment has been minimized.
This comment has been minimized.
|
@aturon Are you suggesting that all sysroot crates would always be specified through |
This comment has been minimized.
This comment has been minimized.
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 |
This comment has been minimized.
This comment has been minimized.
|
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 comment has been minimized.
This comment has been minimized.
This isn't changing. You still have |
This comment has been minimized.
This comment has been minimized.
|
@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? |
This comment has been minimized.
This comment has been minimized.
sanmai-NL
commented
Oct 20, 2018
|
@joshtriplett: Yes please! There’s also the difference in acceptance of |
This comment has been minimized.
This comment has been minimized.
spearman
commented
Oct 20, 2018
|
@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.) |
This comment has been minimized.
This comment has been minimized.
sanmai-NL
commented
Oct 20, 2018
•
This comment has been minimized.
This comment has been minimized.
spearman
commented
Oct 20, 2018
|
@sanmai-NL so does this become this? or this |
This comment has been minimized.
This comment has been minimized.
sanmai-NL
commented
Oct 20, 2018
•
|
The latter. It remains unambiguous though that |
dekellum
referenced this issue
Nov 28, 2018
Closed
2018 edition module/path changes don't work for libtest benchmarks #55133
acmcarther
referenced this issue
Dec 11, 2018
Open
Support renaming dependencies in rust_library and rust_binary #171
This comment has been minimized.
This comment has been minimized.
|
@rust-lang/lang From what I can tell there's nothing left to do here? Shall we close this issue? |
This comment has been minimized.
This comment has been minimized.
spearman
commented
Dec 22, 2018
•
|
This generates a warning on nightly, not on stable: |
This comment has been minimized.
This comment has been minimized.
|
@spearman It's correct to generate a warning for that code-- the use of |
This comment has been minimized.
This comment has been minimized.
spearman
commented
Dec 26, 2018
|
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. |
This comment has been minimized.
This comment has been minimized.
|
@spearman You cannot currently do what you describe. |
This comment has been minimized.
This comment has been minimized.
|
That seems unfortunate... perhaps its worth it's own issue? |
This comment has been minimized.
This comment has been minimized.
|
@mark-i-m Yeah, I'd create one. A PR to add a new lint for this probably wouldn't be too hard. |
This comment has been minimized.
This comment has been minimized.
|
Opened #57274 |
This comment has been minimized.
This comment has been minimized.
|
I believe this is done now so I'll close this out. |
Centril
closed this
Jan 2, 2019
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
@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));
}
|
This comment has been minimized.
This comment has been minimized.
|
@cramertj Not sure. It might be related. I was thinking more about how one must do things like |
This comment has been minimized.
This comment has been minimized.
|
@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
referenced this issue
Jan 2, 2019
Open
Tracking issue for no more `extern crate` for sysroot crates #57288
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@mark-i-m It is a different issue. Sure, if you would that would be great! |
mark-i-m
referenced this issue
Jan 2, 2019
Open
Tracking issue for making std-surfaced macro intrinsics available via `std::` paths #57289
This comment has been minimized.
This comment has been minimized.
|
Done. #57289 :) |
Centril commentedAug 6, 2018
•
edited
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 crateas well as havinguse crate_name::foo::barandcrate_name::foo::barJust Work™.#[macro_use] extern crate.Unresolved questions:
None