Skip to content

Commit 9c83b56

Browse files
Mark defaulted PartialEq/PartialOrd methods as const
1 parent 9b45f04 commit 9c83b56

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/core/src/cmp.rs

+5
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
215215
#[inline]
216216
#[must_use]
217217
#[stable(feature = "rust1", since = "1.0.0")]
218+
#[default_method_body_is_const]
218219
fn ne(&self, other: &Rhs) -> bool {
219220
!self.eq(other)
220221
}
@@ -1031,6 +1032,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
10311032
#[inline]
10321033
#[must_use]
10331034
#[stable(feature = "rust1", since = "1.0.0")]
1035+
#[default_method_body_is_const]
10341036
fn lt(&self, other: &Rhs) -> bool {
10351037
matches!(self.partial_cmp(other), Some(Less))
10361038
}
@@ -1050,6 +1052,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
10501052
#[inline]
10511053
#[must_use]
10521054
#[stable(feature = "rust1", since = "1.0.0")]
1055+
#[default_method_body_is_const]
10531056
fn le(&self, other: &Rhs) -> bool {
10541057
// Pattern `Some(Less | Eq)` optimizes worse than negating `None | Some(Greater)`.
10551058
// FIXME: The root cause was fixed upstream in LLVM with:
@@ -1072,6 +1075,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
10721075
#[inline]
10731076
#[must_use]
10741077
#[stable(feature = "rust1", since = "1.0.0")]
1078+
#[default_method_body_is_const]
10751079
fn gt(&self, other: &Rhs) -> bool {
10761080
matches!(self.partial_cmp(other), Some(Greater))
10771081
}
@@ -1091,6 +1095,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
10911095
#[inline]
10921096
#[must_use]
10931097
#[stable(feature = "rust1", since = "1.0.0")]
1098+
#[default_method_body_is_const]
10941099
fn ge(&self, other: &Rhs) -> bool {
10951100
matches!(self.partial_cmp(other), Some(Greater | Equal))
10961101
}

0 commit comments

Comments
 (0)