-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Opportunistically resolve regions in new solver #112443
Opportunistically resolve regions in new solver #112443
Conversation
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
} | ||
ty::GenericArgKind::Const(ct) => { | ||
matches!(ct.kind(), ty::ConstKind::Bound(ty::INNERMOST, bc) if bc.as_usize() == bv) | ||
let mut var = ty::BoundVar::from_u32(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This essentially just checks that the type and const vars are monotonically increasing, ignoring regions (which may have been resolved to a concrete region or a different region var).
tests/ui/dyn-star/param-env-infer.rs
Outdated
// incremental | ||
|
||
//[next] compile-flags: -Ztrait-solver=next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ends up ICEing like:
https://gist.github.com/compiler-errors/2660fdd9902ec2686f6288b697953294
Not sure why it's overflowing now, though. I'll look into it tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ICE is interesting 🤷
r=me after nit whether or not you fix the ICE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think region resolution should be limited to the query response. Resolving regions in the input side is bad for caching especially because we no longer "uniquify" input regions. It would also allow for trait selection bugs to easily rely on two input regions being equal.
5d0b44b
to
01377e8
Compare
Only opportunistically resolving regions on response (instead of on input), per @aliemjay's suggestion, actually also fixes that ICE. And I gave Think this PR is ready now. |
@bors r+ rollup |
…unistically-resolve-regions, r=lcnr Opportunistically resolve regions in new solver Use `opportunistic_resolve_var` during canonicalization to collapse some regions. We have to start using `CanonicalVarValues::is_identity_modulo_regions`. We also have to modify that function to consider responses like `['static, ^0, '^1, ^2]` to be an "identity" response, since because we opportunistically resolve regions, there's no longer a 1:1 mapping between canonical var values and bound var indices in the response... There's one nasty side-effect -- one test (`tests/ui/dyn-star/param-env-infer.rs`) starts to ICE because the certainty goes from `Yes` to `Maybe(Overflow)`... Not exactly sure why, though? Putting this up for discussion/investigation. r? `@lcnr`
…unistically-resolve-regions, r=lcnr Opportunistically resolve regions in new solver Use `opportunistic_resolve_var` during canonicalization to collapse some regions. We have to start using `CanonicalVarValues::is_identity_modulo_regions`. We also have to modify that function to consider responses like `['static, ^0, '^1, ^2]` to be an "identity" response, since because we opportunistically resolve regions, there's no longer a 1:1 mapping between canonical var values and bound var indices in the response... There's one nasty side-effect -- one test (`tests/ui/dyn-star/param-env-infer.rs`) starts to ICE because the certainty goes from `Yes` to `Maybe(Overflow)`... Not exactly sure why, though? Putting this up for discussion/investigation. r? ``@lcnr``
Rollup of 7 pull requests Successful merges: - rust-lang#112163 (fix: inline `predicate_may_hold_fatal` and remove expect call in it) - rust-lang#112399 (Instantiate closure synthetic substs in root universe) - rust-lang#112443 (Opportunistically resolve regions in new solver) - rust-lang#112535 (reorder attributes to make miri-test-libstd work again) - rust-lang#112579 (Fix building libstd documentation on FreeBSD.) - rust-lang#112639 (Fix `dead_code_cgu` computation) - rust-lang#112642 (Handle interpolated literal errors) r? `@ghost` `@rustbot` modify labels: rollup
Use
opportunistic_resolve_var
during canonicalization to collapse some regions.We have to start using
CanonicalVarValues::is_identity_modulo_regions
. We also have to modify that function to consider responses like['static, ^0, '^1, ^2]
to be an "identity" response, since because we opportunistically resolve regions, there's no longer a 1:1 mapping between canonical var values and bound var indices in the response...There's one nasty side-effect -- one test (
tests/ui/dyn-star/param-env-infer.rs
) starts to ICE because the certainty goes fromYes
toMaybe(Overflow)
... Not exactly sure why, though? Putting this up for discussion/investigation.r? @lcnr