-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
THIR patterns: Use ty::Value in more places throughout const_to_pat
#151295
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
Conversation
|
Some changes occurred in match checking cc @Nadrieril |
|
r? @davidtwco rustbot has assigned @davidtwco. Use |
| .map(|(idx, (val, ty))| { | ||
| let field = FieldIdx::new(idx); | ||
| // Patterns can only use monomorphic types. | ||
| let ty = self.tcx.normalize_erasing_regions(self.typing_env, ty); |
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.
If I simply delete this normalize_erasing_regions and run the ui test suite with no other changes, I get a bunch of failures.
But if I remove the normalization in conjunction with using types from the valtree, everything appears to work. That suggests to me that using the types from the valtree makes the normalization step redundant.
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.
Yeah the types stored in the valtree will come directly from CTFE and are fully normalized (though contain erased regions, but this is fine for THIR building)
|
Hmm, from looking at #150624 it seems like there might be reasons to not rely on the types in a valtree just yet. cc @BoxyUwU Is it OK to rely to use the types embedded in a valtree for the purposes of lowering constants/literals to patterns, or is that going to interfere with other planned changes? |
|
I think its OK. I'm not sure I'll do any of the follow up work in that issue for a while. It turns out to be really annoying to implement a fix for the 'erased regions problem while the old solver is still around, and while generic_const_exprs exists. The solution I'd like to implement won't have any bad interactions here I believe. We've already fed r? BoxyUwU |
|
@bors r+ |
|
@bors rollup=never |
|
@bors r- ah maybe we should just do a perf run then to avoid a potential land-revert churn |
|
Commit 97603c0 has been unapproved. |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
THIR patterns: Use `ty::Value` in more places throughout `const_to_pat`
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (04732d4): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (secondary -0.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary 0.0%, secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 473.646s -> 473.434s (-0.04%) |
|
Seems perf-neutral. :) @bors r=BoxyUwU rollup=maybe |
…uwer Rollup of 15 pull requests Successful merges: - #148623 (Ignore `#[doc(hidden)]` items when computing trimmed paths for printing) - #150550 (Miscellaneous cleanups to borrowck related code) - #150879 (Remove the diagnostic lints) - #150895 (rustc_errors: Add (heuristic) Syntax Highlighting for `rustc --explain`) - #150987 (remote-test-server: Fix header in batch mode) - #151004 (std: implement `sleep_until` on Apple platforms) - #151045 (Simplify some literal-value negations with `u128::wrapping_neg`) - #151119 (Support pointers in type reflection) - #151171 (Do not recover from `Trait()` if generic list is unterminated) - #151231 (HIR typeck cleanup: clarify and re-style `check_expr_unop`) - #151249 (Parse ident with allowing recovery when trying to diagnose) - #151295 (THIR patterns: Use `ty::Value` in more places throughout `const_to_pat`) - #151326 (Remove `DiagMessage::Translated` in favour of `DiagMessage::Str`) - #151361 (add test for issue 61463) - #151371 (Add `S-blocked` to `labels_blocking_approval`) r? @ghost
Rollup merge of #151295 - const-to-pat, r=BoxyUwU THIR patterns: Use `ty::Value` in more places throughout `const_to_pat` This PR changes `ConstToPat::valtree_to_pat` to take a `ty::Value` instead of separate type and valtree arguments, and propagates that change throughout other parts of the overall `const_to_pat` implementation. The biggest under-the-hood change is that instead of combining valtrees from the constant with child types from the parent type, we now just rely on the types already embedded in children of the valtree. I'm not *entirely* sure that this is correct, but it doesn't seem to cause any failures in the test suite, and from what I can tell the old way was a holdover from a time when the types weren't readily available from the value side. --- My ulterior motive for this cleanup is that I'm hoping to eventually add some extra data to `thir::PatKind::Const`, which will be a little easier if creation of that `PatKind::Const` doesn't have to assemble a `ty::Value` from component parts.
…uwer Rollup of 15 pull requests Successful merges: - rust-lang/rust#148623 (Ignore `#[doc(hidden)]` items when computing trimmed paths for printing) - rust-lang/rust#150550 (Miscellaneous cleanups to borrowck related code) - rust-lang/rust#150879 (Remove the diagnostic lints) - rust-lang/rust#150895 (rustc_errors: Add (heuristic) Syntax Highlighting for `rustc --explain`) - rust-lang/rust#150987 (remote-test-server: Fix header in batch mode) - rust-lang/rust#151004 (std: implement `sleep_until` on Apple platforms) - rust-lang/rust#151045 (Simplify some literal-value negations with `u128::wrapping_neg`) - rust-lang/rust#151119 (Support pointers in type reflection) - rust-lang/rust#151171 (Do not recover from `Trait()` if generic list is unterminated) - rust-lang/rust#151231 (HIR typeck cleanup: clarify and re-style `check_expr_unop`) - rust-lang/rust#151249 (Parse ident with allowing recovery when trying to diagnose) - rust-lang/rust#151295 (THIR patterns: Use `ty::Value` in more places throughout `const_to_pat`) - rust-lang/rust#151326 (Remove `DiagMessage::Translated` in favour of `DiagMessage::Str`) - rust-lang/rust#151361 (add test for issue 61463) - rust-lang/rust#151371 (Add `S-blocked` to `labels_blocking_approval`) r? @ghost
This PR changes
ConstToPat::valtree_to_patto take aty::Valueinstead of separate type and valtree arguments, and propagates that change throughout other parts of the overallconst_to_patimplementation.The biggest under-the-hood change is that instead of combining valtrees from the constant with child types from the parent type, we now just rely on the types already embedded in children of the valtree.
I'm not entirely sure that this is correct, but it doesn't seem to cause any failures in the test suite, and from what I can tell the old way was a holdover from a time when the types weren't readily available from the value side.
My ulterior motive for this cleanup is that I'm hoping to eventually add some extra data to
thir::PatKind::Const, which will be a little easier if creation of thatPatKind::Constdoesn't have to assemble aty::Valuefrom component parts.