-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 use Res::Err
without emitting an error 1/*
#72108
Conversation
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
I am reading up a bit here to get more context, however my general opinion that we have to be very careful about things that signal "there was an error reported to the user". It's very common to use variants like that to skip downstream errors or avoid bits of work, and it's easy to wind up with unsoundness as a result. So 👍 to having a clear distinction between "error reported" and "no relevant resolution", presuming at least that 'no relevant resolution' doesn't always imply an error has been reported. Can you elaborate a bit more on what bits of downstream code want to distinguish between those two cases, though? I know it came up when we were discussing lazy normalization, but I think the context would be helpful. |
I first noticed this when refactoring rust/src/librustc_typeck/collect/type_of.rs Lines 271 to 289 in 3fe4dd2
Some correct qpaths have segments where Looking at some other locations where rust/src/librustc_typeck/check/pat.rs Lines 824 to 828 in 3fe4dd2
|
I think this is desirable at least after the main resolution pass, but I'd prefer to see this done in stages instead of changing all occurrences in one go. For example
|
☔ The latest upstream changes (presumably #69171) made this pull request unmergeable. Please resolve the merge conflicts. |
We currently use
Res::Err
both to express "there was an error" and "there is no relevant resolution".rust/src/librustc_middle/ty/context.rs
Lines 454 to 461 in 3fe4dd2
Before I work on changing all occurrences of the second meaning to
Option<Res>
I want to get somefeedback whether this change is actually desired.
cc @nikomatsakis @matthewjasper