Skip to content

Commit 6770dbd

Browse files
committed
Avoid tupling at the callee
1 parent 5387b65 commit 6770dbd

File tree

5 files changed

+38
-36
lines changed

5 files changed

+38
-36
lines changed

library/core/src/intrinsics.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2266,10 +2266,10 @@ pub const unsafe fn const_eval_select<ARG, F, G, RET>(
22662266
called_at_rt: G,
22672267
) -> RET
22682268
where
2269-
F: ~const FnOnce(ARG) -> RET,
2270-
G: FnOnce(ARG) -> RET + ~const Drop,
2269+
F: ~const FnOnce<ARG, Output = RET>,
2270+
G: FnOnce<ARG, Output = RET> + ~const Drop,
22712271
{
2272-
called_at_rt(arg)
2272+
called_at_rt.call_once(arg)
22732273
}
22742274

22752275
#[cfg(not(bootstrap))]
@@ -2285,8 +2285,8 @@ pub const unsafe fn const_eval_select_ct<ARG, F, G, RET>(
22852285
_called_at_rt: G,
22862286
) -> RET
22872287
where
2288-
F: ~const FnOnce(ARG) -> RET,
2289-
G: FnOnce(ARG) -> RET + ~const Drop,
2288+
F: ~const FnOnce<ARG, Output = RET>,
2289+
G: FnOnce<ARG, Output = RET> + ~const Drop,
22902290
{
2291-
called_in_const(arg)
2291+
called_in_const.call_once(arg)
22922292
}

src/test/ui/intrinsics/const-eval-select-bad.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
use std::intrinsics::const_eval_select;
44

55
const fn not_fn_items() {
6-
const_eval_select((), |()| {}, |()| {});
7-
//~^ ERROR expected a `FnOnce<((),)>` closure
6+
const_eval_select((), || {}, || {});
7+
//~^ ERROR expected a `FnOnce<()>` closure
88
const_eval_select((), 42, 0xDEADBEEF);
9-
//~^ ERROR expected a `FnOnce<((),)>` closure
9+
//~^ ERROR expected a `FnOnce<()>` closure
1010
}
1111

