trait solver: account for universes from replace_bound_vars#158362
Conversation
|
rustbot has assigned @JonathanBrouwer. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
r? types |
9cc11df to
697770e
Compare
|
I'm not entirely sure if this is the right fix (I would actually expect that r? @BoxyUwU |
|
yeah, i think you're right that this probably is not the ideal long-term shape. what this pr does is more of a local bound: eager placeholder handling only walks universes the current solver region constraint can actually name. imo that part still makes sense to me. so yeah, idk if i would call this the best fix in the abstract. long term i'd expect us to have a cleaner invariant between created universes and placeholder assumptions, or maybe an explicit set of universes that eager handling should process. but for this pr, i still prefer this local fix over making missing assumptions silently mean ambiguity. if the constraint cannot name the universe, i don't think this pass should care about it. so this still lgtm to me as a short term fix, with the caveat that |
|
Offtopic: what does ltm mean? |
long term. |
|
this in theory makes sense as an optimization but it shouldn't make anything stop ICEing. We should not be entering binders inside of the trait solver without accounting for their assumptions 🤔
the set of universes it should handle is all of them (other than input universes). can you look into where/why we're entering a binder and not inserting assumptions for it |
yeah, you were right. i looked into where the unaccounted binder entry was happening, and it seems like the issue was in the bad path was basically: i changed the patch so eager handling keeps using all non-input universes. instead, when i also added the issue repro as a ui test. with this version it no longer ices and reports the overflow diagnostic instead. pushed this version for you to validate. idk if long-term we want |
| { | ||
| fn replace_bound_vars<T: TypeFoldable<I>>(&mut self, value: T) -> T { | ||
| let old_universes = self.universes.clone(); | ||
| let value = self.ecx.replace_bound_vars(value, &mut self.universes); |
There was a problem hiding this comment.
I think slightly more generally than FindParamInClause, any part of the new solver which calls replace_bound_vars is just wrong under -Zassumptions-on-binders 🤔
I think ideally we would update replace_bound_vars to, when it creates new universes, also insert empty assumptions (and add an associated fixme to fix that in the long term :3)
There was a problem hiding this comment.
yeah, makes sense. i changed this to be less FindParamInClause-specific.
replace_bound_vars now snapshots the universe slots before calling BoundVarReplacer, then inserts Assumptions::empty() for any slot that got materialized. FindParamInClause is back to just calling ecx.replace_bound_vars, so btw this should cover the other new-solver callers of that helper too.
imo this is a better shape than the previous patch. idk if empty assumptions is what we want irl, since replace_bound_vars still does not know enough to compute the real assumptions, so i left a FIXME there as you requested. ltm if you'd rather push this closer to BoundVarReplacer, but i think this is the right small step for this PR.
fyi i also updated the title/description so they no longer talk about limiting eager placeholder handling.
This comment has been minimized.
This comment has been minimized.
ad0815f to
25bd5cc
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.
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
|
@bors r+ |
…er_universe_bounds, r=BoxyUwU trait solver: account for universes from replace_bound_vars Fixes rust-lang#157840. The ICE was not really because eager placeholder handling looked at too many universes. Boxy was right: with `-Zassumptions-on-binders`, if the new solver creates a placeholder universe, that universe needs an assumptions entry. The bad path is `FindParamInClause` entering a binder through `replace_bound_vars`. `BoundVarReplacer` materializes a placeholder universe for the escaping bound vars, but nothing records placeholder assumptions for it. Later eager placeholder handling walks all non-input universes, which imo is the right behavior, and `get_placeholder_assumptions` hits the missing entry. This moves the empty-assumptions bookkeeping into `EvalCtxt::replace_bound_vars` instead of keeping it local to `FindParamInClause`. The helper snapshots the universe slots before replacement and inserts `Assumptions::empty()` for any slot that got filled. There is still a FIXME there because idk that empty assumptions is the final shape irl. `replace_bound_vars` does not have the param-env context to compute proper assumptions. But for this PR, imo this is the least weird local fix: it keeps the eager pass looking at all non-input universes and fixes the missing bookkeeping where the universe is created. The repro is covered by a UI test. It reports the overflow diagnostic instead of ICEing.
Rollup of 18 pull requests Successful merges: - #138618 (Support using const pointers in asm `const` operand) - #150161 (Remove 'static requirement on try_as_dyn) - #158362 (trait solver: account for universes from replace_bound_vars) - #159173 (Add allowed list check on EII implementations attributes) - #159466 (cmse: clear variant-dependent padding in `enum`s) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #157905 (Update comments and add tests for `-Zrandomize-layout` for some guaranteed ZSTs) - #159041 (Reorganize `tests/ui/issues` [22/N]) - #159108 (Reorganize `tests/ui/issues` [23/N]) - #159138 (doc: document wasm import symbol mangling) - #159531 (Reorganize `tests/ui/issues` [28/N]) - #159608 (early_otherwise: Don't hoist dereferences when the otherwise branch is reachable) - #159612 (Reorganize `tests/ui/issues` [29/N]) - #159653 (run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`) - #159759 (rustc-dev-guide subtree update) - #159761 (Remove outdated comment for resolve_vars_with_obligations)
…er_universe_bounds, r=BoxyUwU trait solver: account for universes from replace_bound_vars Fixes rust-lang#157840. The ICE was not really because eager placeholder handling looked at too many universes. Boxy was right: with `-Zassumptions-on-binders`, if the new solver creates a placeholder universe, that universe needs an assumptions entry. The bad path is `FindParamInClause` entering a binder through `replace_bound_vars`. `BoundVarReplacer` materializes a placeholder universe for the escaping bound vars, but nothing records placeholder assumptions for it. Later eager placeholder handling walks all non-input universes, which imo is the right behavior, and `get_placeholder_assumptions` hits the missing entry. This moves the empty-assumptions bookkeeping into `EvalCtxt::replace_bound_vars` instead of keeping it local to `FindParamInClause`. The helper snapshots the universe slots before replacement and inserts `Assumptions::empty()` for any slot that got filled. There is still a FIXME there because idk that empty assumptions is the final shape irl. `replace_bound_vars` does not have the param-env context to compute proper assumptions. But for this PR, imo this is the least weird local fix: it keeps the eager pass looking at all non-input universes and fixes the missing bookkeeping where the universe is created. The repro is covered by a UI test. It reports the overflow diagnostic instead of ICEing.
…er_universe_bounds, r=BoxyUwU trait solver: account for universes from replace_bound_vars Fixes rust-lang#157840. The ICE was not really because eager placeholder handling looked at too many universes. Boxy was right: with `-Zassumptions-on-binders`, if the new solver creates a placeholder universe, that universe needs an assumptions entry. The bad path is `FindParamInClause` entering a binder through `replace_bound_vars`. `BoundVarReplacer` materializes a placeholder universe for the escaping bound vars, but nothing records placeholder assumptions for it. Later eager placeholder handling walks all non-input universes, which imo is the right behavior, and `get_placeholder_assumptions` hits the missing entry. This moves the empty-assumptions bookkeeping into `EvalCtxt::replace_bound_vars` instead of keeping it local to `FindParamInClause`. The helper snapshots the universe slots before replacement and inserts `Assumptions::empty()` for any slot that got filled. There is still a FIXME there because idk that empty assumptions is the final shape irl. `replace_bound_vars` does not have the param-env context to compute proper assumptions. But for this PR, imo this is the least weird local fix: it keeps the eager pass looking at all non-input universes and fixes the missing bookkeeping where the universe is created. The repro is covered by a UI test. It reports the overflow diagnostic instead of ICEing.
Rollup of 19 pull requests Successful merges: - #150161 (Remove 'static requirement on try_as_dyn) - #158362 (trait solver: account for universes from replace_bound_vars) - #159173 (Add allowed list check on EII implementations attributes) - #159466 (cmse: clear variant-dependent padding in `enum`s) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #157905 (Update comments and add tests for `-Zrandomize-layout` for some guaranteed ZSTs) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159041 (Reorganize `tests/ui/issues` [22/N]) - #159108 (Reorganize `tests/ui/issues` [23/N]) - #159138 (doc: document wasm import symbol mangling) - #159531 (Reorganize `tests/ui/issues` [28/N]) - #159608 (early_otherwise: Don't hoist dereferences when the otherwise branch is reachable) - #159612 (Reorganize `tests/ui/issues` [29/N]) - #159653 (run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`) - #159667 (Make some parser structured suggestions verbose and tweak their wording) - #159759 (rustc-dev-guide subtree update) - #159761 (Remove outdated comment for resolve_vars_with_obligations)
…er_universe_bounds, r=BoxyUwU trait solver: account for universes from replace_bound_vars Fixes rust-lang#157840. The ICE was not really because eager placeholder handling looked at too many universes. Boxy was right: with `-Zassumptions-on-binders`, if the new solver creates a placeholder universe, that universe needs an assumptions entry. The bad path is `FindParamInClause` entering a binder through `replace_bound_vars`. `BoundVarReplacer` materializes a placeholder universe for the escaping bound vars, but nothing records placeholder assumptions for it. Later eager placeholder handling walks all non-input universes, which imo is the right behavior, and `get_placeholder_assumptions` hits the missing entry. This moves the empty-assumptions bookkeeping into `EvalCtxt::replace_bound_vars` instead of keeping it local to `FindParamInClause`. The helper snapshots the universe slots before replacement and inserts `Assumptions::empty()` for any slot that got filled. There is still a FIXME there because idk that empty assumptions is the final shape irl. `replace_bound_vars` does not have the param-env context to compute proper assumptions. But for this PR, imo this is the least weird local fix: it keeps the eager pass looking at all non-input universes and fixes the missing bookkeeping where the universe is created. The repro is covered by a UI test. It reports the overflow diagnostic instead of ICEing.
…er_universe_bounds, r=BoxyUwU trait solver: account for universes from replace_bound_vars Fixes rust-lang#157840. The ICE was not really because eager placeholder handling looked at too many universes. Boxy was right: with `-Zassumptions-on-binders`, if the new solver creates a placeholder universe, that universe needs an assumptions entry. The bad path is `FindParamInClause` entering a binder through `replace_bound_vars`. `BoundVarReplacer` materializes a placeholder universe for the escaping bound vars, but nothing records placeholder assumptions for it. Later eager placeholder handling walks all non-input universes, which imo is the right behavior, and `get_placeholder_assumptions` hits the missing entry. This moves the empty-assumptions bookkeeping into `EvalCtxt::replace_bound_vars` instead of keeping it local to `FindParamInClause`. The helper snapshots the universe slots before replacement and inserts `Assumptions::empty()` for any slot that got filled. There is still a FIXME there because idk that empty assumptions is the final shape irl. `replace_bound_vars` does not have the param-env context to compute proper assumptions. But for this PR, imo this is the least weird local fix: it keeps the eager pass looking at all non-input universes and fixes the missing bookkeeping where the universe is created. The repro is covered by a UI test. It reports the overflow diagnostic instead of ICEing.
…er_universe_bounds, r=BoxyUwU trait solver: account for universes from replace_bound_vars Fixes rust-lang#157840. The ICE was not really because eager placeholder handling looked at too many universes. Boxy was right: with `-Zassumptions-on-binders`, if the new solver creates a placeholder universe, that universe needs an assumptions entry. The bad path is `FindParamInClause` entering a binder through `replace_bound_vars`. `BoundVarReplacer` materializes a placeholder universe for the escaping bound vars, but nothing records placeholder assumptions for it. Later eager placeholder handling walks all non-input universes, which imo is the right behavior, and `get_placeholder_assumptions` hits the missing entry. This moves the empty-assumptions bookkeeping into `EvalCtxt::replace_bound_vars` instead of keeping it local to `FindParamInClause`. The helper snapshots the universe slots before replacement and inserts `Assumptions::empty()` for any slot that got filled. There is still a FIXME there because idk that empty assumptions is the final shape irl. `replace_bound_vars` does not have the param-env context to compute proper assumptions. But for this PR, imo this is the least weird local fix: it keeps the eager pass looking at all non-input universes and fixes the missing bookkeeping where the universe is created. The repro is covered by a UI test. It reports the overflow diagnostic instead of ICEing.
…er_universe_bounds, r=BoxyUwU trait solver: account for universes from replace_bound_vars Fixes rust-lang#157840. The ICE was not really because eager placeholder handling looked at too many universes. Boxy was right: with `-Zassumptions-on-binders`, if the new solver creates a placeholder universe, that universe needs an assumptions entry. The bad path is `FindParamInClause` entering a binder through `replace_bound_vars`. `BoundVarReplacer` materializes a placeholder universe for the escaping bound vars, but nothing records placeholder assumptions for it. Later eager placeholder handling walks all non-input universes, which imo is the right behavior, and `get_placeholder_assumptions` hits the missing entry. This moves the empty-assumptions bookkeeping into `EvalCtxt::replace_bound_vars` instead of keeping it local to `FindParamInClause`. The helper snapshots the universe slots before replacement and inserts `Assumptions::empty()` for any slot that got filled. There is still a FIXME there because idk that empty assumptions is the final shape irl. `replace_bound_vars` does not have the param-env context to compute proper assumptions. But for this PR, imo this is the least weird local fix: it keeps the eager pass looking at all non-input universes and fixes the missing bookkeeping where the universe is created. The repro is covered by a UI test. It reports the overflow diagnostic instead of ICEing.
Rollup of 12 pull requests Successful merges: - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - #158362 (trait solver: account for universes from replace_bound_vars) - #159173 (Add allowed list check on EII implementations attributes) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159271 (str: add ASCII fast path to word_to_titlecase) - #159666 (fix(ld64.lld): route version mismatch warnings to linker_info on macOS) - #159667 (Make some parser structured suggestions verbose and tweak their wording)
Rollup of 14 pull requests Successful merges: - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - #158362 (trait solver: account for universes from replace_bound_vars) - #158372 (rustfmt: Discover modules via `cfg_select!`) - #159173 (Add allowed list check on EII implementations attributes) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - #159731 (std: Implement futex on wasip3 targets, update target spec) - #159755 (Improve consistency of attribute error messages) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159271 (str: add ASCII fast path to word_to_titlecase) - #159667 (Make some parser structured suggestions verbose and tweak their wording)
Rollup merge of #158362 - Dnreikronos:trait_solver/placeholder_universe_bounds, r=BoxyUwU trait solver: account for universes from replace_bound_vars Fixes #157840. The ICE was not really because eager placeholder handling looked at too many universes. Boxy was right: with `-Zassumptions-on-binders`, if the new solver creates a placeholder universe, that universe needs an assumptions entry. The bad path is `FindParamInClause` entering a binder through `replace_bound_vars`. `BoundVarReplacer` materializes a placeholder universe for the escaping bound vars, but nothing records placeholder assumptions for it. Later eager placeholder handling walks all non-input universes, which imo is the right behavior, and `get_placeholder_assumptions` hits the missing entry. This moves the empty-assumptions bookkeeping into `EvalCtxt::replace_bound_vars` instead of keeping it local to `FindParamInClause`. The helper snapshots the universe slots before replacement and inserts `Assumptions::empty()` for any slot that got filled. There is still a FIXME there because idk that empty assumptions is the final shape irl. `replace_bound_vars` does not have the param-env context to compute proper assumptions. But for this PR, imo this is the least weird local fix: it keeps the eager pass looking at all non-input universes and fixes the missing bookkeeping where the universe is created. The repro is covered by a UI test. It reports the overflow diagnostic instead of ICEing.
View all comments
Fixes #157840.
The ICE was not really because eager placeholder handling looked at too many universes. Boxy was right: with
-Zassumptions-on-binders, if the new solver creates a placeholder universe, that universe needs an assumptions entry.The bad path is
FindParamInClauseentering a binder throughreplace_bound_vars.BoundVarReplacermaterializes a placeholder universe for the escaping bound vars, but nothing records placeholder assumptions for it. Later eager placeholder handling walks all non-input universes, which imo is the right behavior, andget_placeholder_assumptionshits the missing entry.This moves the empty-assumptions bookkeeping into
EvalCtxt::replace_bound_varsinstead of keeping it local toFindParamInClause. The helper snapshots the universe slots before replacement and insertsAssumptions::empty()for any slot that got filled.There is still a FIXME there because idk that empty assumptions is the final shape irl.
replace_bound_varsdoes not have the param-env context to compute proper assumptions. But for this PR, imo this is the least weird local fix: it keeps the eager pass looking at all non-input universes and fixes the missing bookkeeping where the universe is created.The repro is covered by a UI test. It reports the overflow diagnostic instead of ICEing.