diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-07-01 02:09:12 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-07-05 00:50:51 +0500 |
| commit | 0f7a86bb2ac5b2ca57e5524127f9cbeb88f89a74 (patch) | |
| tree | 13373ec30e55f9b3ac4bd8fa61d6684cca8f006a /tests/ui/closures | |
| parent | 7f2e37fc5cdca01d4e140921f59fad398862606d (diff) | |
| download | rust-0f7a86bb2ac5b2ca57e5524127f9cbeb88f89a74.tar.gz rust-0f7a86bb2ac5b2ca57e5524127f9cbeb88f89a74.zip | |
cleaned up some tests
Diffstat (limited to 'tests/ui/closures')
| -rw-r--r-- | tests/ui/closures/fnonce-call-twice-error.rs | 7 | ||||
| -rw-r--r-- | tests/ui/closures/fnonce-call-twice-error.stderr | 12 |
2 files changed, 9 insertions, 10 deletions
diff --git a/tests/ui/closures/fnonce-call-twice-error.rs b/tests/ui/closures/fnonce-call-twice-error.rs index 3fd8c5cadca..1662b7bddaa 100644 --- a/tests/ui/closures/fnonce-call-twice-error.rs +++ b/tests/ui/closures/fnonce-call-twice-error.rs @@ -1,16 +1,15 @@ -// Testing guarantees provided by once functions. -// This program would segfault if it were legal. +//! Test that `FnOnce` closures cannot be called twice. use std::sync::Arc; -fn foo<F:FnOnce()>(blk: F) { +fn foo<F: FnOnce()>(blk: F) { blk(); blk(); //~ ERROR use of moved value } fn main() { let x = Arc::new(true); - foo(move|| { + foo(move || { assert!(*x); drop(x); }); diff --git a/tests/ui/closures/fnonce-call-twice-error.stderr b/tests/ui/closures/fnonce-call-twice-error.stderr index 42697374115..51d8a33dcd7 100644 --- a/tests/ui/closures/fnonce-call-twice-error.stderr +++ b/tests/ui/closures/fnonce-call-twice-error.stderr @@ -1,18 +1,18 @@ error[E0382]: use of moved value: `blk` - --> $DIR/once-cant-call-twice-on-heap.rs:8:5 + --> $DIR/fnonce-call-twice-error.rs:7:5 | -LL | fn foo<F:FnOnce()>(blk: F) { - | --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait +LL | fn foo<F: FnOnce()>(blk: F) { + | --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait LL | blk(); | ----- `blk` moved due to this call LL | blk(); | ^^^ value used here after move | note: `FnOnce` closures can only be called once - --> $DIR/once-cant-call-twice-on-heap.rs:6:10 + --> $DIR/fnonce-call-twice-error.rs:5:11 | -LL | fn foo<F:FnOnce()>(blk: F) { - | ^^^^^^^^ `F` is made to be an `FnOnce` closure here +LL | fn foo<F: FnOnce()>(blk: F) { + | ^^^^^^^^ `F` is made to be an `FnOnce` closure here LL | blk(); | ----- this value implements `FnOnce`, which causes it to be moved when called |
