Description
For a multi-import statement, the std_instead_of_core family of lints will either:
- Emit a single suggestion if the root of the import can be replaced with
core/alloc
- Emit one help for each member of the import that can be updated.
This can be quite frustrating for larger import statements, since it's not uncommon for only one or two items in the statement to be unavailable from core or alloc. Consider the below:
use std::{
sync::atomic::{Ordering, AtomicBool},
fmt::Debug,
ops::{self, Add},
};
This emits 1 suggestion, replace std with core. However, if I add Mutex to the statement:
use std::{
sync::{
atomic::{Ordering, AtomicBool},
Mutex,
},
fmt::Debug,
ops::{self, Add},
};
This will now produce 5 std_instead_of_core lints, each only showing a small part of the overall statement, when only a single item needs to be moved (Mutex) into it's own std import to allow for the whole original statement to be from core.
If instead a multiline help was emitted, the number of lints emitted stays the same (one), but it changes from a suggestion on std to a help on each applicable item.
#17252 sets up the required changes to how multi-imports are handled to allow for this change. All that would be required is to emit the MultiSpans it computes directly, instead of iterating their primary_spans.
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
Additional Labels
@rustbot label +C-enhancement
Description
For a multi-import statement, the
std_instead_of_corefamily of lints will either:core/allocThis can be quite frustrating for larger import statements, since it's not uncommon for only one or two items in the statement to be unavailable from
coreoralloc. Consider the below:This emits 1 suggestion, replace
stdwithcore. However, if I addMutexto the statement:This will now produce 5
std_instead_of_corelints, each only showing a small part of the overall statement, when only a single item needs to be moved (Mutex) into it's ownstdimport to allow for the whole original statement to be fromcore.If instead a multiline help was emitted, the number of lints emitted stays the same (one), but it changes from a suggestion on
stdto a help on each applicable item.#17252 sets up the required changes to how multi-imports are handled to allow for this change. All that would be required is to emit the
MultiSpans it computes directly, instead of iterating theirprimary_spans.Version
Additional Labels
@rustbot label +C-enhancement