prefer T::IS_ZST over manual check#155840
prefer T::IS_ZST over manual check#155840Lars-Schumann wants to merge 3 commits intorust-lang:mainfrom
T::IS_ZST over manual check#155840Conversation
|
@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.
prefer `T::IS_ZST` over manual check
This comment has been minimized.
This comment has been minimized.
0174ef9 to
cefd2f3
Compare
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (b37c1ea): comparison URL. Overall result: no relevant changes - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (primary 1.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 3.8%, secondary 2.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 488.641s -> 495.724s (1.45%) |
|
There are also some instances of this check in the compiler itself, and some ZST checks that are spelt differently. There's still these instances in the library:
And the compiler:
There's also a bunch in |
| #![feature(dropck_eyepatch)] | ||
| #![feature(never_type)] | ||
| #![feature(rustc_attrs)] | ||
| #![feature(sized_type_properties)] |
There was a problem hiding this comment.
Rather than enabling this whole feature, would it be better for the compiler to have it's own IsZst trait specifically for IS_ZST?
There was a problem hiding this comment.
sized_type_properties is a pretty small feature, it only gates the SizedTypeProperties trait which does nothing but define a few constants. I don't know what rustc's policy on avoiding unstable features is, if it is an issue I'm happy to make such a trait.
|
Portable SIMD is developed in its own repository. If possible, consider making this change to rust-lang/portable-simd instead. cc @calebzulawski, @programmerjake
cc @tgross35 |
|
rustbot has assigned @ShoyuVanilla. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Oh, great that this pings the world :], I assume I just remove the relevant changes here and make separate PRs to those repos? |
| // Ensure T is not a ZST. | ||
| const { assert!(mem::size_of::<T>() != 0) }; | ||
| const { assert!(!T::IS_ZST) }; |
There was a problem hiding this comment.
What is the reason for this change? The top post says clearer intent and possible perf improvement, but it has a comment and it's in const.
There was a problem hiding this comment.
We want to assure T is not a ZST, !T::IS_ZST is easier to read than mem::size_of::<T>() != 0) and the canonical way to make this check.
Regarding the comment, it seems to be redundant with this change, we could remove it.
|
This changes seems fine for anything already using the feature ( At a minimum please drop the subtree changes, it's better to minimize unstable features where possible so syncs are less painful if things change. |
makes the intent clearer and possible small perf improvement