-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
If there is a list import with use path::{...};
with a wrong path, Rust is giving wrong suggestions for that path, it suggests a semicolon. E.g. for this code:
use std::collections::{HashMap, Entry};
It prints:
error[E0432]: unresolved import `std::collections::Entry`
--> src/lib.rs:1:33
|
1 | use std::collections::{HashMap, Entry};
| ^^^^^ no `Entry` in `collections`
|
help: consider importing one of these items instead
|
1 | use std::collections::{HashMap, hashbrown::hash_map::Entry;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 | use std::collections::{HashMap, hashbrown::hash_set::Entry;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 | use std::collections::{HashMap, hashlink::lru_cache::Entry;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 | use std::collections::{HashMap, http::header::Entry;
| ~~~~~~~~~~~~~~~~~~~~
and 14 other candidates
You can't use a semicolon here however, you have to use a comma. Also, it suggests absolute paths, while it should take into account that we are looking for sub-paths of std::collections
.
It should suggest code like:
use std::collections::{HashMap, hash_map::Entry};
use std::collections::{HashMap, btree_map::Entry};
@rustbot label A-diagnostics
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.