Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Noratrieb opened this issue Mar 17, 2023 · 0 comments · Fixed by #111428
Closed

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

Noratrieb opened this issue Mar 17, 2023 · 0 comments · Fixed by #111428
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Noratrieb
Copy link
Member

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

@Noratrieb Noratrieb added C-cleanup Category: PRs that clean code up or issues documenting cleanup. A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 17, 2023
Noratrieb added a commit to Noratrieb/rust that referenced this issue May 16, 2023
refactor(resolve): clean up the early error return caused by non-call

closes rust-lang#109250

It seems no bad happened, r? `@Nilstrieb`
@bors bors closed this as completed in f652815 May 16, 2023
RalfJung pushed a commit to RalfJung/miri that referenced this issue May 18, 2023
refactor(resolve): clean up the early error return caused by non-call

closes rust-lang/rust#109250

It seems no bad happened, r? ``@Nilstrieb``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant