-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #83819 - AngelicosPhosphoros:issue-73338-fix-partial-eq…
…-impl, r=Mark-Simulacrum Optimize jumps in PartialOrd le Closes #73338 This change stops default implementation of `le()` method of PartialOrd from generating jumps.
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// This test checks that comparison operation | ||
// generated by #[derive(PartialOrd)] | ||
// doesn't contain jumps for C enums | ||
|
||
// compile-flags: -Copt-level=3 | ||
|
||
#![crate_type="lib"] | ||
|
||
#[repr(u32)] | ||
#[derive(Copy, Clone, Eq, PartialEq, PartialOrd)] | ||
pub enum Foo { | ||
Zero, | ||
One, | ||
Two, | ||
} | ||
|
||
#[no_mangle] | ||
pub fn compare_less(a: Foo, b: Foo)->bool{ | ||
// CHECK-NOT: br {{.*}} | ||
a < b | ||
} | ||
|
||
#[no_mangle] | ||
pub fn compare_le(a: Foo, b: Foo)->bool{ | ||
// CHECK-NOT: br {{.*}} | ||
a <= b | ||
} | ||
|
||
#[no_mangle] | ||
pub fn compare_ge(a: Foo, b: Foo)->bool{ | ||
// CHECK-NOT: br {{.*}} | ||
a >= b | ||
} | ||
|
||
#[no_mangle] | ||
pub fn compare_greater(a: Foo, b: Foo)->bool{ | ||
// CHECK-NOT: br {{.*}} | ||
a > b | ||
} |