]> git.lizzy.rs Git - rust.git/commitdiff
Avoid tupling at the callee
authorDeadbeef <ent3rm4n@gmail.com>
Thu, 14 Oct 2021 06:18:53 +0000 (06:18 +0000)
committerDeadbeef <ent3rm4n@gmail.com>
Thu, 14 Oct 2021 06:18:53 +0000 (06:18 +0000)
library/core/src/intrinsics.rs
src/test/ui/intrinsics/const-eval-select-bad.rs
src/test/ui/intrinsics/const-eval-select-bad.stderr
src/test/ui/intrinsics/const-eval-select-x86_64.rs
src/test/ui/intrinsics/const-eval-select.rs

index da0591418f072732c4e7d6246ab7667c93cf1dfd..54d0805550ac560e065cb4e43d6cbf5a42a43848 100644 (file)
@@ -2266,10 +2266,10 @@ pub unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
     called_at_rt: G,
 ) -> RET
 where
-    F: ~const FnOnce(ARG) -> RET,
-    G: FnOnce(ARG) -> RET + ~const Drop,
+    F: ~const FnOnce<ARG, Output = RET>,
+    G: FnOnce<ARG, Output = RET> + ~const Drop,
 {
-    called_at_rt(arg)
+    called_at_rt.call_once(arg)
 }
 
 #[cfg(not(bootstrap))]
@@ -2285,8 +2285,8 @@ pub unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
     _called_at_rt: G,
 ) -> RET
 where
-    F: ~const FnOnce(ARG) -> RET,
-    G: FnOnce(ARG) -> RET + ~const Drop,
+    F: ~const FnOnce<ARG, Output = RET>,
+    G: FnOnce<ARG, Output = RET> + ~const Drop,
 {
-    called_in_const(arg)
+    called_in_const.call_once(arg)
 }
index 1e5bf7a70b8c4bc3598ec4136c6f091defd9ecd8..8fbdc0c39c6aa38edce10d2f98470a2b06533879 100644 (file)
@@ -3,22 +3,22 @@
 use std::intrinsics::const_eval_select;
 
 const fn not_fn_items() {
-    const_eval_select((), |()| {}, |()| {});
-    //~^ ERROR expected a `FnOnce<((),)>` closure
+    const_eval_select((), || {}, || {});
+    //~^ ERROR expected a `FnOnce<()>` closure
     const_eval_select((), 42, 0xDEADBEEF);
-    //~^ ERROR expected a `FnOnce<((),)>` closure
+    //~^ ERROR expected a `FnOnce<()>` closure
 }
 
