blob: e283eaa88dd136f52257f41aa4dc997afbe7d7d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#![allow(dead_code)]
#![deny(unused_results, unused_must_use)]
//~^ NOTE: the lint level is defined here
//~| NOTE: the lint level is defined here
#[must_use]
enum MustUse { Test }
#[must_use = "some message"]
enum MustUseMsg { Test2 }
fn foo<T>() -> T { panic!() }
fn bar() -> isize { return foo::<isize>(); }
fn baz() -> MustUse { return foo::<MustUse>(); }
fn qux() -> MustUseMsg { return foo::<MustUseMsg>(); }
#[allow(unused_results)]
fn test() {
foo::<isize>();
foo::<MustUse>(); //~ ERROR: unused `MustUse` that must be used
foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` that must be used
//~^ NOTE: some message
}
#[allow(unused_results, unused_must_use)]
fn test2() {
foo::<isize>();
foo::<MustUse>();
foo::<MustUseMsg>();
}
fn main() {
foo::<isize>(); //~ ERROR: unused result of type `isize`
foo::<MustUse>(); //~ ERROR: unused `MustUse` that must be used
foo::<MustUseMsg>(); //~ ERROR: unused `MustUseMsg` that must be used
//~^ NOTE: some message
let _ = foo::<isize>();
let _ = foo::<MustUse>();
let _ = foo::<MustUseMsg>();
}
|