-
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
Move reporting recursion limit errors outside of the trait system #81091
Comments
@jonas-schievink I don't know if I would describe this as cleanup - this is blocking a major rustdoc feature: #79525 |
There are several reasons I changed this: - `evaluate_obligation` is only used in one place in `rustc_trait_selection`, and in fact warns you against using it anywhere else. - The implementation in `rustc_traits` was considerably more complicated than necessary, because it didn't have the context available in `rustc_trait_selection`. - It allows moving OverflowError into rustc_trait_selection, making rust-lang#81091 simpler (in particular, it allows holding an `Obligation` in OverflowError, which is only defined in `rustc_infer` and not available in rustc_middle). The only reason to keep the previous behavior is if the cache from the query system made it significantly faster.
I made a (very broken) start on this in master...jyn514:recover-overflow. |
Rebased the above as master...koivunej:recover-overflow-continued |
Make cycle errors recoverable In particular, this allows rustdoc to recover from cycle errors when normalizing associated types for documentation. In the past, `@jackh726` has said we need to be careful about overflow errors: rust-lang#91430 (comment) > Off the top of my head, we definitely should be careful about treating overflow errors the same as "not implemented for some reason" errors. Otherwise, you could end up with behavior that is different depending on recursion depth. But, that might be context-dependent. But cycle errors should be safe to unconditionally report; they don't depend on the recursion depth, they will always be an error whenever they're encountered. Helps with rust-lang#81091. r? `@lcnr` cc `@matthewjasper`
Make cycle errors recoverable In particular, this allows rustdoc to recover from cycle errors when normalizing associated types for documentation. In the past, ``@jackh726`` has said we need to be careful about overflow errors: rust-lang#91430 (comment) > Off the top of my head, we definitely should be careful about treating overflow errors the same as "not implemented for some reason" errors. Otherwise, you could end up with behavior that is different depending on recursion depth. But, that might be context-dependent. But cycle errors should be safe to unconditionally report; they don't depend on the recursion depth, they will always be an error whenever they're encountered. Helps with rust-lang#81091. r? ``@lcnr`` cc ``@matthewjasper``
Make cycle errors recoverable In particular, this allows rustdoc to recover from cycle errors when normalizing associated types for documentation. In the past, ```@jackh726``` has said we need to be careful about overflow errors: rust-lang#91430 (comment) > Off the top of my head, we definitely should be careful about treating overflow errors the same as "not implemented for some reason" errors. Otherwise, you could end up with behavior that is different depending on recursion depth. But, that might be context-dependent. But cycle errors should be safe to unconditionally report; they don't depend on the recursion depth, they will always be an error whenever they're encountered. Helps with rust-lang#81091. r? ```@lcnr``` cc ```@matthewjasper```
I assume the fix proposed in this issue will fix the recently reported I-hang issue #108826, too. :) |
I think T-types is planning to fix this by landing the new trait solver, which is unlikely to have the same bugs as the existing solver (instead they will be new and more exciting bugs). |
Right, that's true :) |
This is the proper fix for the breakage in #79506 and #79459.
The steps are basically to find all of the places that create a
OverflowError
orSelectionError::Overflow
and make sure that they are always early returned until outside ofrustc_trait_selection::traits::{select, project}
, at which point they should be emitted. Overflow errors should never be converted to any other kind of error (such asEvaluatedToRecur
orEvaluatedToError
)Originally posted by @matthewjasper in #81055 (comment)
The text was updated successfully, but these errors were encountered: