Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReplace usage of std::intrinsics::discriminant_value with `match` #11884
Conversation
highfive
commented
Jun 27, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Jun 27, 2016
|
@bors-servo try |
Replace usage of std::intrinsics::discriminant_value in properties.mako.rs <!-- Please describe your changes on the following line: --> **WIP, do not merge yet.** --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
|
Test crate: #![feature(core_intrinsics)]
extern crate style;
use std::intrinsics::discriminant_value;
pub fn with_match(decl: &style::properties::PropertyDeclaration) -> usize {
decl.discriminant_value()
}
pub fn with_intrinsic(decl: &style::properties::PropertyDeclaration) -> usize {
unsafe { discriminant_value(decl) as usize }
}
|
|
|
|
r? @bholley |
|
|
|
@bors-servo r+ Reviewed 2 of 2 files at r1, 1 of 1 files at r2, 2 of 2 files at r3, 2 of 2 files at r4, 2 of 2 files at r5. Comments from Reviewable |
|
|
Replace usage of std::intrinsics::discriminant_value with `match` <!-- Please describe your changes on the following line: --> Replace usage of `std::intrinsics::discriminant_value` with per-enum generated code that uses `match` expressions. The LLVM IR shows that this optimizes well in release mode. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix part of #11815. <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require new tests because they shouldn’t change any behavior. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11884) <!-- Reviewable:end -->
|
|
SimonSapin commentedJun 27, 2016
•
edited
Replace usage of
std::intrinsics::discriminant_valuewith per-enum generated code that usesmatchexpressions. The LLVM IR shows that this optimizes well in release mode../mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is