Skip to content

Commit 3c92f25

Browse files
committed
Auto merge of #106210 - fee1-dead-contrib:const-closure-trait-method, r=compiler-errors
Allow trait method paths to satisfy const Fn bounds r? `@oli-obk`
2 parents b36e02e + 2549b60 commit 3c92f25

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

core/src/cmp.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,12 @@ pub trait Ord: Eq + PartialOrd<Self> {
798798
Self: Sized,
799799
Self: ~const Destruct,
800800
{
801-
// HACK(fee1-dead): go back to using `self.max_by(other, Ord::cmp)`
802-
// when trait methods are allowed to be used when a const closure is
803-
// expected.
801+
#[cfg(not(bootstrap))]
802+
{
803+
max_by(self, other, Ord::cmp)
804+
}
805+
806+
#[cfg(bootstrap)]
804807
match self.cmp(&other) {
805808
Ordering::Less | Ordering::Equal => other,
806809
Ordering::Greater => self,
@@ -825,9 +828,12 @@ pub trait Ord: Eq + PartialOrd<Self> {
825828
Self: Sized,
826829
Self: ~const Destruct,
827830
{
828-
// HACK(fee1-dead): go back to using `self.min_by(other, Ord::cmp)`
829-
// when trait methods are allowed to be used when a const closure is
830-
// expected.
831+
#[cfg(not(bootstrap))]
832+
{
833+
min_by(self, other, Ord::cmp)
834+
}
835+
836+
#[cfg(bootstrap)]
831837
match self.cmp(&other) {
832838
Ordering::Less | Ordering::Equal => self,
833839
Ordering::Greater => other,

0 commit comments

Comments
 (0)