-
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 lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.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
rust/compiler/rustc_resolve/src/late.rs
Lines 3480 to 3488 in 511364e
// For paths originating from calls (like in `HashMap::new()`), tries | |
// to enrich the plain `failed to resolve: ...` message with hints | |
// about possible missing imports. | |
// | |
// Similar thing, for types, happens in `report_errors` above. | |
let report_errors_for_call = |this: &mut Self, parent_err: Spanned<ResolutionError<'a>>| { | |
if !source.is_call() { | |
return Some(parent_err); | |
} |
When a path is failed to be resolved, rustc will enrich the error with many suggestions like adding missing imports.
For example
fn main() {
HashMap::new();
}
suggests adding the missing import.
But as seen in the code above, it just bails out on paths where there is no call, like
fn main() {
HashMap::new;
}
This is probably a weird hack around some oddity in the suggestion code (maybe the extremely hacky diagnostics merging that happens in there).
Remove the early return above and figure out what happens. If nothing bad happens, great. If something bad happens, figure out why and fix it properly.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.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.