-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
THIR patterns: Replace AscribeUserType and ExpandedConstant wrappers with per-node data
#150788
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 exhaustiveness checking cc @Nadrieril Some changes occurred in match lowering cc @Nadrieril Some changes occurred in match checking cc @Nadrieril |
|
r? @davidtwco rustbot has assigned @davidtwco. Use |
|
I don't expect any measurable perf impact, but let's check. @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: Replace `AscribeUserType` and `ExpandedConstant` wrappers with per-node data
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (aaf4488): comparison URL. Overall result: ❌✅ regressions and improvements - 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 countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.2%, secondary 2.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 3.0%, secondary -3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 473.64s -> 475.633s (0.42%) |
|
Perf changes look like the usual noise to me. @bors rollup=maybe |
|
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 will allow extra data to be attached to the `Pat` before it is returned.
|
Nice, those wrappers were indeed a hassle to deal with. r? me @bors r+ |
THIR patterns: Replace `AscribeUserType` and `ExpandedConstant` wrappers with per-node data This PR removes the `AscribeUserType` and `ExpandedConstant` variants from `thir::PatKind`, and replaces them with an `Option<Box<PatExtra>>` field attached to every `thir::Pat`. ### Why remove these variants? Unlike other THIR pattern kinds, these variants are mere “wrappers” that exist to attach some additional information to an underlying pattern node. There are several places where code that consumes THIR patterns needs to carefully “unpeel” any wrapper nodes, in order to match on the underlying pattern. This is clunky, and easy to forget to do, especially since it's not always obvious where the wrapper nodes can and can't appear. Attaching the data to an optional per-node field makes it easier for consuming code to simply ignore the extra data when it is not relevant. (One downside is that it is now easier to accidentally ignore the extra data when it *is* relevant, but I think that's generally a favourable tradeoff.) ### Impact After this change, THIR pattern trees should be “logically identical” to the previous THIR pattern trees, in the sense that information that was carried by wrapper nodes should now be directly attached to the non-wrapper nodes that were being wrapped. Types and spans associated with THIR pattern nodes should (hopefully!) still be accurate. There should be no change to the output of THIR-based checks or MIR building.
THIR patterns: Replace `AscribeUserType` and `ExpandedConstant` wrappers with per-node data This PR removes the `AscribeUserType` and `ExpandedConstant` variants from `thir::PatKind`, and replaces them with an `Option<Box<PatExtra>>` field attached to every `thir::Pat`. ### Why remove these variants? Unlike other THIR pattern kinds, these variants are mere “wrappers” that exist to attach some additional information to an underlying pattern node. There are several places where code that consumes THIR patterns needs to carefully “unpeel” any wrapper nodes, in order to match on the underlying pattern. This is clunky, and easy to forget to do, especially since it's not always obvious where the wrapper nodes can and can't appear. Attaching the data to an optional per-node field makes it easier for consuming code to simply ignore the extra data when it is not relevant. (One downside is that it is now easier to accidentally ignore the extra data when it *is* relevant, but I think that's generally a favourable tradeoff.) ### Impact After this change, THIR pattern trees should be “logically identical” to the previous THIR pattern trees, in the sense that information that was carried by wrapper nodes should now be directly attached to the non-wrapper nodes that were being wrapped. Types and spans associated with THIR pattern nodes should (hopefully!) still be accurate. There should be no change to the output of THIR-based checks or MIR building.
THIR patterns: Replace `AscribeUserType` and `ExpandedConstant` wrappers with per-node data This PR removes the `AscribeUserType` and `ExpandedConstant` variants from `thir::PatKind`, and replaces them with an `Option<Box<PatExtra>>` field attached to every `thir::Pat`. ### Why remove these variants? Unlike other THIR pattern kinds, these variants are mere “wrappers” that exist to attach some additional information to an underlying pattern node. There are several places where code that consumes THIR patterns needs to carefully “unpeel” any wrapper nodes, in order to match on the underlying pattern. This is clunky, and easy to forget to do, especially since it's not always obvious where the wrapper nodes can and can't appear. Attaching the data to an optional per-node field makes it easier for consuming code to simply ignore the extra data when it is not relevant. (One downside is that it is now easier to accidentally ignore the extra data when it *is* relevant, but I think that's generally a favourable tradeoff.) ### Impact After this change, THIR pattern trees should be “logically identical” to the previous THIR pattern trees, in the sense that information that was carried by wrapper nodes should now be directly attached to the non-wrapper nodes that were being wrapped. Types and spans associated with THIR pattern nodes should (hopefully!) still be accurate. There should be no change to the output of THIR-based checks or MIR building.
Rollup of 11 pull requests Successful merges: - #148196 (Implement create_dir_all() to operate iteratively instead of recursively) - #150494 ( Fix dso_local for external statics with linkage) - #150788 (THIR patterns: Replace `AscribeUserType` and `ExpandedConstant` wrappers with per-node data) - #150799 (Fix ICE: can't type-check body of DefId for issue #148729) - #150804 (Remove std_detect_file_io and std_detect_dlsym_getauxval features) - #150852 (std: sys: fs: uefi: Implement File::write) - #150871 (Use f64 NaN in documentation instead of sqrt(-1.0)) - #150878 (Emit an error for linking staticlibs on BPF) - #150911 (Add missing documentation for globs feature) - #150913 (compiler: Forward attributes to eii-expanded macros) - #150916 (Once again, reorganize the EII tests a bit) r? @ghost
Rollup of 12 pull requests Successful merges: - #150947 (alloctests: Don't run the longer partial-sort tests under Miri) - #148196 (Implement create_dir_all() to operate iteratively instead of recursively) - #150494 ( Fix dso_local for external statics with linkage) - #150788 (THIR patterns: Replace `AscribeUserType` and `ExpandedConstant` wrappers with per-node data) - #150799 (Fix ICE: can't type-check body of DefId for issue #148729) - #150804 (Remove std_detect_file_io and std_detect_dlsym_getauxval features) - #150852 (std: sys: fs: uefi: Implement File::write) - #150871 (Use f64 NaN in documentation instead of sqrt(-1.0)) - #150878 (Emit an error for linking staticlibs on BPF) - #150911 (Add missing documentation for globs feature) - #150913 (compiler: Forward attributes to eii-expanded macros) - #150916 (Once again, reorganize the EII tests a bit) r? @ghost
Rollup merge of #150788 - thir-pat, r=Nadrieril THIR patterns: Replace `AscribeUserType` and `ExpandedConstant` wrappers with per-node data This PR removes the `AscribeUserType` and `ExpandedConstant` variants from `thir::PatKind`, and replaces them with an `Option<Box<PatExtra>>` field attached to every `thir::Pat`. ### Why remove these variants? Unlike other THIR pattern kinds, these variants are mere “wrappers” that exist to attach some additional information to an underlying pattern node. There are several places where code that consumes THIR patterns needs to carefully “unpeel” any wrapper nodes, in order to match on the underlying pattern. This is clunky, and easy to forget to do, especially since it's not always obvious where the wrapper nodes can and can't appear. Attaching the data to an optional per-node field makes it easier for consuming code to simply ignore the extra data when it is not relevant. (One downside is that it is now easier to accidentally ignore the extra data when it *is* relevant, but I think that's generally a favourable tradeoff.) ### Impact After this change, THIR pattern trees should be “logically identical” to the previous THIR pattern trees, in the sense that information that was carried by wrapper nodes should now be directly attached to the non-wrapper nodes that were being wrapped. Types and spans associated with THIR pattern nodes should (hopefully!) still be accurate. There should be no change to the output of THIR-based checks or MIR building.
This PR removes the
AscribeUserTypeandExpandedConstantvariants fromthir::PatKind, and replaces them with anOption<Box<PatExtra>>field attached to everythir::Pat.Why remove these variants?
Unlike other THIR pattern kinds, these variants are mere “wrappers” that exist to attach some additional information to an underlying pattern node.
There are several places where code that consumes THIR patterns needs to carefully “unpeel” any wrapper nodes, in order to match on the underlying pattern. This is clunky, and easy to forget to do, especially since it's not always obvious where the wrapper nodes can and can't appear.
Attaching the data to an optional per-node field makes it easier for consuming code to simply ignore the extra data when it is not relevant.
(One downside is that it is now easier to accidentally ignore the extra data when it is relevant, but I think that's generally a favourable tradeoff.)
Impact
After this change, THIR pattern trees should be “logically identical” to the previous THIR pattern trees, in the sense that information that was carried by wrapper nodes should now be directly attached to the non-wrapper nodes that were being wrapped. Types and spans associated with THIR pattern nodes should (hopefully!) still be accurate.
There should be no change to the output of THIR-based checks or MIR building.