2019-11-03 18:00:00 -06:00
|
|
|
// check-pass
|
2018-01-31 22:56:01 -06:00
|
|
|
|
2018-04-29 18:51:02 -05:00
|
|
|
#![feature(box_syntax)]
|
|
|
|
#![feature(box_patterns)]
|
2018-01-31 22:56:01 -06:00
|
|
|
#![warn(unused)] // UI tests pass `-A unused` (#43896)
|
|
|
|
|
|
|
|
struct SoulHistory {
|
|
|
|
corridors_of_light: usize,
|
|
|
|
hours_are_suns: bool,
|
|
|
|
endless_and_singing: bool
|
|
|
|
}
|
|
|
|
|
2018-05-18 02:07:31 -05:00
|
|
|
struct LovelyAmbition {
|
|
|
|
lips: usize,
|
|
|
|
fire: usize
|
|
|
|
}
|
|
|
|
|
2018-04-29 19:27:37 -05:00
|
|
|
#[derive(Clone, Copy)]
|
2018-04-29 18:40:11 -05:00
|
|
|
enum Large {
|
|
|
|
Suit { case: () }
|
|
|
|
}
|
|
|
|
|
2018-04-29 19:27:37 -05:00
|
|
|
struct Tuple(Large, ());
|
|
|
|
|
2018-01-31 22:56:01 -06:00
|
|
|
fn main() {
|
2019-11-05 18:00:00 -06:00
|
|
|
let i_think_continually = 2; //~ WARNING unused variable: `i_think_continually`
|
2018-01-31 22:56:01 -06:00
|
|
|
let who_from_the_womb_remembered = SoulHistory {
|
|
|
|
corridors_of_light: 5,
|
|
|
|
hours_are_suns: true,
|
|
|
|
endless_and_singing: true
|
|
|
|
};
|
|
|
|
|
2018-05-11 09:24:04 -05:00
|
|
|
let mut mut_unused_var = 1;
|
2019-11-05 18:00:00 -06:00
|
|
|
//~^ WARNING unused variable: `mut_unused_var`
|
|
|
|
//~| WARNING variable does not need to be mutable
|
2018-05-11 09:24:04 -05:00
|
|
|
|
|
|
|
let (mut var, unused_var) = (1, 2);
|
2019-11-05 18:00:00 -06:00
|
|
|
//~^ WARNING unused variable: `var`
|
|
|
|
//~| WARNING unused variable: `unused_var`
|
|
|
|
//~| WARNING variable does not need to be mutable
|
2019-09-16 13:49:48 -05:00
|
|
|
// NOTE: `var` comes after `unused_var` lexicographically yet the warning
|
|
|
|
// for `var` will be emitted before the one for `unused_var`. We use an
|
|
|
|
// `IndexMap` to ensure this is the case instead of a `BTreeMap`.
|
2018-05-11 09:24:04 -05:00
|
|
|
|
2019-11-05 18:00:00 -06:00
|
|
|
if let SoulHistory { corridors_of_light, //~ WARNING unused variable: `corridors_of_light`
|
|
|
|
mut hours_are_suns, //~ WARNING `hours_are_suns` is assigned to, but
|
2018-01-31 22:56:01 -06:00
|
|
|
endless_and_singing: true } = who_from_the_womb_remembered {
|
2019-11-05 18:00:00 -06:00
|
|
|
hours_are_suns = false; //~ WARNING unused_assignments
|
2018-01-31 22:56:01 -06:00
|
|
|
}
|
2018-04-29 18:40:11 -05:00
|
|
|
|
2018-05-18 02:07:31 -05:00
|
|
|
let the_spirit = LovelyAmbition { lips: 1, fire: 2 };
|
2019-11-05 18:00:00 -06:00
|
|
|
let LovelyAmbition { lips, fire } = the_spirit; //~ WARNING unused variable: `fire`
|
2018-05-18 02:07:31 -05:00
|
|
|
println!("{}", lips);
|
|
|
|
|
2018-04-29 18:51:02 -05:00
|
|
|
let bag = Large::Suit {
|
2018-04-29 18:40:11 -05:00
|
|
|
case: ()
|
|
|
|
};
|
|
|
|
|
2018-04-29 19:27:37 -05:00
|
|
|
// Plain struct
|
|
|
|
match bag {
|
2019-11-05 18:00:00 -06:00
|
|
|
Large::Suit { case } => {} //~ WARNING unused variable: `case`
|
2018-04-29 19:27:37 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Referenced struct
|
2018-04-29 18:51:02 -05:00
|
|
|
match &bag {
|
2019-11-05 18:00:00 -06:00
|
|
|
&Large::Suit { case } => {} //~ WARNING unused variable: `case`
|
2018-04-29 18:40:11 -05:00
|
|
|
};
|
2018-04-29 18:51:02 -05:00
|
|
|
|
2018-04-29 19:27:37 -05:00
|
|
|
// Boxed struct
|
2018-04-29 18:51:02 -05:00
|
|
|
match box bag {
|
2019-11-05 18:00:00 -06:00
|
|
|
box Large::Suit { case } => {} //~ WARNING unused variable: `case`
|
2018-04-29 18:51:02 -05:00
|
|
|
};
|
2018-04-29 19:27:37 -05:00
|
|
|
|
|
|
|
// Tuple with struct
|
|
|
|
match (bag,) {
|
2019-11-05 18:00:00 -06:00
|
|
|
(Large::Suit { case },) => {} //~ WARNING unused variable: `case`
|
2018-04-29 19:27:37 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Slice with struct
|
|
|
|
match [bag] {
|
2019-11-05 18:00:00 -06:00
|
|
|
[Large::Suit { case }] => {} //~ WARNING unused variable: `case`
|
2018-04-29 19:27:37 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Tuple struct with struct
|
|
|
|
match Tuple(bag, ()) {
|
2019-11-05 18:00:00 -06:00
|
|
|
Tuple(Large::Suit { case }, ()) => {} //~ WARNING unused variable: `case`
|
2018-04-29 19:27:37 -05:00
|
|
|
};
|
2018-01-31 22:56:01 -06:00
|
|
|
}
|