summaryrefslogtreecommitdiffstats
path: root/src/test/ui/nll/closure-captures.stderr
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/nll/closure-captures.stderr
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/nll/closure-captures.stderr')
-rw-r--r--src/test/ui/nll/closure-captures.stderr148
1 files changed, 148 insertions, 0 deletions
diff --git a/src/test/ui/nll/closure-captures.stderr b/src/test/ui/nll/closure-captures.stderr
new file mode 100644
index 000000000..5233f0b24
--- /dev/null
+++ b/src/test/ui/nll/closure-captures.stderr
@@ -0,0 +1,148 @@
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/closure-captures.rs:7:5
+ |
+LL | fn one_closure(x: i32) {
+ | - help: consider changing this to be mutable: `mut x`
+LL | ||
+LL | x = 1;
+ | ^^^^^ cannot assign
+
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/closure-captures.rs:9:5
+ |
+LL | fn one_closure(x: i32) {
+ | - help: consider changing this to be mutable: `mut x`
+...
+LL | x = 1;
+ | ^^^^^ cannot assign
+
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/closure-captures.rs:15:9
+ |
+LL | fn two_closures(x: i32) {
+ | - help: consider changing this to be mutable: `mut x`
+...
+LL | x = 1;
+ | ^^^^^ cannot assign
+
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/closure-captures.rs:19:9
+ |
+LL | fn two_closures(x: i32) {
+ | - help: consider changing this to be mutable: `mut x`
+...
+LL | x = 1;
+ | ^^^^^ cannot assign
+
+error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
+ --> $DIR/closure-captures.rs:27:9
+ |
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
+...
+LL | fn_ref(|| {
+ | ------ -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | x = 1;}
+ | - mutable borrow occurs due to use of `x` in closure
+
+error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
+ --> $DIR/closure-captures.rs:31:9
+ |
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
+...
+LL | fn_ref(move || {
+ | ------ ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | x = 1;});
+ | - mutable borrow occurs due to use of `x` in closure
+
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/closure-captures.rs:39:10
+ |
+LL | fn two_closures_ref(x: i32) {
+ | - help: consider changing this to be mutable: `mut x`
+...
+LL | x = 1;}
+ | ^^^^^ cannot assign
+
+error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
+ --> $DIR/closure-captures.rs:38:9
+ |
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
+...
+LL | fn_ref(|| {
+ | ------ -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | x = 1;}
+ | - mutable borrow occurs due to use of `x` in closure
+
+error[E0594]: cannot assign to `x`, as it is not declared as mutable
+ --> $DIR/closure-captures.rs:43:5
+ |
+LL | fn two_closures_ref(x: i32) {
+ | - help: consider changing this to be mutable: `mut x`
+...
+LL | x = 1;});
+ | ^^^^^ cannot assign
+
+error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
+ --> $DIR/closure-captures.rs:42:9
+ |
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
+...
+LL | fn_ref(move || {
+ | ------ ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | x = 1;});
+ | - mutable borrow occurs due to use of `x` in closure
+
+error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
+ --> $DIR/closure-captures.rs:48:9
+ |
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
+...
+LL | fn_ref(|| {
+ | ------ -- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | *x = 1;});
+ | -- mutable borrow occurs due to use of `x` in closure
+
+error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
+ --> $DIR/closure-captures.rs:51:9
+ |
+LL | fn fn_ref<F: Fn()>(f: F) -> F { f }
+ | - change this to accept `FnMut` instead of `Fn`
+...
+LL | fn_ref(move || {
+ | ------ ------- in this closure
+ | |
+ | expects `Fn` instead of `FnMut`
+LL | ||
+ | ^^ cannot borrow as mutable
+LL | *x = 1;});
+ | -- mutable borrow occurs due to use of `x` in closure
+
+error: aborting due to 12 previous errors
+
+Some errors have detailed explanations: E0594, E0596.
+For more information about an error, try `rustc --explain E0594`.