From ca1eb4309e7dc169873dfd5c33401f99937e8cc9 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Mon, 26 Dec 2022 10:48:54 +0000 Subject: [PATCH] test use in libcore --- library/core/src/cmp.rs | 26 +++++++++++++--------- library/core/src/lib.rs | 1 + tests/ui-fulldeps/pprust-expr-roundtrip.rs | 1 + 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index ebf5baa3c02..a7d6fec7d3d 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1234,17 +1234,23 @@ where F: ~const Destruct, K: ~const Destruct, { - const fn imp K, K: ~const Ord>( - f: &mut F, - (v1, v2): (&T, &T), - ) -> Ordering - where - T: ~const Destruct, - K: ~const Destruct, - { - f(v1).cmp(&f(v2)) + cfg_if! { + if #[cfg(bootstrap)] { + const fn imp K, K: ~const Ord>( + f: &mut F, + (v1, v2): (&T, &T), + ) -> Ordering + where + T: ~const Destruct, + K: ~const Destruct, + { + f(v1).cmp(&f(v2)) + } + min_by(v1, v2, ConstFnMutClosure::new(&mut f, imp)) + } else { + min_by(v1, v2, const |v1, v2| f(v1).cmp(&f(v2))) + } } - min_by(v1, v2, ConstFnMutClosure::new(&mut f, imp)) } /// Compares and returns the maximum of two values. diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 9e0d7cab63e..20b325546e2 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -191,6 +191,7 @@ #![feature(cfg_sanitize)] #![feature(cfg_target_has_atomic)] #![feature(cfg_target_has_atomic_equal_alignment)] +#![cfg_attr(not(bootstrap), feature(const_closures))] #![feature(const_fn_floating_point_arithmetic)] #![feature(const_mut_refs)] #![feature(const_precise_live_drops)] diff --git a/tests/ui-fulldeps/pprust-expr-roundtrip.rs b/tests/ui-fulldeps/pprust-expr-roundtrip.rs index 6dbabc8eb34..7a91dcf0dad 100644 --- a/tests/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/tests/ui-fulldeps/pprust-expr-roundtrip.rs @@ -126,6 +126,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P)) { g(ExprKind::Closure(Box::new(Closure { binder: ClosureBinder::NotPresent, capture_clause: CaptureBy::Value, + constness: Const::No, asyncness: Async::No, movability: Movability::Movable, fn_decl: decl.clone(),