]> git.lizzy.rs Git - rust.git/commitdiff
test use in libcore
authorDeadbeef <ent3rm4n@gmail.com>
Mon, 26 Dec 2022 10:48:54 +0000 (10:48 +0000)
committerDeadbeef <ent3rm4n@gmail.com>
Thu, 12 Jan 2023 02:28:38 +0000 (02:28 +0000)
library/core/src/cmp.rs
library/core/src/lib.rs
tests/ui-fulldeps/pprust-expr-roundtrip.rs

index ebf5baa3c020bf898a68c25094675f4f0422e81d..a7d6fec7d3dc1354121ea6058cb766bedc7affbe 100644 (file)
@@ -1234,17 +1234,23 @@ pub const fn min_by_key<T, F: ~const FnMut(&T) -> K, K: ~const Ord>(v1: T, v2: T
     F: ~const Destruct,
     K: ~const Destruct,
 {
-    const fn imp<T, F: ~const FnMut(&T) -> 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<T, F: ~const FnMut(&T) -> 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.
index 9e0d7cab63e5c1d3efc36e508955cc9b8eb3dd89..20b325546e2ff2ebb25e8f2ddffa239e743f5948 100644 (file)
 #![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)]
index 6dbabc8eb348512d437c60bbd9aad8113017310e..7a91dcf0dad35b9808f64c5b61f5859fc78fb9a0 100644 (file)
@@ -126,6 +126,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
                     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(),