]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/stability-attribute-sanity.rs
Rollup merge of #44562 - eddyb:ugh-rustdoc, r=nikomatsakis
[rust.git] / src / test / compile-fail / stability-attribute-sanity.rs
1 // Copyright 2015 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
11 // Various checks that stability attributes are used correctly, per RFC 507
12
13 #![feature(const_fn, staged_api, rustc_const_unstable)]
14
15 #![stable(feature = "rust1", since = "1.0.0")]
16
17 mod bogus_attribute_types_1 {
18     #[stable(feature = "a", since = "a", reason)] //~ ERROR unknown meta item 'reason' [E0541]
19     fn f1() { }
20
21     #[stable(feature = "a", since)] //~ ERROR incorrect meta item [E0539]
22     fn f2() { }
23
24     #[stable(feature, since = "a")] //~ ERROR incorrect meta item [E0539]
25     fn f3() { }
26
27     #[stable(feature = "a", since(b))] //~ ERROR incorrect meta item [E0539]
28     fn f5() { }
29
30     #[stable(feature(b), since = "a")] //~ ERROR incorrect meta item [E0539]
31     fn f6() { }
32 }
33
34 mod bogus_attribute_types_2 {
35     #[unstable] //~ ERROR incorrect stability attribute type [E0548]
36     fn f1() { }
37
38     #[unstable = "a"] //~ ERROR incorrect stability attribute type [E0548]
39     fn f2() { }
40
41     #[stable] //~ ERROR incorrect stability attribute type [E0548]
42     fn f3() { }
43
44     #[stable = "a"] //~ ERROR incorrect stability attribute type [E0548]
45     fn f4() { }
46
47     #[stable(feature = "a", since = "b")]
48     #[rustc_deprecated] //~ ERROR incorrect stability attribute type [E0548]
49     fn f5() { }
50
51     #[stable(feature = "a", since = "b")]
52     #[rustc_deprecated = "a"] //~ ERROR incorrect stability attribute type [E0548]
53     fn f6() { }
54 }
55
56 mod missing_feature_names {
57     #[unstable(issue = "0")] //~ ERROR missing 'feature' [E0546]
58     fn f1() { }
59
60     #[unstable(feature = "a")] //~ ERROR missing 'issue' [E0547]
61     fn f2() { }
62
63     #[stable(since = "a")] //~ ERROR missing 'feature' [E0546]
64     fn f3() { }
65 }
66
67 mod missing_version {
68     #[stable(feature = "a")] //~ ERROR missing 'since' [E0542]
69     fn f1() { }
70
71     #[stable(feature = "a", since = "b")]
72     #[rustc_deprecated(reason = "a")] //~ ERROR missing 'since' [E0542]
73     fn f2() { }
74 }
75
76 #[unstable(feature = "a", issue = "0")]
77 #[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544]
78 fn multiple1() { }
79
80 #[unstable(feature = "a", issue = "0")]
81 #[unstable(feature = "a", issue = "0")] //~ ERROR multiple stability levels [E0544]
82 fn multiple2() { }
83
84 #[stable(feature = "a", since = "b")]
85 #[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544]
86 fn multiple3() { }
87
88 #[stable(feature = "a", since = "b")]
89 #[rustc_deprecated(since = "b", reason = "text")]
90 #[rustc_deprecated(since = "b", reason = "text")]
91 #[rustc_const_unstable(feature = "a")]
92 #[rustc_const_unstable(feature = "b")]
93 pub const fn multiple4() { } //~ ERROR multiple rustc_deprecated attributes [E0540]
94 //~^ ERROR Invalid stability or deprecation version found
95 //~| ERROR multiple rustc_const_unstable attributes
96
97 #[rustc_deprecated(since = "a", reason = "text")]
98 fn deprecated_without_unstable_or_stable() { }
99 //~^ ERROR rustc_deprecated attribute must be paired with either stable or unstable attribute
100
101 fn main() { }