diff options
Diffstat (limited to 'tests/ui/closures')
30 files changed, 318 insertions, 41 deletions
diff --git a/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2018.stderr b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2018.stderr new file mode 100644 index 000000000..394629c00 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2018.stderr @@ -0,0 +1,33 @@ +error[E0505]: cannot move out of `value` because it is borrowed + --> $DIR/if-let-guards-errors.rs:16:13 + | +LL | let f = |x: &E| { + | ------- borrow of `value` occurs here +LL | match &x { +LL | E::Number(_) if let E::Number(ref mut n) = *value => { } + | ------ borrow occurs due to use in closure +... +LL | let x = value; + | ^^^^^ move out of `value` occurs here +LL | +LL | drop(f); + | - borrow later used here + +error[E0382]: use of moved value: `value` + --> $DIR/if-let-guards-errors.rs:28:13 + | +LL | fn if_let_move(value: Box<E>) { + | ----- move occurs because `value` has type `Box<E>`, which does not implement the `Copy` trait +LL | let f = |x: &E| { + | ------- value moved into closure here +LL | match &x { +LL | E::Number(_) if let E::String(s) = *value => { } + | ------ variable moved due to use in closure +... +LL | let x = value; + | ^^^^^ value used here after move + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0382, E0505. +For more information about an error, try `rustc --explain E0382`. diff --git a/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2021.stderr b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2021.stderr new file mode 100644 index 000000000..567284501 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2021.stderr @@ -0,0 +1,33 @@ +error[E0505]: cannot move out of `value` because it is borrowed + --> $DIR/if-let-guards-errors.rs:16:13 + | +LL | let f = |x: &E| { + | ------- borrow of `*value` occurs here +LL | match &x { +LL | E::Number(_) if let E::Number(ref mut n) = *value => { } + | ------ borrow occurs due to use in closure +... +LL | let x = value; + | ^^^^^ move out of `value` occurs here +LL | +LL | drop(f); + | - borrow later used here + +error[E0382]: use of moved value: `value` + --> $DIR/if-let-guards-errors.rs:28:13 + | +LL | fn if_let_move(value: Box<E>) { + | ----- move occurs because `value` has type `Box<E>`, which does not implement the `Copy` trait +LL | let f = |x: &E| { + | ------- value moved into closure here +LL | match &x { +LL | E::Number(_) if let E::String(s) = *value => { } + | ------ variable moved due to use in closure +... +LL | let x = value; + | ^^^^^ value used here after move + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0382, E0505. +For more information about an error, try `rustc --explain E0382`. diff --git a/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.rs b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.rs new file mode 100644 index 000000000..17e38c033 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.rs @@ -0,0 +1,37 @@ +// Check the if let guards don't force capture by value +// revisions: e2018 e2021 +//[e2018] edition:2018 +//[e2021] edition:2021 + +#![feature(if_let_guard)] +#![allow(irrefutable_let_patterns)] + +fn if_let_ref_mut(mut value: Box<E>) { + let f = |x: &E| { + match &x { + E::Number(_) if let E::Number(ref mut n) = *value => { } + _ => {} + } + }; + let x = value; + //~^ ERROR cannot move out of `value` because it is borrowed + drop(f); +} + +fn if_let_move(value: Box<E>) { + let f = |x: &E| { + match &x { + E::Number(_) if let E::String(s) = *value => { } + _ => {} + } + }; + let x = value; + //~^ ERROR use of moved value: `value` +} + +enum E { + String(String), + Number(i32), +} + +fn main() {} diff --git a/tests/ui/closures/2229_closure_analysis/match/if-let-guards.rs b/tests/ui/closures/2229_closure_analysis/match/if-let-guards.rs new file mode 100644 index 000000000..fa331707b --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/match/if-let-guards.rs @@ -0,0 +1,55 @@ +// Check the if let guards don't force capture by value +// revisions: e2018 e2021 +// check-pass +//[e2018] edition:2018 +//[e2021] edition:2021 + +#![feature(if_let_guard)] +#![allow(irrefutable_let_patterns)] + +fn if_let_underscore(value: Box<E>) { + |x: &E| { + match &x { + E::Number(_) if let _ = *value => { } + _ => {} + } + }; + let x = value; +} + +fn if_let_copy(value: Box<E>) { + |x: &E| { + match &x { + E::Number(_) if let E::Number(n) = *value => { } + _ => {} + } + }; + let x = value; +} + +fn if_let_ref(value: Box<E>) { + |x: &E| { + match &x { + E::Number(_) if let E::Number(ref n) = *value => { } + _ => {} + } + }; + let x = value; +} + +fn if_let_ref_mut(mut value: Box<E>) { + |x: &E| { + match &x { + E::Number(_) if let E::Number(ref mut n) = *value => { } + _ => {} + } + }; + let x = value; +} + +enum E { + String(String), + Number(i32), +} + +fn main() {} diff --git a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr index 3a5fad154..0807f4590 100644 --- a/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr @@ -45,7 +45,8 @@ note: `E2` defined here | LL | pub enum E2 { A, B } | ^^^^^^^^^^^ - = note: the matched value is of type `E2`, which is marked as non-exhaustive + = note: the matched value is of type `E2` + = note: `E2` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL | let _e = || { match e2 { E2::A => (), E2::B => (), _ => todo!() } }; diff --git a/tests/ui/closures/2229_closure_analysis/repr_packed.rs b/tests/ui/closures/2229_closure_analysis/repr_packed.rs index f23670f63..8c23454fa 100644 --- a/tests/ui/closures/2229_closure_analysis/repr_packed.rs +++ b/tests/ui/closures/2229_closure_analysis/repr_packed.rs @@ -3,7 +3,8 @@ #![feature(rustc_attrs)] // `u8` aligned at a byte and are unaffected by repr(packed). -// Therefore we can precisely (and safely) capture references to both the fields. +// Therefore we *could* precisely (and safely) capture references to both the fields, +// but we don't, since we don't want capturing to change when field types change alignment. fn test_alignment_not_affected() { #[repr(packed)] struct Foo { x: u8, y: u8 } @@ -17,11 +18,10 @@ fn test_alignment_not_affected() { //~^ ERROR: First Pass analysis includes: //~| ERROR: Min Capture analysis includes: let z1: &u8 = &foo.x; - //~^ NOTE: Capturing foo[(0, 0)] -> ImmBorrow - //~| NOTE: Min Capture foo[(0, 0)] -> ImmBorrow + //~^ NOTE: Capturing foo[] -> ImmBorrow let z2: &mut u8 = &mut foo.y; - //~^ NOTE: Capturing foo[(1, 0)] -> MutBorrow - //~| NOTE: Min Capture foo[(1, 0)] -> MutBorrow + //~^ NOTE: Capturing foo[] -> MutBorrow + //~| NOTE: Min Capture foo[] -> MutBorrow *z2 = 42; diff --git a/tests/ui/closures/2229_closure_analysis/repr_packed.stderr b/tests/ui/closures/2229_closure_analysis/repr_packed.stderr index 580061ebc..32b3d844c 100644 --- a/tests/ui/closures/2229_closure_analysis/repr_packed.stderr +++ b/tests/ui/closures/2229_closure_analysis/repr_packed.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/repr_packed.rs:13:17 + --> $DIR/repr_packed.rs:14:17 | LL | let mut c = #[rustc_capture_analysis] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | let c = #[rustc_capture_analysis] = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable error: First Pass analysis includes: - --> $DIR/repr_packed.rs:16:5 + --> $DIR/repr_packed.rs:17:5 | LL | / || { LL | | @@ -37,19 +37,19 @@ LL | | println!("({}, {})", z1, z2); LL | | }; | |_____^ | -note: Capturing foo[(0, 0)] -> ImmBorrow - --> $DIR/repr_packed.rs:19:24 +note: Capturing foo[] -> ImmBorrow + --> $DIR/repr_packed.rs:20:24 | LL | let z1: &u8 = &foo.x; | ^^^^^ -note: Capturing foo[(1, 0)] -> MutBorrow +note: Capturing foo[] -> MutBorrow --> $DIR/repr_packed.rs:22:32 | LL | let z2: &mut u8 = &mut foo.y; | ^^^^^ error: Min Capture analysis includes: - --> $DIR/repr_packed.rs:16:5 + --> $DIR/repr_packed.rs:17:5 | LL | / || { LL | | @@ -60,12 +60,7 @@ LL | | println!("({}, {})", z1, z2); LL | | }; | |_____^ | -note: Min Capture foo[(0, 0)] -> ImmBorrow - --> $DIR/repr_packed.rs:19:24 - | -LL | let z1: &u8 = &foo.x; - | ^^^^^ -note: Min Capture foo[(1, 0)] -> MutBorrow +note: Min Capture foo[] -> MutBorrow --> $DIR/repr_packed.rs:22:32 | LL | let z2: &mut u8 = &mut foo.y; diff --git a/tests/ui/closures/capture-unsized-by-move.rs b/tests/ui/closures/capture-unsized-by-move.rs new file mode 100644 index 000000000..1148e34ac --- /dev/null +++ b/tests/ui/closures/capture-unsized-by-move.rs @@ -0,0 +1,10 @@ +// compile-flags: --crate-type=lib + +#![feature(unsized_fn_params)] + +pub fn f(k: dyn std::fmt::Display) { + let k2 = move || { + k.to_string(); + //~^ ERROR the size for values of type `(dyn std::fmt::Display + 'static)` cannot be known at compilation time + }; +} diff --git a/tests/ui/closures/capture-unsized-by-move.stderr b/tests/ui/closures/capture-unsized-by-move.stderr new file mode 100644 index 000000000..d7fafc8ca --- /dev/null +++ b/tests/ui/closures/capture-unsized-by-move.stderr @@ -0,0 +1,14 @@ +error[E0277]: the size for values of type `(dyn std::fmt::Display + 'static)` cannot be known at compilation time + --> $DIR/capture-unsized-by-move.rs:7:9 + | +LL | let k2 = move || { + | -- this closure captures all values by move +LL | k.to_string(); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn std::fmt::Display + 'static)` + = note: all values captured by value by a closure must have a statically known size + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/closures/capture-unsized-by-ref.rs b/tests/ui/closures/capture-unsized-by-ref.rs new file mode 100644 index 000000000..c9e4a5903 --- /dev/null +++ b/tests/ui/closures/capture-unsized-by-ref.rs @@ -0,0 +1,10 @@ +// build-pass +// compile-flags: --crate-type=lib + +#![feature(unsized_fn_params)] + +pub fn f(k: dyn std::fmt::Display) { + let k2 = || { + k.to_string(); + }; +} diff --git a/tests/ui/closures/closure-no-fn-1.stderr b/tests/ui/closures/closure-no-fn-1.stderr index eab7482e6..87e670bb0 100644 --- a/tests/ui/closures/closure-no-fn-1.stderr +++ b/tests/ui/closures/closure-no-fn-1.stderr @@ -7,7 +7,7 @@ LL | let foo: fn(u8) -> u8 = |v: u8| { a += v; a }; | expected due to this | = note: expected fn pointer `fn(u8) -> u8` - found closure `[closure@$DIR/closure-no-fn-1.rs:6:29: 6:36]` + found closure `{closure@$DIR/closure-no-fn-1.rs:6:29: 6:36}` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-no-fn-1.rs:6:39 | diff --git a/tests/ui/closures/closure-no-fn-2.stderr b/tests/ui/closures/closure-no-fn-2.stderr index e1f0143ab..7c7e9d0ce 100644 --- a/tests/ui/closures/closure-no-fn-2.stderr +++ b/tests/ui/closures/closure-no-fn-2.stderr @@ -7,7 +7,7 @@ LL | let bar: fn() -> u8 = || { b }; | expected due to this | = note: expected fn pointer `fn() -> u8` - found closure `[closure@$DIR/closure-no-fn-2.rs:6:27: 6:29]` + found closure `{closure@$DIR/closure-no-fn-2.rs:6:27: 6:29}` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-no-fn-2.rs:6:32 | diff --git a/tests/ui/closures/closure-no-fn-3.stderr b/tests/ui/closures/closure-no-fn-3.stderr index 6009389b1..276e766e8 100644 --- a/tests/ui/closures/closure-no-fn-3.stderr +++ b/tests/ui/closures/closure-no-fn-3.stderr @@ -1,4 +1,4 @@ -error[E0605]: non-primitive cast: `[closure@$DIR/closure-no-fn-3.rs:6:28: 6:30]` as `fn() -> u8` +error[E0605]: non-primitive cast: `{closure@$DIR/closure-no-fn-3.rs:6:28: 6:30}` as `fn() -> u8` --> $DIR/closure-no-fn-3.rs:6:27 | LL | let baz: fn() -> u8 = (|| { b }) as fn() -> u8; diff --git a/tests/ui/closures/closure-no-fn-4.stderr b/tests/ui/closures/closure-no-fn-4.stderr index d1b704884..0bec11ab6 100644 --- a/tests/ui/closures/closure-no-fn-4.stderr +++ b/tests/ui/closures/closure-no-fn-4.stderr @@ -12,7 +12,7 @@ LL | | }; | |_____- `match` arms have incompatible types | = note: expected fn pointer `fn(usize) -> usize` - found closure `[closure@$DIR/closure-no-fn-4.rs:5:18: 5:21]` + found closure `{closure@$DIR/closure-no-fn-4.rs:5:18: 5:21}` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-no-fn-4.rs:5:26 | diff --git a/tests/ui/closures/closure-no-fn-5.stderr b/tests/ui/closures/closure-no-fn-5.stderr index a33b847ea..13d19495d 100644 --- a/tests/ui/closures/closure-no-fn-5.stderr +++ b/tests/ui/closures/closure-no-fn-5.stderr @@ -7,7 +7,7 @@ LL | let bar: fn() -> u8 = || { a; b; c; d; e }; | expected due to this | = note: expected fn pointer `fn() -> u8` - found closure `[closure@$DIR/closure-no-fn-5.rs:10:27: 10:29]` + found closure `{closure@$DIR/closure-no-fn-5.rs:10:27: 10:29}` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-no-fn-5.rs:10:32 | diff --git a/tests/ui/closures/closure-reform-bad.stderr b/tests/ui/closures/closure-reform-bad.stderr index 4c40f70b9..6bb598131 100644 --- a/tests/ui/closures/closure-reform-bad.stderr +++ b/tests/ui/closures/closure-reform-bad.stderr @@ -9,7 +9,7 @@ LL | call_bare(f) | arguments to this function are incorrect | = note: expected fn pointer `for<'a> fn(&'a str)` - found closure `[closure@$DIR/closure-reform-bad.rs:10:13: 10:22]` + found closure `{closure@$DIR/closure-reform-bad.rs:10:13: 10:22}` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-reform-bad.rs:10:43 | diff --git a/tests/ui/closures/closure_cap_coerce_many_fail.stderr b/tests/ui/closures/closure_cap_coerce_many_fail.stderr index ca8a43328..958439e7d 100644 --- a/tests/ui/closures/closure_cap_coerce_many_fail.stderr +++ b/tests/ui/closures/closure_cap_coerce_many_fail.stderr @@ -12,7 +12,7 @@ LL | | }; | |_____- `match` arms have incompatible types | = note: expected fn item `fn(i32, i32) -> i32 {add}` - found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:9:16: 9:22]` + found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:9:16: 9:22}` error[E0308]: `match` arms have incompatible types --> $DIR/closure_cap_coerce_many_fail.rs:18:16 @@ -23,15 +23,15 @@ LL | | "+" => |a, b| (a + b) as i32, | | --------------------- | | | | | the expected closure - | | this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:22]` + | | this is found to be of type `{closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:22}` LL | | "-" => |a, b| (a - b + cap) as i32, | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure LL | | _ => unimplemented!(), LL | | }; | |_____- `match` arms have incompatible types | - = note: expected closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:22]` - found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:18:16: 18:22]` + = note: expected closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:17:16: 17:22}` + found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:18:16: 18:22}` = note: no two closures, even if identical, have the same type = help: consider boxing your closure and/or using it as a trait object @@ -44,15 +44,15 @@ LL | | "+" => |a, b| (a + b + cap) as i32, | | --------------------------- | | | | | the expected closure - | | this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:22]` + | | this is found to be of type `{closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:22}` LL | | "-" => |a, b| (a - b) as i32, | | ^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure LL | | _ => unimplemented!(), LL | | }; | |_____- `match` arms have incompatible types | - = note: expected closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:22]` - found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:27:16: 27:22]` + = note: expected closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:26:16: 26:22}` + found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:27:16: 27:22}` = note: no two closures, even if identical, have the same type = help: consider boxing your closure and/or using it as a trait object @@ -65,15 +65,15 @@ LL | | "+" => |a, b| (a + b + cap) as i32, | | --------------------------- | | | | | the expected closure - | | this is found to be of type `[closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:22]` + | | this is found to be of type `{closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:22}` LL | | "-" => |a, b| (a - b + cap) as i32, | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure LL | | _ => unimplemented!(), LL | | }; | |_____- `match` arms have incompatible types | - = note: expected closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:22]` - found closure `[closure@$DIR/closure_cap_coerce_many_fail.rs:35:16: 35:22]` + = note: expected closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:34:16: 34:22}` + found closure `{closure@$DIR/closure_cap_coerce_many_fail.rs:35:16: 35:22}` = note: no two closures, even if identical, have the same type = help: consider boxing your closure and/or using it as a trait object diff --git a/tests/ui/closures/issue-112547.rs b/tests/ui/closures/issue-112547.rs new file mode 100644 index 000000000..8ecb2abcc --- /dev/null +++ b/tests/ui/closures/issue-112547.rs @@ -0,0 +1,15 @@ +#![feature(non_lifetime_binders)] + //~^ WARNING the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + +pub fn bar() +where + for<const N: usize = { + (||1usize)() +}> V: IntoIterator +//~^ ERROR cannot find type `V` in this scope [E0412] +{ +} + +fn main() { + bar(); +} diff --git a/tests/ui/closures/issue-112547.stderr b/tests/ui/closures/issue-112547.stderr new file mode 100644 index 000000000..d86b05dc6 --- /dev/null +++ b/tests/ui/closures/issue-112547.stderr @@ -0,0 +1,23 @@ +error[E0412]: cannot find type `V` in this scope + --> $DIR/issue-112547.rs:8:4 + | +LL | }> V: IntoIterator + | ^ not found in this scope + | +help: you might be missing a type parameter + | +LL | pub fn bar<V>() + | +++ + +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-112547.rs:1:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/closures/issue-11873.rs b/tests/ui/closures/issue-11873.rs new file mode 100644 index 000000000..d3bd05caf --- /dev/null +++ b/tests/ui/closures/issue-11873.rs @@ -0,0 +1,7 @@ +fn main() { + let mut v = vec![1]; + let mut f = || v.push(2); + let _w = v; //~ ERROR: cannot move out of `v` + + f(); +} diff --git a/tests/ui/closures/issue-11873.stderr b/tests/ui/closures/issue-11873.stderr new file mode 100644 index 000000000..c814eedd2 --- /dev/null +++ b/tests/ui/closures/issue-11873.stderr @@ -0,0 +1,16 @@ +error[E0505]: cannot move out of `v` because it is borrowed + --> $DIR/issue-11873.rs:4:14 + | +LL | let mut f = || v.push(2); + | -- - borrow occurs due to use in closure + | | + | borrow of `v` occurs here +LL | let _w = v; + | ^ move out of `v` occurs here +LL | +LL | f(); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/tests/ui/closures/issue-25439.rs b/tests/ui/closures/issue-25439.rs new file mode 100644 index 000000000..4f73ff3e3 --- /dev/null +++ b/tests/ui/closures/issue-25439.rs @@ -0,0 +1,9 @@ +struct Helper<'a, F: 'a>(&'a F); + +fn fix<F>(f: F) -> i32 where F: Fn(Helper<F>, i32) -> i32 { + f(Helper(&f), 8) +} + +fn main() { + fix(|_, x| x); //~ ERROR closure/generator type that references itself [E0644] +} diff --git a/tests/ui/closures/issue-25439.stderr b/tests/ui/closures/issue-25439.stderr new file mode 100644 index 000000000..dadae23fd --- /dev/null +++ b/tests/ui/closures/issue-25439.stderr @@ -0,0 +1,19 @@ +error[E0644]: closure/generator type that references itself + --> $DIR/issue-25439.rs:8:9 + | +LL | fix(|_, x| x); + | ^^^^^^ cyclic type of infinite size + | + = note: closures cannot capture themselves or take themselves as argument; + this error may be the result of a recent compiler bug-fix, + see issue #46062 <https://github.com/rust-lang/rust/issues/46062> + for more information +note: required by a bound in `fix` + --> $DIR/issue-25439.rs:3:33 + | +LL | fn fix<F>(f: F) -> i32 where F: Fn(Helper<F>, i32) -> i32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `fix` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0644`. diff --git a/tests/ui/closures/issue-90871.stderr b/tests/ui/closures/issue-90871.stderr index 4a578b4d7..ef1cb213f 100644 --- a/tests/ui/closures/issue-90871.stderr +++ b/tests/ui/closures/issue-90871.stderr @@ -14,7 +14,7 @@ LL | type_ascribe!(2, n([u8; || 1])) | ^^^^ expected `usize`, found closure | = note: expected type `usize` - found closure `[closure@$DIR/issue-90871.rs:4:29: 4:31]` + found closure `{closure@$DIR/issue-90871.rs:4:29: 4:31}` help: use parentheses to call this closure | LL | type_ascribe!(2, n([u8; (|| 1)()])) diff --git a/tests/ui/closures/print/closure-print-generic-1.stderr b/tests/ui/closures/print/closure-print-generic-1.stderr index b21734f02..2697f93b1 100644 --- a/tests/ui/closures/print/closure-print-generic-1.stderr +++ b/tests/ui/closures/print/closure-print-generic-1.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `c` --> $DIR/closure-print-generic-1.rs:17:5 | LL | let c = to_fn_once(move || { - | - move occurs because `c` has type `[closure@$DIR/closure-print-generic-1.rs:12:24: 12:31]`, which does not implement the `Copy` trait + | - move occurs because `c` has type `{closure@$DIR/closure-print-generic-1.rs:12:24: 12:31}`, which does not implement the `Copy` trait ... LL | c(); | --- `c` moved due to this call diff --git a/tests/ui/closures/print/closure-print-generic-2.stderr b/tests/ui/closures/print/closure-print-generic-2.stderr index e53277a93..ced0be945 100644 --- a/tests/ui/closures/print/closure-print-generic-2.stderr +++ b/tests/ui/closures/print/closure-print-generic-2.stderr @@ -9,7 +9,7 @@ LL | let c1: () = c; | expected due to this | = note: expected unit type `()` - found closure `[closure@$DIR/closure-print-generic-2.rs:5:17: 5:19]` + found closure `{closure@$DIR/closure-print-generic-2.rs:5:17: 5:19}` help: use parentheses to call this closure | LL | let c1: () = c(); diff --git a/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr b/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr index 49453b053..6e3659b95 100644 --- a/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr +++ b/tests/ui/closures/print/closure-print-generic-trim-off-verbose-2.stderr @@ -9,7 +9,7 @@ LL | let c1 : () = c; | expected due to this | = note: expected unit type `()` - found closure `[mod1::f<T>::{closure#0} closure_args=(unavailable) args=[T, ?16t, extern "rust-call" fn(()), ?15t]]` + found closure `{mod1::f<T>::{closure#0} closure_args=(unavailable) args=[T, ?16t, extern "rust-call" fn(()), ?15t]}` help: use parentheses to call this closure | LL | let c1 : () = c(); diff --git a/tests/ui/closures/print/closure-print-generic-verbose-1.stderr b/tests/ui/closures/print/closure-print-generic-verbose-1.stderr index 9a1f18fa8..5e8a6b1a7 100644 --- a/tests/ui/closures/print/closure-print-generic-verbose-1.stderr +++ b/tests/ui/closures/print/closure-print-generic-verbose-1.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `c` --> $DIR/closure-print-generic-verbose-1.rs:17:5 | LL | let c = to_fn_once(move|| { - | - move occurs because `c` has type `[f<T>::{closure#0} closure_kind_ty=i32 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=(Foo<&'?9 str>, T)]`, which does not implement the `Copy` trait + | - move occurs because `c` has type `{f<T>::{closure#0} closure_kind_ty=i32 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=(Foo<&'?9 str>, T)}`, which does not implement the `Copy` trait ... LL | c(); | --- `c` moved due to this call diff --git a/tests/ui/closures/print/closure-print-generic-verbose-2.stderr b/tests/ui/closures/print/closure-print-generic-verbose-2.stderr index d2deba3dd..f1fc35e75 100644 --- a/tests/ui/closures/print/closure-print-generic-verbose-2.stderr +++ b/tests/ui/closures/print/closure-print-generic-verbose-2.stderr @@ -9,7 +9,7 @@ LL | let c1 : () = c; | expected due to this | = note: expected unit type `()` - found closure `[f<T>::{closure#0} closure_args=(unavailable) args=[T, ?16t, extern "rust-call" fn(()), ?15t]]` + found closure `{f<T>::{closure#0} closure_args=(unavailable) args=[T, ?16t, extern "rust-call" fn(()), ?15t]}` help: use parentheses to call this closure | LL | let c1 : () = c(); diff --git a/tests/ui/closures/print/closure-print-verbose.stderr b/tests/ui/closures/print/closure-print-verbose.stderr index acc81f5e4..3f9160fe5 100644 --- a/tests/ui/closures/print/closure-print-verbose.stderr +++ b/tests/ui/closures/print/closure-print-verbose.stderr @@ -7,7 +7,7 @@ LL | let foo: fn(u8) -> u8 = |v: u8| { a += v; a }; | expected due to this | = note: expected fn pointer `fn(u8) -> u8` - found closure `[main::{closure#0} closure_args=(unavailable) args=[i8, extern "rust-call" fn((u8,)) -> u8, ?6t]]` + found closure `{main::{closure#0} closure_args=(unavailable) args=[i8, extern "rust-call" fn((u8,)) -> u8, ?6t]}` note: closures can only be coerced to `fn` types if they do not capture any variables --> $DIR/closure-print-verbose.rs:10:39 | |