diff options
Diffstat (limited to 'src/test/ui/unboxed-closures')
6 files changed, 21 insertions, 23 deletions
diff --git a/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.rs b/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.rs index 925463d6d..d2e486002 100644 --- a/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.rs +++ b/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.rs @@ -1,8 +1,8 @@ #![feature(unboxed_closures)] fn a<F: Fn<usize>>(f: F) {} +//~^ ERROR type parameter to bare `Fn` trait must be a tuple fn main() { a(|_: usize| {}); - //~^ ERROR mismatched types } diff --git a/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.stderr b/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.stderr index 9a24fb8c2..1c18eb0fc 100644 --- a/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.stderr +++ b/src/test/ui/unboxed-closures/non-tupled-arg-mismatch.stderr @@ -1,17 +1,15 @@ -error[E0308]: mismatched types - --> $DIR/non-tupled-arg-mismatch.rs:6:5 - | -LL | a(|_: usize| {}); - | ^ types differ - | - = note: expected trait `Fn<usize>` - found trait `Fn<(usize,)>` -note: required by a bound in `a` +error[E0059]: type parameter to bare `Fn` trait must be a tuple --> $DIR/non-tupled-arg-mismatch.rs:3:9 | LL | fn a<F: Fn<usize>>(f: F) {} - | ^^^^^^^^^ required by this bound in `a` + | ^^^^^^^^^ the trait `Tuple` is not implemented for `usize` + | +note: required by a bound in `Fn` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + | +LL | pub trait Fn<Args: Tuple>: FnMut<Args> { + | ^^^^^ required by this bound in `Fn` error: aborting due to previous error -For more information about this error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs index ed8d72114..7377359b6 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.rs @@ -1,12 +1,12 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] // Tests that we can't move out of an unboxed closure environment // if the upvar is captured by ref or the closure takes self by // reference. -fn to_fn<A,F:Fn<A>>(f: F) -> F { f } -fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f } -fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f } +fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f } +fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f } +fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f } fn main() { // By-ref cases diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs index 57e6d3065..c57312b43 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs @@ -2,12 +2,12 @@ // as `mut` through a closure. Also test that we CAN mutate a moved copy, // unless this is a `Fn` closure. Issue #16749. -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] use std::mem; -fn to_fn<A,F:Fn<A>>(f: F) -> F { f } -fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f } +fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f } +fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f } fn a() { let n = 0; diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr index d6e74b5b8..26f97b519 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr @@ -28,8 +28,8 @@ LL | n += 1; error[E0594]: cannot assign to `n`, as it is a captured variable in a `Fn` closure --> $DIR/unboxed-closures-mutate-upvar.rs:53:9 | -LL | fn to_fn<A,F:Fn<A>>(f: F) -> F { f } - | - change this to accept `FnMut` instead of `Fn` +LL | fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f } + | - change this to accept `FnMut` instead of `Fn` ... LL | let mut f = to_fn(move || { | ----- ------- in this closure diff --git a/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs b/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs index 0e727b11c..7289d9322 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.rs @@ -1,6 +1,6 @@ -#![feature(unboxed_closures)] +#![feature(unboxed_closures, tuple_trait)] -fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f } +fn to_fn_mut<A:std::marker::Tuple,F:FnMut<A>>(f: F) -> F { f } fn main() { let mut_ = to_fn_mut(|x| x); |