]> git.proxmox.com Git - rustc.git/blob - tests/ui/lint/no-coverage.rs
New upstream version 1.70.0+dfsg1
[rustc.git] / tests / ui / lint / no-coverage.rs
1 #![feature(extern_types)]
2 #![feature(no_coverage)]
3 #![feature(impl_trait_in_assoc_type)]
4 #![warn(unused_attributes)]
5 #![no_coverage]
6 //~^ WARN: `#[no_coverage]` does not propagate into items and must be applied to the contained functions directly
7
8 #[no_coverage]
9 //~^ WARN: `#[no_coverage]` does not propagate into items and must be applied to the contained functions directly
10 trait Trait {
11 #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
12 const X: u32;
13
14 #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
15 type T;
16
17 type U;
18 }
19
20 #[no_coverage]
21 //~^ WARN: `#[no_coverage]` does not propagate into items and must be applied to the contained functions directly
22 impl Trait for () {
23 const X: u32 = 0;
24
25 #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
26 type T = Self;
27
28 #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
29 type U = impl Trait; //~ ERROR unconstrained opaque type
30 }
31
32 extern "C" {
33 #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
34 static X: u32;
35
36 #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
37 type T;
38 }
39
40 #[no_coverage]
41 fn main() {
42 #[no_coverage]
43 //~^ WARN `#[no_coverage]` may only be applied to function definitions
44 let _ = ();
45
46 match () {
47 #[no_coverage]
48 //~^ WARN `#[no_coverage]` may only be applied to function definitions
49 () => (),
50 }
51
52 #[no_coverage]
53 //~^ WARN `#[no_coverage]` may only be applied to function definitions
54 return ();
55 }