Skip to content

Commit 26355bd

Browse files
committed
moved renamed docs formatted | cannot-mutate-captured-non-mut-var.rs
1 parent 485026e commit 26355bd

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

tests/ui/cannot-mutate-captured-non-mut-var.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! Tests errors for mutating captured immutable variables in closures.
2+
3+
#![feature(unboxed_closures, tuple_trait)]
4+
5+
use std::io::Read;
6+
7+
fn to_fn_once<A: std::marker::Tuple, F: FnOnce<A>>(f: F) -> F {
8+
f
9+
}
10+
11+
fn main() {
12+
let x = 1;
13+
to_fn_once(move || {
14+
x = 2;
15+
//~^ ERROR: cannot assign to `x`, as it is not declared as mutable
16+
});
17+
18+
let s = std::io::stdin();
19+
to_fn_once(move || {
20+
s.read_to_end(&mut Vec::new());
21+
//~^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable
22+
});
23+
}

0 commit comments

Comments
 (0)