12-
const fn foo((n,): (i32,)) -> i32 {
12+
const fn foo(n: i32) -> i32 {
1313
n
1414
}
1515

16-
fn bar((n,): (i32,)) -> bool {
16+
fn bar(n: i32) -> bool {
1717
assert_eq!(n, 0, "{} must be equal to {}", n, 0);
1818
n == 0
1919
}
2020

21-
fn baz((n,): (bool,)) -> i32 {
21+
fn baz(n: bool) -> i32 {
2222
assert!(n, "{} must be true", n);
2323
n as i32
2424
}

src/test/ui/intrinsics/const-eval-select-bad.stderr

+22-20
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
error[E0277]: expected a `FnOnce<((),)>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:34]`
2-
--> $DIR/const-eval-select-bad.rs:6:36
1+
error[E0277]: expected a `FnOnce<()>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`
2+
--> $DIR/const-eval-select-bad.rs:6:34
33
|
4-
LL | const_eval_select((), |()| {}, |()| {});
5-
| ----------------- ^^^^^^^ expected an `FnOnce<((),)>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:34]`
4+
LL | const_eval_select((), || {}, || {});
5+
| ----------------- ^^^^^ expected an `FnOnce<()>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`
66
| |
77
| required by a bound introduced by this call
88
|
9-
= help: the trait `FnOnce<((),)>` is not implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:34]`
9+
= help: the trait `FnOnce<()>` is not implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`
10+
= note: wrap the `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]` in a closure with no arguments: `|| { /* code */ }`
1011
note: required by a bound in `const_eval_select`
1112
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
1213
|
13-
LL | F: ~const FnOnce(ARG) -> RET,
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
14+
LL | F: ~const FnOnce<ARG, Output = RET>,
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
1516

16-
error[E0277]: expected a `FnOnce<((),)>` closure, found `{integer}`
17+
error[E0277]: expected a `FnOnce<()>` closure, found `{integer}`
1718
--> $DIR/const-eval-select-bad.rs:8:31
1819
|
1920
LL | const_eval_select((), 42, 0xDEADBEEF);
20-
| ----------------- ^^^^^^^^^^ expected an `FnOnce<((),)>` closure, found `{integer}`
21+
| ----------------- ^^^^^^^^^^ expected an `FnOnce<()>` closure, found `{integer}`
2122
| |
2223
| required by a bound introduced by this call
2324
|
24-
= help: the trait `FnOnce<((),)>` is not implemented for `{integer}`
25+
= help: the trait `FnOnce<()>` is not implemented for `{integer}`
26+
= note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }`
2527
note: required by a bound in `const_eval_select`
2628
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
2729
|
28-
LL | F: ~const FnOnce(ARG) -> RET,
29-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
30+
LL | F: ~const FnOnce<ARG, Output = RET>,
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
3032

31-
error[E0271]: type mismatch resolving `<fn((i32,)) -> bool {bar} as FnOnce<((i32,),)>>::Output == i32`
33+
error[E0271]: type mismatch resolving `<fn(i32) -> bool {bar} as FnOnce<(i32,)>>::Output == i32`
3234
--> $DIR/const-eval-select-bad.rs:27:5
3335
|
3436
LL | const_eval_select((1,), foo, bar);
@@ -37,25 +39,25 @@ LL | const_eval_select((1,), foo, bar);
3739
note: required by a bound in `const_eval_select`
3840
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
3941
|
40-
LL | G: FnOnce(ARG) -> RET + ~const Drop,
41-
| ^^^ required by this bound in `const_eval_select`
42+
LL | G: FnOnce<ARG, Output = RET> + ~const Drop,
43+
| ^^^^^^^^^^^^ required by this bound in `const_eval_select`
4244

4345
error[E0631]: type mismatch in function arguments
4446
--> $DIR/const-eval-select-bad.rs:32:37
4547
|
46-
LL | const fn foo((n,): (i32,)) -> i32 {
47-
| --------------------------------- found signature of `fn((i32,)) -> _`
48+
LL | const fn foo(n: i32) -> i32 {
49+
| --------------------------- found signature of `fn(i32) -> _`
4850
...
4951
LL | const_eval_select((true,), foo, baz);
50-
| ----------------- ^^^ expected signature of `fn((bool,)) -> _`
52+
| ----------------- ^^^ expected signature of `fn(bool) -> _`
5153
| |
5254
| required by a bound introduced by this call
5355
|
5456
note: required by a bound in `const_eval_select`
5557
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
5658
|
57-
LL | F: ~const FnOnce(ARG) -> RET,
58-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
59+
LL | F: ~const FnOnce<ARG, Output = RET>,
60+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
5961

6062
error: aborting due to 4 previous errors
6163

src/test/ui/intrinsics/const-eval-select-x86_64.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use std::intrinsics::const_eval_select;
66
use std::arch::x86_64::*;
77
use std::mem::transmute;
88

9-
const fn eq_ct((x, y): ([i32; 4], [i32; 4])) -> bool {
9+
const fn eq_ct(x: [i32; 4], y: [i32; 4]) -> bool {
1010
x[0] == y[0] && x[1] == y[1] && x[2] == y[2] && x[3] == y[3]
1111
}
1212

13-
fn eq_rt((x, y): ([i32; 4], [i32; 4])) -> bool {
13+
fn eq_rt(x: [i32; 4], y: [i32; 4]) -> bool {
1414
unsafe {
1515
let x = _mm_loadu_si128(&x as *const _ as *const _);
1616
let y = _mm_loadu_si128(&y as *const _ as *const _);

src/test/ui/intrinsics/const-eval-select.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
use std::intrinsics::const_eval_select;
66

7-
const fn yes(_: ()) -> bool {
7+
const fn yes() -> bool {
88
true
99
}
1010

11-
fn no(_: ()) -> bool {
11+
fn no() -> bool {
1212
false
1313
}
1414

0 commit comments

Comments
 (0)