-const fn foo((n,): (i32,)) -> i32 {
+const fn foo(n: i32) -> i32 {
     n
 }
 
-fn bar((n,): (i32,)) -> bool {
+fn bar(n: i32) -> bool {
     assert_eq!(n, 0, "{} must be equal to {}", n, 0);
     n == 0
 }
 
-fn baz((n,): (bool,)) -> i32 {
+fn baz(n: bool) -> i32 {
     assert!(n, "{} must be true", n);
     n as i32
 }
index a38eb627e341de280974e98b2fb998deec6281dc..78647e92138c2ccaa8dd3cd29001265654afea8b 100644 (file)
@@ -1,34 +1,36 @@
-error[E0277]: expected a `FnOnce<((),)>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:34]`
-  --> $DIR/const-eval-select-bad.rs:6:36
+error[E0277]: expected a `FnOnce<()>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`
+  --> $DIR/const-eval-select-bad.rs:6:34
    |
-LL |     const_eval_select((), |()| {}, |()| {});
-   |     -----------------              ^^^^^^^ expected an `FnOnce<((),)>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:34]`
+LL |     const_eval_select((), || {}, || {});
+   |     -----------------            ^^^^^ expected an `FnOnce<()>` closure, found `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`
    |     |
    |     required by a bound introduced by this call
    |
-   = help: the trait `FnOnce<((),)>` is not implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:34]`
+   = help: the trait `FnOnce<()>` is not implemented for `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]`
+   = note: wrap the `[closure@$DIR/const-eval-select-bad.rs:6:27: 6:32]` in a closure with no arguments: `|| { /* code */ }`
 note: required by a bound in `const_eval_select`
   --> $SRC_DIR/core/src/intrinsics.rs:LL:COL
    |
-LL |     F: ~const FnOnce(ARG) -> RET,
-   |        ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
+LL |     F: ~const FnOnce<ARG, Output = RET>,
+   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
 
-error[E0277]: expected a `FnOnce<((),)>` closure, found `{integer}`
+error[E0277]: expected a `FnOnce<()>` closure, found `{integer}`
   --> $DIR/const-eval-select-bad.rs:8:31
    |
 LL |     const_eval_select((), 42, 0xDEADBEEF);
-   |     -----------------         ^^^^^^^^^^ expected an `FnOnce<((),)>` closure, found `{integer}`
+   |     -----------------         ^^^^^^^^^^ expected an `FnOnce<()>` closure, found `{integer}`
    |     |
    |     required by a bound introduced by this call
    |
-   = help: the trait `FnOnce<((),)>` is not implemented for `{integer}`
+   = help: the trait `FnOnce<()>` is not implemented for `{integer}`
+   = note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }`
 note: required by a bound in `const_eval_select`
   --> $SRC_DIR/core/src/intrinsics.rs:LL:COL
    |
-LL |     F: ~const FnOnce(ARG) -> RET,
-   |        ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
+LL |     F: ~const FnOnce<ARG, Output = RET>,
+   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
 
-error[E0271]: type mismatch resolving `<fn((i32,)) -> bool {bar} as FnOnce<((i32,),)>>::Output == i32`
+error[E0271]: type mismatch resolving `<fn(i32) -> bool {bar} as FnOnce<(i32,)>>::Output == i32`
   --> $DIR/const-eval-select-bad.rs:27:5
    |
 LL |     const_eval_select((1,), foo, bar);
@@ -37,25 +39,25 @@ LL |     const_eval_select((1,), foo, bar);
 note: required by a bound in `const_eval_select`
   --> $SRC_DIR/core/src/intrinsics.rs:LL:COL
    |
-LL |     G: FnOnce(ARG) -> RET + ~const Drop,
-   |                       ^^^ required by this bound in `const_eval_select`
+LL |     G: FnOnce<ARG, Output = RET> + ~const Drop,
+   |                    ^^^^^^^^^^^^ required by this bound in `const_eval_select`
 
 error[E0631]: type mismatch in function arguments
   --> $DIR/const-eval-select-bad.rs:32:37
    |
-LL | const fn foo((n,): (i32,)) -> i32 {
-   | --------------------------------- found signature of `fn((i32,)) -> _`
+LL | const fn foo(n: i32) -> i32 {
+   | --------------------------- found signature of `fn(i32) -> _`
 ...
 LL |     const_eval_select((true,), foo, baz);
-   |     -----------------               ^^^ expected signature of `fn((bool,)) -> _`
+   |     -----------------               ^^^ expected signature of `fn(bool) -> _`
    |     |
    |     required by a bound introduced by this call
    |
 note: required by a bound in `const_eval_select`
   --> $SRC_DIR/core/src/intrinsics.rs:LL:COL
    |
-LL |     F: ~const FnOnce(ARG) -> RET,
-   |        ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
+LL |     F: ~const FnOnce<ARG, Output = RET>,
+   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select`
 
 error: aborting due to 4 previous errors
 
index 807db65bc72d9885fc62b5df7b0bc901066ee14e..afec8e054bb76b4adc69a613a0e3216cae9b3ce8 100644 (file)
@@ -6,11 +6,11 @@
 use std::arch::x86_64::*;
 use std::mem::transmute;
 
-const fn eq_ct((x, y): ([i32; 4], [i32; 4])) -> bool {
+const fn eq_ct(x: [i32; 4], y: [i32; 4]) -> bool {
     x[0] == y[0] && x[1] == y[1] && x[2] == y[2] && x[3] == y[3]
 }
 
-fn eq_rt((x, y): ([i32; 4], [i32; 4])) -> bool {
+fn eq_rt(x: [i32; 4], y: [i32; 4]) -> bool {
     unsafe {
         let x = _mm_loadu_si128(&x as *const _ as *const _);
         let y = _mm_loadu_si128(&y as *const _ as *const _);
index 0b2c2f6ed4f067e4005c21e4536368e66075fce0..744db2f15b0560952d558528c18a380b105a98d9 100644 (file)
@@ -4,11 +4,11 @@
 
 use std::intrinsics::const_eval_select;
 
-const fn yes(_: ()) -> bool {
+const fn yes() -> bool {
     true
 }
 
-fn no(_: ()) -> bool {
+fn no() -> bool {
     false
 }