Move placeholder error handling to before region inference#142623
Move placeholder error handling to before region inference#142623amandasystems wants to merge 11 commits intorust-lang:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
|
Wow, a merge conflict with upstream for a commit I JUST PUSHED, that's record time! |
fd18095 to
199f961
Compare
|
@rustbot blocked |
199f961 to
3a46042
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3a46042 to
9b555d3
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9b555d3 to
f31393f
Compare
|
@rustbot ready |
| = note: `Getter<'1>` would have to be implemented for the type `GetterImpl<'0, ConstructableImpl<'_>>`, for any two lifetimes `'0` and `'1`... | ||
| = note: `Getter<'_>` would have to be implemented for the type `GetterImpl<'0, ConstructableImpl<'1>>`, for any two lifetimes `'0` and `'1`... |
There was a problem hiding this comment.
I hate this, but can't find a way around it. My gut feeling says it's another case of an order-dependent extraction procedure somewhere. For what it's worth, it wasn't in the earlier version of this code but it seems to have appeared after the recent changes to the base commit. Presumably the difference is from selecting smallest placeholder by rvid, etc. Help very much appreciated!
f31393f to
f542ec5
Compare
| error_element | ||
| { | ||
| let adjusted_universe = | ||
| error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32()); |
There was a problem hiding this comment.
I think the "checked sub" part is what really broke me here. Why are universes being adjusted? What's a base universe? And why can the subtraction sometimes overflow?!?!
There was a problem hiding this comment.
For the record, these are the only reads of base_universe on CanonicalTypeOpDeeplyNormalizeGoal, CanonicalTypeOpAscribeUserTypeGoal and InstantiateOpaqueType.
This comment has been minimized.
This comment has been minimized.
f542ec5 to
8269a42
Compare
This comment has been minimized.
This comment has been minimized.
I don't understand where these errors come from. On my branch every single commit passes the |
8269a42 to
e0b30fa
Compare
|
☔ The latest upstream changes (presumably #149535) made this pull request unmergeable. Please resolve the merge conflicts. |
fbe2418 to
a9e1a79
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
- coroutine/auto-trait-regions.rs: also reformulate the test to make sure we don't miss errors -- just duplicate ones. - traits/trait-upcasting/higher-ranked-upcasting-ub.rs: remove duplicate ERROR mismatched types - ui/associated-types/associated-types-eq-hr.rs: remove 5 duplicate errors for "implementation not general enough" and mismatched types" - ui/borrowck/opaque-types-patterns-subtyping-ice-104779.rs: two redundant higher-ranked subtype errors
a9e1a79 to
21ddce3
Compare
…er-ranked/higher-ranked-lifetime-equality.rs: remove literally idential error.
`bound_inv_a_b_vs_bound_inv_a` has one fewer identical error
… "not general enough"
…al "one type is more general"
This comment has been minimized.
This comment has been minimized.
…ong enough" This error is caused as a side-effect from added `r: 'static` constraints. It should not be necessary, but beig less aggressive with rewriting breaks many other diagnostics, and this is closer to the original logic.
| } else { | ||
| None | ||
| }; | ||
| // FIXME: one day this should just be error_element, but see above about the adjusted universes. At that point, this method can probably be removed entirely. |
There was a problem hiding this comment.
| // FIXME: one day this should just be error_element, but see above about the adjusted universes. At that point, this method can probably be removed entirely. | |
| // FIXME: one day this should just be error_element, | |
| // but see above about the adjusted universes. At that point, | |
| // this method can probably be removed entirely. |
| }; | ||
| if bound_generic_params | ||
| .iter() | ||
| .rfind(|bgp| self.infcx.tcx.local_def_id_to_hir_id(bgp.def_id) == gat_hir_id) |
There was a problem hiding this comment.
| .rfind(|bgp| self.infcx.tcx.local_def_id_to_hir_id(bgp.def_id) == gat_hir_id) | |
| .rfind(|bgp| tcx.local_def_id_to_hir_id(bgp.def_id) == gat_hir_id) |
| }; | ||
| if bound_generic_params | ||
| .iter() | ||
| .rfind(|bgp| self.infcx.tcx.local_def_id_to_hir_id(bgp.def_id) == gat_hir_id) |
There was a problem hiding this comment.
| .rfind(|bgp| self.infcx.tcx.local_def_id_to_hir_id(bgp.def_id) == gat_hir_id) | |
| .rfind(|bgp| tcx.local_def_id_to_hir_id(bgp.def_id) == gat_hir_id) |
| // FIXME(amandasystems) we can probably flatten this. | ||
| for pred in self | ||
| .infcx | ||
| .tcx |
There was a problem hiding this comment.
why use self.infcx.tcx instead of just tcx?
|
After discussing this with @lcnr we've decided to abandon this avenue. I'll submit a few PRs with cleanups and nice lessons from this work. It turns out that the main thrust of this -- removing placeholder tracking -- is incompatible with future trait solver work that would involve richer assumptions about outlives constraints. Checking these would require knowing precisely which placeholder regions end up where and is thus incompatible with the spirit of this PR. |
This change backports some changes from the now abandoned rust-lang#142623. Notably, it simplifies the `PlaceholderReachability` `enum` by replacing the case when no placeholders were reached with a standard `Option::None`. It also rewrites the API for `scc::Annotations` to be update-mut rather than a more Functional programming style. This snowed some slight performance impact in early tests of the PR and definitely makes the implementation simpler.
…te, r=lcnr Borrowck: Simplify SCC annotation computation, placeholder rewriting This change backports some changes from the now abandoned rust-lang#142623. Notably, it simplifies the `PlaceholderReachability` `enum` by replacing the case when no placeholders were reached with a standard `Option::None`. It also rewrites the API for `scc::Annotations` to be update-mut rather than a more Functional programming style. This showed some slight performance impact in early tests of the PR and definitely makes the implementation simpler. This probably wants a perf run just for good measure. r? @lcnr
Rollup merge of #151696 - amandasystems:scc-annotations-update, r=lcnr Borrowck: Simplify SCC annotation computation, placeholder rewriting This change backports some changes from the now abandoned #142623. Notably, it simplifies the `PlaceholderReachability` `enum` by replacing the case when no placeholders were reached with a standard `Option::None`. It also rewrites the API for `scc::Annotations` to be update-mut rather than a more Functional programming style. This showed some slight performance impact in early tests of the PR and definitely makes the implementation simpler. This probably wants a perf run just for good measure. r? @lcnr
Borrowck: Simplify SCC annotation computation, placeholder rewriting This change backports some changes from the now abandoned rust-lang/rust#142623. Notably, it simplifies the `PlaceholderReachability` `enum` by replacing the case when no placeholders were reached with a standard `Option::None`. It also rewrites the API for `scc::Annotations` to be update-mut rather than a more Functional programming style. This showed some slight performance impact in early tests of the PR and definitely makes the implementation simpler. This probably wants a perf run just for good measure. r? @lcnr
Borrowck: Simplify SCC annotation computation, placeholder rewriting This change backports some changes from the now abandoned rust-lang/rust#142623. Notably, it simplifies the `PlaceholderReachability` `enum` by replacing the case when no placeholders were reached with a standard `Option::None`. It also rewrites the API for `scc::Annotations` to be update-mut rather than a more Functional programming style. This showed some slight performance impact in early tests of the PR and definitely makes the implementation simpler. This probably wants a perf run just for good measure. r? @lcnr
This PR supersedes #130227. It removes precise tracking of placeholders in borrowck, moving them to an earlier stage. This leads to better performance, since we track less information. It is also part of the preparations for Polonius by moving specialised logic out of region inference itself and into the region graph or other, common pre-processing steps. Originally, the intention was to do this in multiple steps, but since some of them incur performance penalties won back by later stages, doing them in one go makes the net results clearer.
Error reporting changes
Trait<r1, r2>, which frequently gives two error messages, one for each region. Under this logic it only gives one.tests/ui/impl-trait/nested-rpit-hrtb.rs, we now also addr: 'static, which causes an extra error. Being more conservative when rewriting the constraint graph and avoiding it when invalid outlives are already detected breaks existing diagnostics for many, many tests that rely on the extrar: 'staticto find out why they error.Due to reason 2., several UI tests change, a lot, since they rely on diagnostic duplication being turned off to find several duplicate errors.
Code structure changes
r? lcnr