Skip to content

fix(lint): std_instead_of_core false positives for core::io/MSRV#16964

Open
bushrat011899 wants to merge 1 commit intorust-lang:masterfrom
bushrat011899:std_instead_of_core_io_in_core_false_positive
Open

fix(lint): std_instead_of_core false positives for core::io/MSRV#16964
bushrat011899 wants to merge 1 commit intorust-lang:masterfrom
bushrat011899:std_instead_of_core_io_in_core_false_positive

Conversation

@bushrat011899
Copy link
Copy Markdown

@bushrat011899 bushrat011899 commented May 5, 2026

Objective

Solution

Previously the lint had an exception for all instances of a stable item in an unstable module, primarily to allow certain intrinsics such as copy to be accessible. Instead, I check for the presence of rustc_allowed_through_unstable_modules to handle those exceptions, and allow the is_stable check within the lint to early out as soon as any part of its path is unstable.

I believe this was the last piece required to resolve #13158, and have added tests for all examples listed in the issue. If there are other examples of this lint failing, I'd greatly appreciate seeing them!


Notes


Please write a short comment explaining your change (or "none" for internal only changes)

changelog: fix certain false positives for [std_instead_of_core] for stable items in an unstable module (e.g., core::io::ErrorKind), and other MSRV-unaware issues.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 5, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 5, 2026

r? @Jarcho

rustbot has assigned @Jarcho.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Lintcheck changes for bc66086

Lint Added Removed Changed
clippy::std_instead_of_alloc 1 0 1
clippy::std_instead_of_core 7 56 5

This comment will be updated if you push new changes

@bushrat011899

This comment has been minimized.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels May 5, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 5, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@bushrat011899 bushrat011899 force-pushed the std_instead_of_core_io_in_core_false_positive branch from 751c8ff to bc2d729 Compare May 5, 2026 13:07
@bushrat011899

This comment has been minimized.

@bushrat011899 bushrat011899 force-pushed the std_instead_of_core_io_in_core_false_positive branch 2 times, most recently from 87538e5 to 2ae396b Compare May 6, 2026 05:22
@bushrat011899
Copy link
Copy Markdown
Author

It was a little more involved than I anticipated, but I believe I have resolved the false positive I was intending to, and also solved a couple of additional multi-import ones. I've added additional test cases for the lint which should catch any regressions. This also solved some MSRV issues too. For example, serde 1.0.204 had an MSRV of 1.31 and imports AtomicBool, AtomicI8, and AtomicU8 in a single line. Current clippy suggests importing all from core, even though AtomicI8 and AtomicU8 were only added to core in 1.34.0.

Because I was struggling to understand how the lint worked initially, I've refactored it probably more than it strictly had to be. However I believe it is now easier to understand (at least to my new-to-clippy eyes), with additional comments and internal documentation.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels May 6, 2026
@bushrat011899 bushrat011899 changed the title fix(lint): std_instead_of_core false positive for core::io fix(lint): std_instead_of_core false positives for core::io/MSRV May 6, 2026
@bushrat011899 bushrat011899 force-pushed the std_instead_of_core_io_in_core_false_positive branch from 2ae396b to bc66086 Compare May 6, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSRV-aware std_instead_of_core

3 participants