2018-07-03 14:12:09 -05:00
|
|
|
// extra unused mut lint tests for #51918
|
|
|
|
|
2020-01-22 18:00:00 -06:00
|
|
|
// check-pass
|
2018-07-03 14:12:09 -05:00
|
|
|
|
2022-04-01 12:13:25 -05:00
|
|
|
#![feature(generators)]
|
2018-07-03 14:12:09 -05:00
|
|
|
#![deny(unused_mut)]
|
|
|
|
|
|
|
|
fn ref_argument(ref _y: i32) {}
|
|
|
|
|
|
|
|
// #51801
|
|
|
|
fn mutable_upvar() {
|
|
|
|
let mut x = 0;
|
|
|
|
move || {
|
|
|
|
x = 1;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// #50897
|
|
|
|
fn generator_mutable_upvar() {
|
|
|
|
let mut x = 0;
|
|
|
|
move || {
|
|
|
|
x = 1;
|
|
|
|
yield;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// #51830
|
|
|
|
fn ref_closure_argument() {
|
|
|
|
let _ = Some(0).as_ref().map(|ref _a| true);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Expr {
|
|
|
|
attrs: Vec<u32>,
|
|
|
|
}
|
|
|
|
|
|
|
|
// #51904
|
|
|
|
fn parse_dot_or_call_expr_with(mut attrs: Vec<u32>) {
|
|
|
|
let x = Expr { attrs: vec![] };
|
|
|
|
Some(Some(x)).map(|expr|
|
|
|
|
expr.map(|mut expr| {
|
|
|
|
attrs.push(666);
|
|
|
|
expr.attrs = attrs;
|
|
|
|
expr
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-07-28 15:18:34 -05:00
|
|
|
// Found when trying to bootstrap rustc
|
|
|
|
fn if_guard(x: Result<i32, i32>) {
|
|
|
|
match x {
|
|
|
|
Ok(mut r) | Err(mut r) if true => r = 1,
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-04 15:25:08 -05:00
|
|
|
// #59620
|
|
|
|
fn nested_closures() {
|
|
|
|
let mut i = 0;
|
|
|
|
[].iter().for_each(|_: &i32| {
|
|
|
|
[].iter().for_each(move |_: &i32| {
|
|
|
|
i += 1;
|
|
|
|
});
|
|
|
|
});
|
2018-07-03 14:12:09 -05:00
|
|
|
}
|
2019-04-04 15:25:08 -05:00
|
|
|
|
|
|
|
fn main() {}
|