]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/unused/unused-closure.rs
Auto merge of #106989 - clubby789:is-zero-num, r=scottmcm
[rust.git] / tests / ui / lint / unused / unused-closure.rs
1 // Test that closures and generators are "must use" types.
2 // edition:2018
3
4 #![feature(async_closure)]
5 #![feature(generators)]
6 #![deny(unused_must_use)]
7
8 fn unused() {
9     || { //~ ERROR unused closure that must be used
10         println!("Hello!");
11     };
12
13     async {};    //~ ERROR unused implementer of `Future` that must be used
14     || async {}; //~ ERROR unused closure that must be used
15     async || {}; //~ ERROR unused closure that must be used
16
17
18     [Box::new([|| {}; 10]); 1]; //~ ERROR unused array of boxed arrays of closures that must be used
19
20     vec![|| "a"].pop().unwrap(); //~ ERROR unused closure that must be used
21
22     let b = false;
23         || true; //~ ERROR unused closure that must be used
24     println!("{}", b);
25 }
26
27 fn ignored() {
28     let _ = || {};
29     let _ = || yield 42;
30 }
31
32 fn main() {
33     unused();
34     ignored();
35 }