2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2015-03-22 20:13:15 +00:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2014-10-26 04:27:19 +00:00
|
|
|
#![deny(unused_mut)]
|
2020-07-28 00:00:00 +00:00
|
|
|
#![allow(unused_must_use)]
|
2014-10-26 04:27:19 +00:00
|
|
|
|
|
|
|
// Test that mutating a mutable upvar in a capture-by-value unboxed
|
|
|
|
// closure does not ice (issue #18238) and marks the upvar as used
|
|
|
|
// mutably so we do not get a spurious warning about it not needing to
|
2014-11-09 05:51:02 +00:00
|
|
|
// be declared mutable (issue #18336 and #18769)
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn set(x: &mut usize) { *x = 42; }
|
2014-10-26 04:27:19 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
{
|
2015-02-18 10:42:01 +00:00
|
|
|
let mut x = 0_usize;
|
2020-05-22 00:00:00 +00:00
|
|
|
move || x += 1; //~ WARN unused variable: `x`
|
2014-10-26 04:27:19 +00:00
|
|
|
}
|
|
|
|
{
|
2015-02-18 10:42:01 +00:00
|
|
|
let mut x = 0_usize;
|
2020-05-22 00:00:00 +00:00
|
|
|
move || x += 1; //~ WARN unused variable: `x`
|
2014-10-26 04:27:19 +00:00
|
|
|
}
|
2014-11-09 05:51:02 +00:00
|
|
|
{
|
2015-02-18 10:42:01 +00:00
|
|
|
let mut x = 0_usize;
|
2015-02-01 17:44:15 +00:00
|
|
|
move || set(&mut x);
|
2014-11-09 05:51:02 +00:00
|
|
|
}
|
|
|
|
{
|
2015-02-18 10:42:01 +00:00
|
|
|
let mut x = 0_usize;
|
2015-02-01 17:44:15 +00:00
|
|
|
move || set(&mut x);
|
2014-11-09 05:51:02 +00:00
|
|
|
}
|
2014-10-26 04:27:19 +00:00
|
|
|
}
|