Wrong highlighting in E0432 when import and suggestion share prefix (original) (raw)
I tried this code:
I expected to see this:
--> /tmp/test.rs:1:5
|
1 | use sync;
| ^^^^ no `sync` in the root
|
help: consider importing this module instead
|
1 | use std::sync;
| +++++
Instead, this happened:
--> /tmp/test.rs:1:5
|
1 | use sync;
| ^^^^ no `sync` in the root
|
help: consider importing this module instead
|
1 | use std::sync;
| +++++
Note that in the second case, the highlighted part is td::s instead of std::.
The error is that as std:: starts with the same prefix as sync, it fails to highlight correctly what to add. It's not wrong, as if you add that it works, but it looks weird.
The same happens with time if you have tokio or tracing_suscriber as a dependency.
Meta
rustc --version --verbose:
rustc 1.90.0 (1159e78c4 2025-09-14)
binary: rustc
commit-hash: 1159e78c4747b02ef996e55082b704c09b970588
commit-date: 2025-09-14
host: x86_64-unknown-linux-gnu
release: 1.90.0
LLVM version: 20.1.8
This happens up until the last nightly compiler, and happens since it was added.
I could narrow the error, and I tried a fix in #148061 but it makes tests fail, as other warnings depend on this behaviour.