Skip to content

Commit ca1eb43

Browse files
committed
test use in libcore
1 parent b0aa859 commit ca1eb43

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

library/core/src/cmp.rs

+16-10
Original file line numberDiff line numberDiff line change
@@ -1234,17 +1234,23 @@ where
12341234
F: ~const Destruct,
12351235
K: ~const Destruct,
12361236
{
1237-
const fn imp<T, F: ~const FnMut(&T) -> K, K: ~const Ord>(
1238-
f: &mut F,
1239-
(v1, v2): (&T, &T),
1240-
) -> Ordering
1241-
where
1242-
T: ~const Destruct,
1243-
K: ~const Destruct,
1244-
{
1245-
f(v1).cmp(&f(v2))
1237+
cfg_if! {
1238+
if #[cfg(bootstrap)] {
1239+
const fn imp<T, F: ~const FnMut(&T) -> K, K: ~const Ord>(
1240+
f: &mut F,
1241+
(v1, v2): (&T, &T),
1242+
) -> Ordering
1243+
where
1244+
T: ~const Destruct,
1245+
K: ~const Destruct,
1246+
{
1247+
f(v1).cmp(&f(v2))
1248+
}
1249+
min_by(v1, v2, ConstFnMutClosure::new(&mut f, imp))
1250+
} else {
1251+
min_by(v1, v2, const |v1, v2| f(v1).cmp(&f(v2)))
1252+
}
12461253
}
1247-
min_by(v1, v2, ConstFnMutClosure::new(&mut f, imp))
12481254
}
12491255

12501256
/// Compares and returns the maximum of two values.

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
#![feature(cfg_sanitize)]
192192
#![feature(cfg_target_has_atomic)]
193193
#![feature(cfg_target_has_atomic_equal_alignment)]
194+
#![cfg_attr(not(bootstrap), feature(const_closures))]
194195
#![feature(const_fn_floating_point_arithmetic)]
195196
#![feature(const_mut_refs)]
196197
#![feature(const_precise_live_drops)]

tests/ui-fulldeps/pprust-expr-roundtrip.rs

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
126126
g(ExprKind::Closure(Box::new(Closure {
127127
binder: ClosureBinder::NotPresent,
128128
capture_clause: CaptureBy::Value,
129+
constness: Const::No,
129130
asyncness: Async::No,
130131
movability: Movability::Movable,
131132
fn_decl: decl.clone(),

0 commit comments

Comments
 (0)