]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closures-move-mutable.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / unboxed-closures / unboxed-closures-move-mutable.rs
1 // run-pass
2 // pretty-expanded FIXME #23616
3
4 #![deny(unused_mut)]
5 #![allow(unused_must_use)]
6
7 // Test that mutating a mutable upvar in a capture-by-value unboxed
8 // closure does not ice (issue #18238) and marks the upvar as used
9 // mutably so we do not get a spurious warning about it not needing to
10 // be declared mutable (issue #18336 and #18769)
11
12 fn set(x: &mut usize) { *x = 42; }
13
14 fn main() {
15     {
16         let mut x = 0_usize;
17         move || x += 1; //~ WARN unused variable: `x`
18     }
19     {
20         let mut x = 0_usize;
21         move || x += 1; //~ WARN unused variable: `x`
22     }
23     {
24         let mut x = 0_usize;
25         move || set(&mut x);
26     }
27     {
28         let mut x = 0_usize;
29         move || set(&mut x);
30     }
31 }