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.
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.
12 #![deny(unused_results, unused_must_use)]
13 //~^ NOTE: lint level defined here
14 //~| NOTE: lint level defined here
19 #[must_use = "some message"]
20 enum MustUseMsg { Test2 }
22 fn foo
<T
>() -> T { panic!() }
24 fn bar() -> isize { return foo::<isize>(); }
25 fn baz() -> MustUse { return foo::<MustUse>(); }
26 fn qux() -> MustUseMsg { return foo::<MustUseMsg>(); }
28 #[allow(unused_results)]
31 foo
::<MustUse
>(); //~ ERROR: unused `MustUse` which must be used
32 foo
::<MustUseMsg
>(); //~ ERROR: unused `MustUseMsg` which must be used
33 //~^ NOTE: some message
36 #[allow(unused_results, unused_must_use)]
44 foo
::<isize>(); //~ ERROR: unused result
45 foo
::<MustUse
>(); //~ ERROR: unused `MustUse` which must be used
46 foo
::<MustUseMsg
>(); //~ ERROR: unused `MustUseMsg` which must be used
47 //~^ NOTE: some message
49 let _
= foo
::<isize>();
50 let _
= foo
::<MustUse
>();
51 let _
= foo
::<MustUseMsg
>();