rust/tests/ui/stability-attribute/stability-attribute-sanity.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
2.5 KiB
Rust
Raw Normal View History

// Various checks that stability attributes are used correctly, per RFC 507
2021-05-07 11:56:16 -05:00
#![feature(staged_api)]
2015-11-16 10:54:28 -06:00
#![stable(feature = "rust1", since = "1.0.0")]
mod bogus_attribute_types_1 {
2018-07-23 06:22:23 -05:00
#[stable(feature = "a", since = "b", reason)] //~ ERROR unknown meta item 'reason' [E0541]
fn f1() { }
2016-06-29 10:23:51 -05:00
#[stable(feature = "a", since)] //~ ERROR incorrect meta item [E0539]
fn f2() { }
2016-06-29 10:23:51 -05:00
#[stable(feature, since = "a")] //~ ERROR incorrect meta item [E0539]
fn f3() { }
2016-06-29 10:23:51 -05:00
#[stable(feature = "a", since(b))] //~ ERROR incorrect meta item [E0539]
fn f5() { }
2016-06-29 10:23:51 -05:00
#[stable(feature(b), since = "a")] //~ ERROR incorrect meta item [E0539]
fn f6() { }
}
mod missing_feature_names {
#[unstable(issue = "none")] //~ ERROR missing 'feature' [E0546]
fn f1() { }
2018-07-23 06:22:23 -05:00
#[unstable(feature = "b")] //~ ERROR missing 'issue' [E0547]
fn f2() { }
2015-08-13 15:06:25 -05:00
2016-06-29 10:23:51 -05:00
#[stable(since = "a")] //~ ERROR missing 'feature' [E0546]
2015-08-13 15:06:25 -05:00
fn f3() { }
}
mod missing_version {
2016-06-29 10:23:51 -05:00
#[stable(feature = "a")] //~ ERROR missing 'since' [E0542]
fn f1() { }
#[stable(feature = "a", since = "b")]
2022-03-04 20:59:18 -06:00
#[deprecated(note = "a")] //~ ERROR missing 'since' [E0542]
fn f2() { }
2019-09-26 06:24:41 -05:00
#[stable(feature = "a", since = "b")]
2022-03-04 20:59:18 -06:00
#[deprecated(since = "a")] //~ ERROR missing 'note' [E0543]
2019-09-26 06:24:41 -05:00
fn f3() { }
}
#[unstable(feature = "b", issue = "none")]
2016-06-29 10:23:51 -05:00
#[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544]
fn multiple1() { }
#[unstable(feature = "b", issue = "none")]
#[unstable(feature = "b", issue = "none")] //~ ERROR multiple stability levels [E0544]
2016-06-29 10:23:51 -05:00
fn multiple2() { }
#[stable(feature = "a", since = "b")]
2016-06-29 10:23:51 -05:00
#[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544]
fn multiple3() { }
#[stable(feature = "a", since = "b")] //~ ERROR invalid stability version found
2022-03-04 20:59:18 -06:00
#[deprecated(since = "b", note = "text")]
2022-04-11 19:43:42 -05:00
#[deprecated(since = "b", note = "text")] //~ ERROR multiple `deprecated` attributes
#[rustc_const_unstable(feature = "c", issue = "none")]
#[rustc_const_unstable(feature = "d", issue = "none")] //~ ERROR multiple stability levels
pub const fn multiple4() { }
#[stable(feature = "a", since = "1.0.0")] //~ ERROR invalid deprecation version found
2022-01-19 09:24:49 -06:00
//~^ ERROR feature `a` is declared stable since 1.0.0
2022-03-04 20:59:18 -06:00
#[deprecated(since = "invalid", note = "text")]
fn invalid_deprecation_version() {}
2022-03-04 20:59:18 -06:00
#[deprecated(since = "a", note = "text")]
2016-06-29 10:23:51 -05:00
fn deprecated_without_unstable_or_stable() { }
2022-03-04 20:59:18 -06:00
//~^^ ERROR deprecated attribute must be paired with either stable or unstable attribute
fn main() { }