]> git.lizzy.rs Git - rust.git/blob - tests/ui/cannot-mutate-captured-non-mut-var.rs
Bless updated output from print-type-sizes tests.
[rust.git] / tests / ui / cannot-mutate-captured-non-mut-var.rs
1 #![feature(unboxed_closures, tuple_trait)]
2
3 use std::io::Read;
4
5 fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f }
6
7 fn main() {
8     let x = 1;
9     to_fn_once(move|| { x = 2; });
10     //~^ ERROR: cannot assign to `x`, as it is not declared as mutable
11
12     let s = std::io::stdin();
13     to_fn_once(move|| { s.read_to_end(&mut Vec::new()); });
14     //~^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable
15 }