-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
std_instead_of_core: false positive with std::env since nightly-2024-03-08 #12438
Comments
rust-lang/rust-clippy#12438 ``` error: used import from `std` instead of `core` --> src/lib.rs:134:5 | 134 | use std::{ | ^^^ help: consider importing the item from `core`: `core` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#std_instead_of_core = note: `-D clippy::std-instead-of-core` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::std_instead_of_core)]` ```
Yeah it's definitely caused by that, I didn't see it until now since I updated the expected output file, and didn't notice the erroneous fix from |
Yep, pretty stupid mistake, got a PR with the fix here #12447 preserves the bugfix that it was supposed to achieve. |
Fix #12438 std_instead_of_core regression Fixes #12438. Boy-scouting removed two paths that checks for duplication since I thought they were unused. However, that's just because I didn't spot it in the diff. I installed [difftastic](https://github.com/Wilfred/difftastic) and ran it on the old one: ![image](https://github.com/rust-lang/rust-clippy/assets/34198073/5c51276c-055a-49a3-9425-6f7da0590fb0) And the new one (fixed): ![image](https://github.com/rust-lang/rust-clippy/assets/34198073/6e10f29c-6d6b-4f64-893f-de526424f1cd) New one (stderr): ![image](https://github.com/rust-lang/rust-clippy/assets/34198073/c4c07776-ee0f-47ba-996f-6b632de47c81) Good teachings for the future when inspecting diffs with a lot of line changes, should've thought of that before, sorry for the trouble! changelog: [`std_instead_of_core`] Fix false positive for crates that are in `std` but not `core`
@MarcusGrass @bors Just to note, I ran into this issue just now, after updating to 1.78.0 stable. I checked Git and it seems that although this fix was merged to |
- Disabled the clippy::std_instead_of_core lint for the std module due to a false positive on std::env, which is due to the following bug: rust-lang/rust-clippy#12438 The fix had to be applied globally otherwise it triggered a "useless lint attribute" warning, which may be another bug! rust-lang/rust-clippy#1938
Oh no that was a real miss, I'm fairly new to this project and didn't realize that the fix might miss the merge window, I'm sorry about that |
- Removed the clippy::std_instead_of_core lint workaround for the false positive on std::env, which was due to the following bug (now fixed): rust-lang/rust-clippy#12438
Summary
Since nightly-2024-03-08, it seems that std_instead_of_core is not correctly handling cases where macros and modules have the same name.
Probably related to #12406, cc @MarcusGrass
Lint Name
std_instead_of_core
Reproducer
I tried this code:
I saw this happen:
However, replacing
std::env
withcore::env
causes compile error:I expected to see this happen: no warning
Version
Additional Labels
@rustbot label +I-suggestion-causes-error
The text was updated successfully, but these errors were encountered: