Summary
std_instead_of_core and friends explicitly do not lint for macros. This was done to avoid linting std::env, which refers to the module std::env and the macro core::env. However, this also causes other macros, such as writeln, stringify, etc. to be missed.
#17252 changes how the lints generate suggestions in a way that resolves this issue. All that's missing is the removal of the explicit bail-out for macros:
|
&& !matches!(def_kind, DefKind::Macro(_)) |
Which should be done in a follow-up PR.
Lint Name
std_instead_of_core
Reproducer
I tried this code:
I expected to see this happen:
std_instead_of_core should suggest replacing the above with use core::writeln;
Instead, this happened:
The lint is not triggered.
Version
rustc 1.98.0-nightly (485ec3fbc 2026-06-10)
binary: rustc
commit-hash: 485ec3fbcc12fa14ef6596dabb125ad710499c9e
commit-date: 2026-06-10
host: x86_64-pc-windows-msvc
release: 1.98.0-nightly
LLVM version: 22.1.6
Summary
std_instead_of_coreand friends explicitly do not lint for macros. This was done to avoid lintingstd::env, which refers to the modulestd::envand the macrocore::env. However, this also causes other macros, such aswriteln,stringify, etc. to be missed.#17252 changes how the lints generate suggestions in a way that resolves this issue. All that's missing is the removal of the explicit bail-out for macros:
rust-clippy/clippy_lints/src/std_instead_of_core.rs
Line 131 in d7246b0
Which should be done in a follow-up PR.
Lint Name
std_instead_of_core
Reproducer
I tried this code:
I expected to see this happen:
std_instead_of_coreshould suggest replacing the above withuse core::writeln;Instead, this happened:
The lint is not triggered.
Version