]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
1a4d82fc | 11 | #![allow(dead_code)] |
83c7162d XL |
12 | #![deny(unused_results, unused_must_use)] |
13 | //~^ NOTE: lint level defined here | |
14 | //~| NOTE: lint level defined here | |
1a4d82fc JJ |
15 | |
16 | #[must_use] | |
17 | enum MustUse { Test } | |
18 | ||
19 | #[must_use = "some message"] | |
20 | enum MustUseMsg { Test2 } | |
21 | ||
22 | fn foo<T>() -> T { panic!() } | |
23 | ||
24 | fn bar() -> isize { return foo::<isize>(); } | |
25 | fn baz() -> MustUse { return foo::<MustUse>(); } | |
26 | fn qux() -> MustUseMsg { return foo::<MustUseMsg>(); } | |
27 | ||
28 | #[allow(unused_results)] | |
29 | fn test() { | |
30 | foo::<isize>(); | |
0bf4aa26 XL |
31 | foo::<MustUse>(); //~ ERROR: unused `MustUse` that must be used |
32 | foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` that must be used | |
83c7162d | 33 | //~^ NOTE: some message |
1a4d82fc JJ |
34 | } |
35 | ||
36 | #[allow(unused_results, unused_must_use)] | |
37 | fn test2() { | |
38 | foo::<isize>(); | |
39 | foo::<MustUse>(); | |
40 | foo::<MustUseMsg>(); | |
41 | } | |
42 | ||
43 | fn main() { | |
44 | foo::<isize>(); //~ ERROR: unused result | |
0bf4aa26 XL |
45 | foo::<MustUse>(); //~ ERROR: unused `MustUse` that must be used |
46 | foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` that must be used | |
83c7162d | 47 | //~^ NOTE: some message |
1a4d82fc JJ |
48 | |
49 | let _ = foo::<isize>(); | |
50 | let _ = foo::<MustUse>(); | |
51 | let _ = foo::<MustUseMsg>(); | |
52 | } |