-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Closed
Copy link
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
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:
#![allow(dead_code)]
#![warn(clippy::std_instead_of_core)]
use std::env;
fn f() -> Option<String> {
env::var("FOO").ok()
}
I saw this happen:
warning: used import from `std` instead of `core`
--> src/lib.rs:4:5
|
4 | use std::env;
| ^^^ help: consider importing the item from `core`: `core`
|
However, replacing std::env
with core::env
causes compile error:
#![allow(dead_code)]
#![warn(clippy::std_instead_of_core)]
use core::env;
fn f() -> Option<String> {
env::var("FOO").ok()
}
error[E0433]: failed to resolve: use of undeclared crate or module `env`
--> src/lib.rs:7:5
|
7 | env::var("FOO").ok()
| ^^^ use of undeclared crate or module `env`
|
help: consider importing this module
|
4 + use std::env;
|
I expected to see this happen: no warning
Version
rustc 1.78.0-nightly (9c3ad802d 2024-03-07)
binary: rustc
commit-hash: 9c3ad802d9b9633d60d3a74668eb1be819212d34
commit-date: 2024-03-07
host: aarch64-apple-darwin
release: 1.78.0-nightly
LLVM version: 18.1.0
Additional Labels
@rustbot label +I-suggestion-causes-error
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied