-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Rustc does not warn about use
with paths incompatible with uniform_paths
for edition 2018
#53797
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
Comments
The error is emitted during name resolution: rust/src/librustc_resolve/resolve_imports.rs Lines 721 to 733 in ee73f80
To make this rustfix-able, we would want to reformulate the |
@zackmdavis That's not enough. What needs to happen is the canaries need to be injected in Rust 2015 before switching to Rust 2018, and that's where the correct suggestions can be generated, because we know what the user meant (in the working Rust 2015 code). I've been meaning to do this ever since I realized it's actually plausible with the way the canaries are implemented, because we can inject them in more situations, and provide different diagnostics. |
@eddyb what is the story with this one? |
@nikomatsakis I didn't get to it, but also I've started to doubt the idea of reusing canaries. |
Discussed at compiler team meeting. This seems important enough to resolve that it should remain on the RC2 milestone. |
I just tested this locally and the most important instance ( |
The example works now, as the |
Closing for now — the problem described in this issue is fixed, though there may be a more general bug (we should try to make a test case for that?). |
You can still reproduce this by having a local item (in the type/module namespace), with the same name, e.g. this triggers the error on the playground, on beta & nightly: extern crate rayon;
mod foo {
mod rayon {}
use rayon::Scope;
} I added |
OK, I'm going to re-open, but move to Rust 2018 Release milestone, since I think that we can probably address this with some targeted tweaks and it seems like it will not affect The Entire World. |
BTW, there is discussion on Zulip and in particular starting around here we are talking about the new reproduction |
removing old nomination tag. |
visited for T-compiler triage. Marking P-high, since it is on the 2018 Release milestone. |
@petrochenkov does your PR address this issue? |
No, it doesn't. |
I haven't added any new lints on 2015 edition (which is this issue about), only uniform path reimplementation on 2018 edition. |
I've updated the OP to reflect the current status here @nikomatsakis it sounds like on the discussion linked you had a strawman of how to fix this. Did you get a chance to test that out? Or is someone lined up to fix this perhaps in a different fashion? |
I do think this is plausible to fix with a "quick hack". I might try to pull it off today, though I'm not sure how important it is. The original example no longer applies, and it's not clear how common the pattern described above is in real code. |
I think I'd agree as well that this, while still a bug, is likely no longer edition-critical. Any opposition to removing it from the milestone and removing P-high? |
@alexcrichton sgtm, I didn't get to do any work on this today |
Another example, encountered by a user: #![deny(rust_2018_compatibility)]
extern crate ptr;
pub mod foo {
pub use std::ptr;
pub use ptr::Shared;
} Does not generate any errors/warnings, but fails to compile on 2018. |
I think at this point we can close this bug -- we're not probably going to go back and make more changes here, the transition code seems to have worked "well enough". (On the other hand, we could leave it open to collect more examples that we may someday go back and fix, I suppose.) |
Updated Description:
This code generates no warnings when compiled with the 2015 edition:
but when compiled with the 2018 edition fails to compile:
Old Description
Rustc does not warn about
use
with paths incompatible withuniform_paths
for edition 2018. This means that rustfix it will not fix your code for edition 2018.To reproduce create the following project:
Cargo.toml
:src/lib.rs
:If you run
cargo +nightly check
you will not get any warning, which means that when you runcargo +nightly fix --edition
nothing will change, but the code is not compilable in rust 2018. ChangeCargo.toml
to enable edition 2018 (by addingcargo-features = ["edition"]
andpackage.edition = "2018"
) and runcargo +nightly build
:cargo +nightly fix --edition
should have changed line 4 touse ::criterion::Criterion
.Ref: Bug in cargo: rust-lang/cargo#5905
The text was updated successfully, but these errors were encountered: