]>
Commit | Line | Data |
---|---|---|
a1dfa0c6 XL |
1 | #![deny(unused_must_use)] |
2 | ||
3 | #[must_use] | |
4 | trait Critical {} | |
5 | ||
6 | trait NotSoCritical {} | |
7 | ||
8 | trait DecidedlyUnimportant {} | |
9 | ||
10 | struct Anon; | |
11 | ||
12 | impl Critical for Anon {} | |
13 | impl NotSoCritical for Anon {} | |
14 | impl DecidedlyUnimportant for Anon {} | |
15 | ||
16 | fn get_critical() -> impl NotSoCritical + Critical + DecidedlyUnimportant { | |
17 | Anon {} | |
18 | } | |
19 | ||
dc9dc135 XL |
20 | fn get_boxed_critical() -> Box<dyn Critical> { |
21 | Box::new(Anon {}) | |
22 | } | |
23 | ||
24 | fn get_nested_boxed_critical() -> Box<Box<dyn Critical>> { | |
25 | Box::new(Box::new(Anon {})) | |
26 | } | |
27 | ||
28 | fn get_critical_tuple() -> (u32, Box<dyn Critical>, impl Critical, ()) { | |
29 | (0, get_boxed_critical(), get_critical(), ()) | |
30 | } | |
31 | ||
a1dfa0c6 XL |
32 | fn main() { |
33 | get_critical(); //~ ERROR unused implementer of `Critical` that must be used | |
dc9dc135 XL |
34 | get_boxed_critical(); //~ ERROR unused boxed `Critical` trait object that must be used |
35 | get_nested_boxed_critical(); | |
36 | //~^ ERROR unused boxed boxed `Critical` trait object that must be used | |
37 | get_critical_tuple(); //~ ERROR unused boxed `Critical` trait object in tuple element 1 | |
38 | //~^ ERROR unused implementer of `Critical` in tuple element 2 | |
a1dfa0c6 | 39 | } |