diff options
Diffstat (limited to 'src/test/ui/closures')
27 files changed, 101 insertions, 58 deletions
diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/arrays.rs b/src/test/ui/closures/2229_closure_analysis/diagnostics/arrays.rs index 93131b2ac..f97e60daf 100644 --- a/src/test/ui/closures/2229_closure_analysis/diagnostics/arrays.rs +++ b/src/test/ui/closures/2229_closure_analysis/diagnostics/arrays.rs @@ -68,7 +68,7 @@ fn arrays_5() { arr[1] += 10; }; - // c will capture `arr` completely, therefore we cannot borrow other indecies + // c will capture `arr` completely, therefore we cannot borrow other indices // into the array. println!("{:#?}", &arr[3..2]); //~^ ERROR: cannot borrow `arr` as immutable because it is also borrowed as mutable diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/closure-origin-array-diagnostics.stderr b/src/test/ui/closures/2229_closure_analysis/diagnostics/closure-origin-array-diagnostics.stderr index bcde35983..309c63e52 100644 --- a/src/test/ui/closures/2229_closure_analysis/diagnostics/closure-origin-array-diagnostics.stderr +++ b/src/test/ui/closures/2229_closure_analysis/diagnostics/closure-origin-array-diagnostics.stderr @@ -7,7 +7,15 @@ LL | let [_, _s] = s; | - closure is `FnOnce` because it moves the variable `s` out of its environment LL | }; LL | expect_fn(c); - | --------- the requirement to implement `Fn` derives from here + | --------- - the requirement to implement `Fn` derives from here + | | + | required by a bound introduced by this call + | +note: required by a bound in `expect_fn` + --> $DIR/closure-origin-array-diagnostics.rs:5:17 + | +LL | fn expect_fn<F: Fn()>(_f: F) {} + | ^^^^ required by this bound in `expect_fn` error: aborting due to previous error diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/closure-origin-tuple-diagnostics.stderr b/src/test/ui/closures/2229_closure_analysis/diagnostics/closure-origin-tuple-diagnostics.stderr index df33c4f1f..3e77635f9 100644 --- a/src/test/ui/closures/2229_closure_analysis/diagnostics/closure-origin-tuple-diagnostics.stderr +++ b/src/test/ui/closures/2229_closure_analysis/diagnostics/closure-origin-tuple-diagnostics.stderr @@ -7,7 +7,15 @@ LL | let s = s.1; | --- closure is `FnOnce` because it moves the variable `s.1` out of its environment LL | }; LL | expect_fn(c); - | --------- the requirement to implement `Fn` derives from here + | --------- - the requirement to implement `Fn` derives from here + | | + | required by a bound introduced by this call + | +note: required by a bound in `expect_fn` + --> $DIR/closure-origin-tuple-diagnostics.rs:5:17 + | +LL | fn expect_fn<F: Fn()>(_f: F) {} + | ^^^^ required by this bound in `expect_fn` error: aborting due to previous error diff --git a/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs index 318673ef8..972c24c23 100644 --- a/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs +++ b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs @@ -24,7 +24,7 @@ fn main() { let _a = || { match l1 { L1::A => (), L1::B => () } }; // (except if the match is already non-exhaustive) let _b = || { match l1 { L1::A => () } }; - //~^ ERROR: non-exhaustive patterns: `B` not covered [E0004] + //~^ ERROR: non-exhaustive patterns: `L1::B` not covered [E0004] // l2 should not be captured as it is a non-exhaustive SingleVariant // defined in this crate diff --git a/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr index e0678bc71..3a5fad154 100644 --- a/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr +++ b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr @@ -1,8 +1,8 @@ -error[E0004]: non-exhaustive patterns: `B` not covered +error[E0004]: non-exhaustive patterns: `L1::B` not covered --> $DIR/non-exhaustive-match.rs:26:25 | LL | let _b = || { match l1 { L1::A => () } }; - | ^^ pattern `B` not covered + | ^^ pattern `L1::B` not covered | note: `L1` defined here --> $DIR/non-exhaustive-match.rs:12:14 @@ -12,8 +12,8 @@ LL | enum L1 { A, B } = note: the matched value is of type `L1` 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 _b = || { match l1 { L1::A => (), B => todo!() } }; - | ++++++++++++++ +LL | let _b = || { match l1 { L1::A => (), L1::B => todo!() } }; + | ++++++++++++++++++ error[E0004]: non-exhaustive patterns: type `E1` is non-empty --> $DIR/non-exhaustive-match.rs:37:25 diff --git a/src/test/ui/closures/2229_closure_analysis/repr_packed.rs b/src/test/ui/closures/2229_closure_analysis/repr_packed.rs index 3ed780f51..f23670f63 100644 --- a/src/test/ui/closures/2229_closure_analysis/repr_packed.rs +++ b/src/test/ui/closures/2229_closure_analysis/repr_packed.rs @@ -31,7 +31,7 @@ fn test_alignment_not_affected() { c(); } -// `String`, `u16` are not aligned at a one byte boundry and are thus affected by repr(packed). +// `String`, `u16` are not aligned at a one byte boundary and are thus affected by repr(packed). // // Here we test that the closure doesn't capture a reference point to `foo.x` but // rather capture `foo` entirely. diff --git a/src/test/ui/closures/2229_closure_analysis/run_pass/by_value.rs b/src/test/ui/closures/2229_closure_analysis/run_pass/by_value.rs index 2c828aed5..f8752fe1c 100644 --- a/src/test/ui/closures/2229_closure_analysis/run_pass/by_value.rs +++ b/src/test/ui/closures/2229_closure_analysis/run_pass/by_value.rs @@ -1,8 +1,8 @@ // edition:2021 // run-pass -// Test that ByValue captures compile sucessefully especially when the captures are -// derefenced within the closure. +// Test that ByValue captures compile successfully especially when the captures are +// dereferenced within the closure. #[derive(Debug, Default)] struct SomeLargeType; diff --git a/src/test/ui/closures/2229_closure_analysis/run_pass/destructure-pattern-closure-within-closure.stderr b/src/test/ui/closures/2229_closure_analysis/run_pass/destructure-pattern-closure-within-closure.stderr index 40274c883..cf8bd7a0a 100644 --- a/src/test/ui/closures/2229_closure_analysis/run_pass/destructure-pattern-closure-within-closure.stderr +++ b/src/test/ui/closures/2229_closure_analysis/run_pass/destructure-pattern-closure-within-closure.stderr @@ -1,8 +1,8 @@ -warning: unused variable: `t2` - --> $DIR/destructure-pattern-closure-within-closure.rs:13:21 +warning: unused variable: `g2` + --> $DIR/destructure-pattern-closure-within-closure.rs:10:17 | -LL | let (_, t2) = t; - | ^^ help: if this is intentional, prefix it with an underscore: `_t2` +LL | let (_, g2) = g; + | ^^ help: if this is intentional, prefix it with an underscore: `_g2` | note: the lint level is defined here --> $DIR/destructure-pattern-closure-within-closure.rs:3:9 @@ -11,11 +11,11 @@ LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` -warning: unused variable: `g2` - --> $DIR/destructure-pattern-closure-within-closure.rs:10:17 +warning: unused variable: `t2` + --> $DIR/destructure-pattern-closure-within-closure.rs:13:21 | -LL | let (_, g2) = g; - | ^^ help: if this is intentional, prefix it with an underscore: `_g2` +LL | let (_, t2) = t; + | ^^ help: if this is intentional, prefix it with an underscore: `_t2` warning: 2 warnings emitted diff --git a/src/test/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs b/src/test/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs index 88a9816a0..03400e0ee 100644 --- a/src/test/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs +++ b/src/test/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs @@ -1,7 +1,7 @@ // edition:2021 // run-pass -// Tests that if a closure uses indivual fields of the same object +// Tests that if a closure uses individual fields of the same object // then that case is handled properly. #![allow(unused)] diff --git a/src/test/ui/closures/2229_closure_analysis/run_pass/multilevel-path-1.rs b/src/test/ui/closures/2229_closure_analysis/run_pass/multilevel-path-1.rs index b8e464031..624e0ff22 100644 --- a/src/test/ui/closures/2229_closure_analysis/run_pass/multilevel-path-1.rs +++ b/src/test/ui/closures/2229_closure_analysis/run_pass/multilevel-path-1.rs @@ -1,10 +1,10 @@ // edition:2021 // run-pass -// Test that closures can catpure paths that are more precise than just one level +// Test that closures can capture paths that are more precise than just one level // from the root variable. // -// If the closures can handle such precison we should be able to mutate one path in the closure +// If the closures can handle such precision we should be able to mutate one path in the closure // while being able to mutate another path outside the closure, where the two paths are disjoint // after applying two projections on the root variable. diff --git a/src/test/ui/closures/2229_closure_analysis/run_pass/multilevel-path-2.rs b/src/test/ui/closures/2229_closure_analysis/run_pass/multilevel-path-2.rs index 11a324d8a..bd8addd37 100644 --- a/src/test/ui/closures/2229_closure_analysis/run_pass/multilevel-path-2.rs +++ b/src/test/ui/closures/2229_closure_analysis/run_pass/multilevel-path-2.rs @@ -3,7 +3,7 @@ #![allow(unused)] -// If the closures can handle such precison we should be able to read one path in the closure +// If the closures can handle such precision we should be able to read one path in the closure // while being able mutate another path outside the closure, where the two paths are disjoint // after applying two projections on the root variable. diff --git a/src/test/ui/closures/2229_closure_analysis/run_pass/mut_ref_struct_mem.rs b/src/test/ui/closures/2229_closure_analysis/run_pass/mut_ref_struct_mem.rs index bb784774b..a85335438 100644 --- a/src/test/ui/closures/2229_closure_analysis/run_pass/mut_ref_struct_mem.rs +++ b/src/test/ui/closures/2229_closure_analysis/run_pass/mut_ref_struct_mem.rs @@ -5,7 +5,7 @@ // that is captured by the closure // More specifically we test that the if the mutable reference isn't root variable of a capture -// but rather accessed while acessing the precise capture. +// but rather accessed while accessing the precise capture. fn mut_tuple() { let mut t = (10, 10); diff --git a/src/test/ui/closures/binder/disallow-const.rs b/src/test/ui/closures/binder/disallow-const.rs new file mode 100644 index 000000000..72ad6185d --- /dev/null +++ b/src/test/ui/closures/binder/disallow-const.rs @@ -0,0 +1,6 @@ +#![feature(closure_lifetime_binder)] + +fn main() { + for<const N: i32> || -> () {}; + //~^ ERROR only lifetime parameters can be used in this context +} diff --git a/src/test/ui/closures/binder/disallow-const.stderr b/src/test/ui/closures/binder/disallow-const.stderr new file mode 100644 index 000000000..3c3b43d8c --- /dev/null +++ b/src/test/ui/closures/binder/disallow-const.stderr @@ -0,0 +1,8 @@ +error: only lifetime parameters can be used in this context + --> $DIR/disallow-const.rs:4:15 + | +LL | for<const N: i32> || -> () {}; + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/closures/binder/disallow-ty.rs b/src/test/ui/closures/binder/disallow-ty.rs new file mode 100644 index 000000000..bbe3d8488 --- /dev/null +++ b/src/test/ui/closures/binder/disallow-ty.rs @@ -0,0 +1,6 @@ +#![feature(closure_lifetime_binder)] + +fn main() { + for<T> || -> () {}; + //~^ ERROR only lifetime parameters can be used in this context +} diff --git a/src/test/ui/closures/binder/disallow-ty.stderr b/src/test/ui/closures/binder/disallow-ty.stderr new file mode 100644 index 000000000..51b6773ed --- /dev/null +++ b/src/test/ui/closures/binder/disallow-ty.stderr @@ -0,0 +1,8 @@ +error: only lifetime parameters can be used in this context + --> $DIR/disallow-ty.rs:4:9 + | +LL | for<T> || -> () {}; + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/closures/closure-move-sync.stderr b/src/test/ui/closures/closure-move-sync.stderr index 1086cfa29..a2ca06b4e 100644 --- a/src/test/ui/closures/closure-move-sync.stderr +++ b/src/test/ui/closures/closure-move-sync.stderr @@ -1,11 +1,17 @@ error[E0277]: `std::sync::mpsc::Receiver<()>` cannot be shared between threads safely - --> $DIR/closure-move-sync.rs:6:13 + --> $DIR/closure-move-sync.rs:6:27 | -LL | let t = thread::spawn(|| { - | ^^^^^^^^^^^^^ `std::sync::mpsc::Receiver<()>` cannot be shared between threads safely +LL | let t = thread::spawn(|| { + | _____________-------------_^ + | | | + | | required by a bound introduced by this call +LL | | recv.recv().unwrap(); +LL | | +LL | | }); + | |_____^ `std::sync::mpsc::Receiver<()>` cannot be shared between threads safely | = help: the trait `Sync` is not implemented for `std::sync::mpsc::Receiver<()>` - = note: required because of the requirements on the impl of `Send` for `&std::sync::mpsc::Receiver<()>` + = note: required for `&std::sync::mpsc::Receiver<()>` to implement `Send` note: required because it's used within this closure --> $DIR/closure-move-sync.rs:6:27 | @@ -18,13 +24,15 @@ LL | F: Send + 'static, | ^^^^ required by this bound in `spawn` error[E0277]: `Sender<()>` cannot be shared between threads safely - --> $DIR/closure-move-sync.rs:18:5 + --> $DIR/closure-move-sync.rs:18:19 | LL | thread::spawn(|| tx.send(()).unwrap()); - | ^^^^^^^^^^^^^ `Sender<()>` cannot be shared between threads safely + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^ `Sender<()>` cannot be shared between threads safely + | | + | required by a bound introduced by this call | = help: the trait `Sync` is not implemented for `Sender<()>` - = note: required because of the requirements on the impl of `Send` for `&Sender<()>` + = note: required for `&Sender<()>` to implement `Send` note: required because it's used within this closure --> $DIR/closure-move-sync.rs:18:19 | diff --git a/src/test/ui/closures/closure-wrong-kind.stderr b/src/test/ui/closures/closure-wrong-kind.stderr index 35caf71a5..9ea55d764 100644 --- a/src/test/ui/closures/closure-wrong-kind.stderr +++ b/src/test/ui/closures/closure-wrong-kind.stderr @@ -6,7 +6,15 @@ LL | let closure = |_| foo(x); | | | this closure implements `FnOnce`, not `Fn` LL | bar(closure); - | --- the requirement to implement `Fn` derives from here + | --- ------- the requirement to implement `Fn` derives from here + | | + | required by a bound introduced by this call + | +note: required by a bound in `bar` + --> $DIR/closure-wrong-kind.rs:6:11 + | +LL | fn bar<T: Fn(u32)>(_: T) {} + | ^^^^^^^ required by this bound in `bar` error: aborting due to previous error diff --git a/src/test/ui/closures/coerce-unsafe-to-closure.stderr b/src/test/ui/closures/coerce-unsafe-to-closure.stderr index bd095c2d8..6ce63e829 100644 --- a/src/test/ui/closures/coerce-unsafe-to-closure.stderr +++ b/src/test/ui/closures/coerce-unsafe-to-closure.stderr @@ -6,7 +6,7 @@ LL | let x: Option<&[u8]> = Some("foo").map(std::mem::transmute); | | | required by a bound introduced by this call | - = help: the trait `FnOnce<(&str,)>` is not implemented for `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` + = help: the trait `FnOnce<(&str,)>` is not implemented for fn item `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `Option::<T>::map` --> $SRC_DIR/core/src/option.rs:LL:COL diff --git a/src/test/ui/closures/issue-10398.rs b/src/test/ui/closures/issue-10398.rs index 0405b2d01..f76d09cd0 100644 --- a/src/test/ui/closures/issue-10398.rs +++ b/src/test/ui/closures/issue-10398.rs @@ -1,7 +1,5 @@ -#![feature(box_syntax)] - fn main() { - let x: Box<_> = box 1; + let x: Box<_> = Box::new(1); let f = move|| { let _a = x; drop(x); diff --git a/src/test/ui/closures/issue-10398.stderr b/src/test/ui/closures/issue-10398.stderr index 8d9faf324..423b79daf 100644 --- a/src/test/ui/closures/issue-10398.stderr +++ b/src/test/ui/closures/issue-10398.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `x` - --> $DIR/issue-10398.rs:7:14 + --> $DIR/issue-10398.rs:5:14 | LL | let _a = x; | - value moved here diff --git a/src/test/ui/closures/issue-52437.rs b/src/test/ui/closures/issue-52437.rs index f79a0bd35..6ac5380a5 100644 --- a/src/test/ui/closures/issue-52437.rs +++ b/src/test/ui/closures/issue-52437.rs @@ -2,5 +2,4 @@ fn main() { [(); &(&'static: loop { |x| {}; }) as *const _ as usize] //~^ ERROR: invalid label name `'static` //~| ERROR: type annotations needed - //~| ERROR mismatched types } diff --git a/src/test/ui/closures/issue-52437.stderr b/src/test/ui/closures/issue-52437.stderr index 38d9d08ce..4c24a54bb 100644 --- a/src/test/ui/closures/issue-52437.stderr +++ b/src/test/ui/closures/issue-52437.stderr @@ -15,15 +15,6 @@ help: consider giving this closure parameter an explicit type LL | [(); &(&'static: loop { |x: _| {}; }) as *const _ as usize] | +++ -error[E0308]: mismatched types - --> $DIR/issue-52437.rs:2:5 - | -LL | fn main() { - | - expected `()` because of default return type -LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[(); _]` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0282, E0308. -For more information about an error, try `rustc --explain E0282`. +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/closures/issue-6801.rs b/src/test/ui/closures/issue-6801.rs index 694d86feb..cecb08f00 100644 --- a/src/test/ui/closures/issue-6801.rs +++ b/src/test/ui/closures/issue-6801.rs @@ -2,7 +2,7 @@ // transferring ownership of the box before invoking the stack // closure results in a crash. -#![feature(box_syntax)] + fn twice(x: Box<usize>) -> usize { *x * 2 @@ -13,7 +13,7 @@ fn invoke<F>(f: F) where F: FnOnce() -> usize { } fn main() { - let x : Box<usize> = box 9; + let x : Box<usize> = Box::new(9); let sq = || { *x * *x }; twice(x); //~ ERROR: cannot move out of diff --git a/src/test/ui/closures/issue-84128.rs b/src/test/ui/closures/issue-84128.rs index f81d7cfaa..30733871b 100644 --- a/src/test/ui/closures/issue-84128.rs +++ b/src/test/ui/closures/issue-84128.rs @@ -1,5 +1,5 @@ // test for issue 84128 -// missing suggestion for similar ADT type with diffetent generic paramenter +// missing suggestion for similar ADT type with diffetent generic parameter // on closure ReturnNoExpression struct Foo<T>(T); diff --git a/src/test/ui/closures/issue-84128.stderr b/src/test/ui/closures/issue-84128.stderr index 09c44d261..59607afec 100644 --- a/src/test/ui/closures/issue-84128.stderr +++ b/src/test/ui/closures/issue-84128.stderr @@ -6,11 +6,6 @@ LL | Foo(()) | | | arguments to this struct are incorrect | -note: return type inferred to be `{integer}` here - --> $DIR/issue-84128.rs:10:20 - | -LL | return Foo(0); - | ^^^^^^ note: tuple struct defined here --> $DIR/issue-84128.rs:5:8 | diff --git a/src/test/ui/closures/print/closure-print-generic-verbose-1.stderr b/src/test/ui/closures/print/closure-print-generic-verbose-1.stderr index fdaf353fe..3ab7c66d1 100644 --- a/src/test/ui/closures/print/closure-print-generic-verbose-1.stderr +++ b/src/test/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<&'_#10r 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<&'_#9r str>, T)]`, which does not implement the `Copy` trait ... LL | c(); | --- `c` moved due to this call |