]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/stability-attribute-sanity.rs
Merge tag 'upstream/1.5.0+dfsg1'
[rustc.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(staged_api)]
14 #![staged_api]
15
16 mod bogus_attribute_types_1 {
17 #[stable(feature = "a", since = "a", reason)] //~ ERROR unknown meta item 'reason'
18 fn f1() { }
19
20 #[stable(feature = "a", since)] //~ ERROR incorrect meta item
21 fn f2() { }
22
23 #[stable(feature, since = "a")] //~ ERROR incorrect meta item
24 fn f3() { }
25
26 #[stable(feature = "a", since(b))] //~ ERROR incorrect meta item
27 fn f5() { }
28
29 #[stable(feature(b), since = "a")] //~ ERROR incorrect meta item
30 fn f6() { }
31 }
32
33 mod bogus_attribute_types_2 {
34 #[unstable] //~ ERROR incorrect stability attribute type
35 fn f1() { }
36
37 #[unstable = "a"] //~ ERROR incorrect stability attribute type
38 fn f2() { }
39
40 #[stable] //~ ERROR incorrect stability attribute type
41 fn f3() { }
42
43 #[stable = "a"] //~ ERROR incorrect stability attribute type
44 fn f4() { }
45
46 #[stable(feature = "a", since = "b")]
47 #[deprecated] //~ ERROR incorrect stability attribute type
48 fn f5() { }
49
50 #[stable(feature = "a", since = "b")]
51 #[deprecated = "a"] //~ ERROR incorrect stability attribute type
52 fn f6() { }
53 }
54
55 mod missing_feature_names {
56 #[unstable(issue = "0")] //~ ERROR missing 'feature'
57 fn f1() { }
58
59 #[unstable(feature = "a")] //~ ERROR missing 'issue'
60 fn f2() { }
61
62 #[stable(since = "a")] //~ ERROR missing 'feature'
63 fn f3() { }
64 }
65
66 mod missing_version {
67 #[stable(feature = "a")] //~ ERROR missing 'since'
68 fn f1() { }
69
70 #[stable(feature = "a", since = "b")]
71 #[deprecated(reason = "a")] //~ ERROR missing 'since'
72 fn f2() { }
73 }
74
75 #[unstable(feature = "a", issue = "0")]
76 #[stable(feature = "a", since = "b")]
77 fn multiple1() { } //~ ERROR multiple stability levels
78
79 #[unstable(feature = "a", issue = "0")]
80 #[unstable(feature = "a", issue = "0")]
81 fn multiple2() { } //~ ERROR multiple stability levels
82
83 #[stable(feature = "a", since = "b")]
84 #[stable(feature = "a", since = "b")]
85 fn multiple3() { } //~ ERROR multiple stability levels
86
87 #[stable(feature = "a", since = "b")]
88 #[deprecated(since = "b", reason = "text")]
89 #[deprecated(since = "b", reason = "text")]
90 fn multiple4() { } //~ ERROR multiple deprecated attributes
91 //~^ ERROR Invalid stability or deprecation version found
92
93 #[deprecated(since = "a", reason = "text")]
94 fn deprecated_without_unstable_or_stable() { } //~ ERROR deprecated attribute must be paired
95
96 fn main() { }