|
| 1 | +// Copyright 2013 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 | +// xfail-fast aux-build |
| 12 | +// aux-build:lint_stability.rs |
| 13 | + |
| 14 | +#[deny(unstable)]; |
| 15 | +#[deny(deprecated)]; |
| 16 | +#[deny(experimental)]; |
| 17 | + |
| 18 | +mod cross_crate { |
| 19 | + extern mod lint_stability; |
| 20 | + use self::lint_stability::*; |
| 21 | + |
| 22 | + fn test() { |
| 23 | + // XXX: attributes on methods are not encoded cross crate. |
| 24 | + let foo = MethodTester; |
| 25 | + |
| 26 | + deprecated(); //~ ERROR use of deprecated item |
| 27 | + foo.method_deprecated(); // ~ ERROR use of deprecated item |
| 28 | + foo.trait_deprecated(); // ~ ERROR use of deprecated item |
| 29 | + |
| 30 | + deprecated_text(); //~ ERROR use of deprecated item: text |
| 31 | + foo.method_deprecated_text(); // ~ ERROR use of deprecated item: text |
| 32 | + foo.trait_deprecated_text(); // ~ ERROR use of deprecated item: text |
| 33 | + |
| 34 | + experimental(); //~ ERROR use of experimental item |
| 35 | + foo.method_experimental(); // ~ ERROR use of experimental item |
| 36 | + foo.trait_experimental(); // ~ ERROR use of experimental item |
| 37 | + |
| 38 | + experimental_text(); //~ ERROR use of experimental item: text |
| 39 | + foo.method_experimental_text(); // ~ ERROR use of experimental item: text |
| 40 | + foo.trait_experimental_text(); // ~ ERROR use of experimental item: text |
| 41 | + |
| 42 | + unstable(); //~ ERROR use of unstable item |
| 43 | + foo.method_unstable(); // ~ ERROR use of unstable item |
| 44 | + foo.trait_unstable(); // ~ ERROR use of unstable item |
| 45 | + |
| 46 | + unstable_text(); //~ ERROR use of unstable item: text |
| 47 | + foo.method_unstable_text(); // ~ ERROR use of unstable item: text |
| 48 | + foo.trait_unstable_text(); // ~ ERROR use of unstable item: text |
| 49 | + |
| 50 | + unmarked(); //~ ERROR use of unmarked item |
| 51 | + foo.method_unmarked(); // ~ ERROR use of unmarked item |
| 52 | + foo.trait_unmarked(); // ~ ERROR use of unmarked item |
| 53 | + |
| 54 | + stable(); |
| 55 | + foo.method_stable(); |
| 56 | + foo.trait_stable(); |
| 57 | + |
| 58 | + stable_text(); |
| 59 | + foo.method_stable_text(); |
| 60 | + foo.trait_stable_text(); |
| 61 | + |
| 62 | + frozen(); |
| 63 | + foo.method_frozen(); |
| 64 | + foo.trait_frozen(); |
| 65 | + |
| 66 | + frozen_text(); |
| 67 | + foo.method_frozen_text(); |
| 68 | + foo.trait_frozen_text(); |
| 69 | + |
| 70 | + locked(); |
| 71 | + foo.method_locked(); |
| 72 | + foo.trait_locked(); |
| 73 | + |
| 74 | + locked_text(); |
| 75 | + foo.method_locked_text(); |
| 76 | + foo.trait_locked_text(); |
| 77 | + |
| 78 | + |
| 79 | + let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated item |
| 80 | + let _ = ExperimentalStruct { i: 0 }; //~ ERROR use of experimental item |
| 81 | + let _ = UnstableStruct { i: 0 }; //~ ERROR use of unstable item |
| 82 | + let _ = UnmarkedStruct { i: 0 }; //~ ERROR use of unmarked item |
| 83 | + let _ = StableStruct { i: 0 }; |
| 84 | + let _ = FrozenStruct { i: 0 }; |
| 85 | + let _ = LockedStruct { i: 0 }; |
| 86 | + |
| 87 | + let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item |
| 88 | + let _ = ExperimentalUnitStruct; //~ ERROR use of experimental item |
| 89 | + let _ = UnstableUnitStruct; //~ ERROR use of unstable item |
| 90 | + let _ = UnmarkedUnitStruct; //~ ERROR use of unmarked item |
| 91 | + let _ = StableUnitStruct; |
| 92 | + let _ = FrozenUnitStruct; |
| 93 | + let _ = LockedUnitStruct; |
| 94 | + |
| 95 | + let _ = DeprecatedVariant; //~ ERROR use of deprecated item |
| 96 | + let _ = ExperimentalVariant; //~ ERROR use of experimental item |
| 97 | + let _ = UnstableVariant; //~ ERROR use of unstable item |
| 98 | + let _ = UnmarkedVariant; //~ ERROR use of unmarked item |
| 99 | + let _ = StableVariant; |
| 100 | + let _ = FrozenVariant; |
| 101 | + let _ = LockedVariant; |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | +mod this_crate { |
| 106 | + #[deprecated] |
| 107 | + pub fn deprecated() {} |
| 108 | + #[deprecated="text"] |
| 109 | + pub fn deprecated_text() {} |
| 110 | + |
| 111 | + #[experimental] |
| 112 | + pub fn experimental() {} |
| 113 | + #[experimental="text"] |
| 114 | + pub fn experimental_text() {} |
| 115 | + |
| 116 | + #[unstable] |
| 117 | + pub fn unstable() {} |
| 118 | + #[unstable="text"] |
| 119 | + pub fn unstable_text() {} |
| 120 | + |
| 121 | + pub fn unmarked() {} |
| 122 | + |
| 123 | + #[stable] |
| 124 | + pub fn stable() {} |
| 125 | + #[stable="text"] |
| 126 | + pub fn stable_text() {} |
| 127 | + |
| 128 | + #[locked] |
| 129 | + pub fn locked() {} |
| 130 | + #[locked="text"] |
| 131 | + pub fn locked_text() {} |
| 132 | + |
| 133 | + #[frozen] |
| 134 | + pub fn frozen() {} |
| 135 | + #[frozen="text"] |
| 136 | + pub fn frozen_text() {} |
| 137 | + |
| 138 | + #[stable] |
| 139 | + pub struct MethodTester; |
| 140 | + |
| 141 | + impl MethodTester { |
| 142 | + #[deprecated] |
| 143 | + pub fn method_deprecated(&self) {} |
| 144 | + #[deprecated="text"] |
| 145 | + pub fn method_deprecated_text(&self) {} |
| 146 | + |
| 147 | + #[experimental] |
| 148 | + pub fn method_experimental(&self) {} |
| 149 | + #[experimental="text"] |
| 150 | + pub fn method_experimental_text(&self) {} |
| 151 | + |
| 152 | + #[unstable] |
| 153 | + pub fn method_unstable(&self) {} |
| 154 | + #[unstable="text"] |
| 155 | + pub fn method_unstable_text(&self) {} |
| 156 | + |
| 157 | + pub fn method_unmarked(&self) {} |
| 158 | + |
| 159 | + #[stable] |
| 160 | + pub fn method_stable(&self) {} |
| 161 | + #[stable="text"] |
| 162 | + pub fn method_stable_text(&self) {} |
| 163 | + |
| 164 | + #[locked] |
| 165 | + pub fn method_locked(&self) {} |
| 166 | + #[locked="text"] |
| 167 | + pub fn method_locked_text(&self) {} |
| 168 | + |
| 169 | + #[frozen] |
| 170 | + pub fn method_frozen(&self) {} |
| 171 | + #[frozen="text"] |
| 172 | + pub fn method_frozen_text(&self) {} |
| 173 | + } |
| 174 | + |
| 175 | + pub trait Trait { |
| 176 | + #[deprecated] |
| 177 | + fn trait_deprecated(&self) {} |
| 178 | + #[deprecated="text"] |
| 179 | + fn trait_deprecated_text(&self) {} |
| 180 | + |
| 181 | + #[experimental] |
| 182 | + fn trait_experimental(&self) {} |
| 183 | + #[experimental="text"] |
| 184 | + fn trait_experimental_text(&self) {} |
| 185 | + |
| 186 | + #[unstable] |
| 187 | + fn trait_unstable(&self) {} |
| 188 | + #[unstable="text"] |
| 189 | + fn trait_unstable_text(&self) {} |
| 190 | + |
| 191 | + fn trait_unmarked(&self) {} |
| 192 | + |
| 193 | + #[stable] |
| 194 | + fn trait_stable(&self) {} |
| 195 | + #[stable="text"] |
| 196 | + fn trait_stable_text(&self) {} |
| 197 | + |
| 198 | + #[locked] |
| 199 | + fn trait_locked(&self) {} |
| 200 | + #[locked="text"] |
| 201 | + fn trait_locked_text(&self) {} |
| 202 | + |
| 203 | + #[frozen] |
| 204 | + fn trait_frozen(&self) {} |
| 205 | + #[frozen="text"] |
| 206 | + fn trait_frozen_text(&self) {} |
| 207 | + } |
| 208 | + |
| 209 | + impl Trait for MethodTester {} |
| 210 | + |
| 211 | + #[deprecated] |
| 212 | + pub struct DeprecatedStruct { i: int } |
| 213 | + #[experimental] |
| 214 | + pub struct ExperimentalStruct { i: int } |
| 215 | + #[unstable] |
| 216 | + pub struct UnstableStruct { i: int } |
| 217 | + pub struct UnmarkedStruct { i: int } |
| 218 | + #[stable] |
| 219 | + pub struct StableStruct { i: int } |
| 220 | + #[frozen] |
| 221 | + pub struct FrozenStruct { i: int } |
| 222 | + #[locked] |
| 223 | + pub struct LockedStruct { i: int } |
| 224 | + |
| 225 | + #[deprecated] |
| 226 | + pub struct DeprecatedUnitStruct; |
| 227 | + #[experimental] |
| 228 | + pub struct ExperimentalUnitStruct; |
| 229 | + #[unstable] |
| 230 | + pub struct UnstableUnitStruct; |
| 231 | + pub struct UnmarkedUnitStruct; |
| 232 | + #[stable] |
| 233 | + pub struct StableUnitStruct; |
| 234 | + #[frozen] |
| 235 | + pub struct FrozenUnitStruct; |
| 236 | + #[locked] |
| 237 | + pub struct LockedUnitStruct; |
| 238 | + |
| 239 | + pub enum Enum { |
| 240 | + #[deprecated] |
| 241 | + DeprecatedVariant, |
| 242 | + #[experimental] |
| 243 | + ExperimentalVariant, |
| 244 | + #[unstable] |
| 245 | + UnstableVariant, |
| 246 | + |
| 247 | + UnmarkedVariant, |
| 248 | + #[stable] |
| 249 | + StableVariant, |
| 250 | + #[frozen] |
| 251 | + FrozenVariant, |
| 252 | + #[locked] |
| 253 | + LockedVariant, |
| 254 | + } |
| 255 | + |
| 256 | + fn test() { |
| 257 | + let foo = MethodTester; |
| 258 | + |
| 259 | + deprecated(); //~ ERROR use of deprecated item |
| 260 | + foo.method_deprecated(); // ~ ERROR use of deprecated item |
| 261 | + foo.trait_deprecated(); // ~ ERROR use of deprecated item |
| 262 | + |
| 263 | + deprecated_text(); //~ ERROR use of deprecated item: text |
| 264 | + foo.method_deprecated_text(); // ~ ERROR use of deprecated item: text |
| 265 | + foo.trait_deprecated_text(); // ~ ERROR use of deprecated item: text |
| 266 | + |
| 267 | + experimental(); //~ ERROR use of experimental item |
| 268 | + foo.method_experimental(); // ~ ERROR use of experimental item |
| 269 | + foo.trait_experimental(); // ~ ERROR use of experimental item |
| 270 | + |
| 271 | + experimental_text(); //~ ERROR use of experimental item: text |
| 272 | + foo.method_experimental_text(); // ~ ERROR use of experimental item: text |
| 273 | + foo.trait_experimental_text(); // ~ ERROR use of experimental item: text |
| 274 | + |
| 275 | + unstable(); //~ ERROR use of unstable item |
| 276 | + foo.method_unstable(); // ~ ERROR use of unstable item |
| 277 | + foo.trait_unstable(); // ~ ERROR use of unstable item |
| 278 | + |
| 279 | + unstable_text(); //~ ERROR use of unstable item: text |
| 280 | + foo.method_unstable_text(); // ~ ERROR use of unstable item: text |
| 281 | + foo.trait_unstable_text(); // ~ ERROR use of unstable item: text |
| 282 | + |
| 283 | + unmarked(); //~ ERROR use of unmarked item |
| 284 | + foo.method_unmarked(); // ~ ERROR use of unmarked item |
| 285 | + foo.trait_unmarked(); // ~ ERROR use of unmarked item |
| 286 | + |
| 287 | + stable(); |
| 288 | + foo.method_stable(); |
| 289 | + foo.trait_stable(); |
| 290 | + |
| 291 | + stable_text(); |
| 292 | + foo.method_stable_text(); |
| 293 | + foo.trait_stable_text(); |
| 294 | + |
| 295 | + frozen(); |
| 296 | + foo.method_frozen(); |
| 297 | + foo.trait_frozen(); |
| 298 | + |
| 299 | + frozen_text(); |
| 300 | + foo.method_frozen_text(); |
| 301 | + foo.trait_frozen_text(); |
| 302 | + |
| 303 | + locked(); |
| 304 | + foo.method_locked(); |
| 305 | + foo.trait_locked(); |
| 306 | + |
| 307 | + locked_text(); |
| 308 | + foo.method_locked_text(); |
| 309 | + foo.trait_locked_text(); |
| 310 | + |
| 311 | + |
| 312 | + let _ = DeprecatedStruct { i: 0 }; //~ ERROR use of deprecated item |
| 313 | + let _ = ExperimentalStruct { i: 0 }; //~ ERROR use of experimental item |
| 314 | + let _ = UnstableStruct { i: 0 }; //~ ERROR use of unstable item |
| 315 | + let _ = UnmarkedStruct { i: 0 }; //~ ERROR use of unmarked item |
| 316 | + let _ = StableStruct { i: 0 }; |
| 317 | + let _ = FrozenStruct { i: 0 }; |
| 318 | + let _ = LockedStruct { i: 0 }; |
| 319 | + |
| 320 | + let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item |
| 321 | + let _ = ExperimentalUnitStruct; //~ ERROR use of experimental item |
| 322 | + let _ = UnstableUnitStruct; //~ ERROR use of unstable item |
| 323 | + let _ = UnmarkedUnitStruct; //~ ERROR use of unmarked item |
| 324 | + let _ = StableUnitStruct; |
| 325 | + let _ = FrozenUnitStruct; |
| 326 | + let _ = LockedUnitStruct; |
| 327 | + |
| 328 | + let _ = DeprecatedVariant; //~ ERROR use of deprecated item |
| 329 | + let _ = ExperimentalVariant; //~ ERROR use of experimental item |
| 330 | + let _ = UnstableVariant; //~ ERROR use of unstable item |
| 331 | + let _ = UnmarkedVariant; //~ ERROR use of unmarked item |
| 332 | + let _ = StableVariant; |
| 333 | + let _ = FrozenVariant; |
| 334 | + let _ = LockedVariant; |
| 335 | + } |
| 336 | +} |
| 337 | + |
| 338 | +fn main() {} |
0 commit comments