Skip to content

Don't bail out on non-calls in resolver diagnostics #109250

Closed
@Noratrieb

Description

@Noratrieb

// 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

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions