Skip to content

std_instead_of_core/etc. miss macros #17260

Description

@bushrat011899

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:

use std::writeln;

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions