]> git.proxmox.com Git - rustc.git/blob - src/test/ui/stability-attribute/stability-attribute-sanity.rs
New upstream version 1.40.0+dfsg1
[rustc.git] / src / test / ui / stability-attribute / stability-attribute-sanity.rs
1 // Various checks that stability attributes are used correctly, per RFC 507
2
3 #![feature(const_fn, staged_api, rustc_const_unstable)]
4
5 #![stable(feature = "rust1", since = "1.0.0")]
6
7 mod bogus_attribute_types_1 {
8 #[stable(feature = "a", since = "b", reason)] //~ ERROR unknown meta item 'reason' [E0541]
9 fn f1() { }
10
11 #[stable(feature = "a", since)] //~ ERROR incorrect meta item [E0539]
12 fn f2() { }
13
14 #[stable(feature, since = "a")] //~ ERROR incorrect meta item [E0539]
15 fn f3() { }
16
17 #[stable(feature = "a", since(b))] //~ ERROR incorrect meta item [E0539]
18 fn f5() { }
19
20 #[stable(feature(b), since = "a")] //~ ERROR incorrect meta item [E0539]
21 fn f6() { }
22 }
23
24 mod missing_feature_names {
25 #[unstable(issue = "0")] //~ ERROR missing 'feature' [E0546]
26 fn f1() { }
27
28 #[unstable(feature = "b")] //~ ERROR missing 'issue' [E0547]
29 fn f2() { }
30
31 #[stable(since = "a")] //~ ERROR missing 'feature' [E0546]
32 fn f3() { }
33 }
34
35 mod missing_version {
36 #[stable(feature = "a")] //~ ERROR missing 'since' [E0542]
37 fn f1() { }
38
39 #[stable(feature = "a", since = "b")]
40 #[rustc_deprecated(reason = "a")] //~ ERROR missing 'since' [E0542]
41 fn f2() { }
42
43 #[stable(feature = "a", since = "b")]
44 #[rustc_deprecated(since = "a")] //~ ERROR missing 'reason' [E0543]
45 fn f3() { }
46 }
47
48 #[unstable(feature = "b", issue = "0")]
49 #[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544]
50 fn multiple1() { }
51
52 #[unstable(feature = "b", issue = "0")]
53 #[unstable(feature = "b", issue = "0")] //~ ERROR multiple stability levels [E0544]
54 fn multiple2() { }
55
56 #[stable(feature = "a", since = "b")]
57 #[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544]
58 fn multiple3() { }
59
60 #[stable(feature = "a", since = "b")]
61 #[rustc_deprecated(since = "b", reason = "text")]
62 #[rustc_deprecated(since = "b", reason = "text")]
63 #[rustc_const_unstable(feature = "c")]
64 #[rustc_const_unstable(feature = "d")]
65 pub const fn multiple4() { } //~ ERROR multiple rustc_deprecated attributes [E0540]
66 //~^ ERROR Invalid stability or deprecation version found
67 //~| ERROR multiple rustc_const_unstable attributes
68
69 #[rustc_deprecated(since = "a", reason = "text")]
70 fn deprecated_without_unstable_or_stable() { }
71 //~^ ERROR rustc_deprecated attribute must be paired with either stable or unstable attribute
72
73 fn main() { }