diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/lint/auxiliary/add-impl.rs | 22 | ||||
-rw-r--r-- | src/test/ui/lint/auxiliary/external_extern_fn.rs | 3 | ||||
-rw-r--r-- | src/test/ui/lint/auxiliary/inherited_stability.rs | 47 | ||||
-rw-r--r-- | src/test/ui/lint/auxiliary/lint_output_format.rs | 20 | ||||
-rw-r--r-- | src/test/ui/lint/auxiliary/lint_stability.rs | 188 | ||||
-rw-r--r-- | src/test/ui/lint/auxiliary/lint_stability_fields.rs | 66 | ||||
-rw-r--r-- | src/test/ui/lint/auxiliary/lints-in-foreign-macros.rs | 14 | ||||
-rw-r--r-- | src/test/ui/lint/auxiliary/stability-cfg2.rs | 5 | ||||
-rw-r--r-- | src/test/ui/lint/auxiliary/stability_cfg1.rs | 3 | ||||
-rw-r--r-- | src/test/ui/lint/auxiliary/stability_cfg2.rs | 5 | ||||
-rw-r--r-- | src/test/ui/lint/auxiliary/unaligned_references_external_crate.rs | 28 |
11 files changed, 401 insertions, 0 deletions
diff --git a/src/test/ui/lint/auxiliary/add-impl.rs b/src/test/ui/lint/auxiliary/add-impl.rs new file mode 100644 index 000000000..9d0e3068a --- /dev/null +++ b/src/test/ui/lint/auxiliary/add-impl.rs @@ -0,0 +1,22 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(AddImpl)] +// Unnecessary qualification `bar::foo` +// https://github.com/rust-lang/rust/issues/71898 +pub fn derive(input: TokenStream) -> TokenStream { + "impl B { + fn foo(&self) { use bar::foo; bar::foo() } + } + + fn foo() {} + + mod bar { pub fn foo() {} } + ".parse().unwrap() +} diff --git a/src/test/ui/lint/auxiliary/external_extern_fn.rs b/src/test/ui/lint/auxiliary/external_extern_fn.rs new file mode 100644 index 000000000..c2a8cadc6 --- /dev/null +++ b/src/test/ui/lint/auxiliary/external_extern_fn.rs @@ -0,0 +1,3 @@ +extern "C" { + pub fn extern_fn(x: u8); +} diff --git a/src/test/ui/lint/auxiliary/inherited_stability.rs b/src/test/ui/lint/auxiliary/inherited_stability.rs new file mode 100644 index 000000000..62100e5cc --- /dev/null +++ b/src/test/ui/lint/auxiliary/inherited_stability.rs @@ -0,0 +1,47 @@ +#![crate_name="inherited_stability"] +#![crate_type = "lib"] +#![unstable(feature = "unstable_test_feature", issue = "none")] +#![feature(staged_api)] + +pub fn unstable() {} + +#[stable(feature = "rust1", since = "1.0.0")] +pub fn stable() {} + +#[stable(feature = "rust1", since = "1.0.0")] +pub mod stable_mod { + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub fn unstable() {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub fn stable() {} +} + +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub mod unstable_mod { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0", note = "text")] + pub fn deprecated() {} + + pub fn unstable() {} +} + +#[stable(feature = "rust1", since = "1.0.0")] +pub trait Stable { + #[unstable(feature = "unstable_test_feature", issue = "none")] + fn unstable(&self); + + #[stable(feature = "rust1", since = "1.0.0")] + fn stable(&self); +} + +impl Stable for usize { + fn unstable(&self) {} + fn stable(&self) {} +} + +pub enum Unstable { + UnstableVariant, + #[stable(feature = "rust1", since = "1.0.0")] + StableVariant +} diff --git a/src/test/ui/lint/auxiliary/lint_output_format.rs b/src/test/ui/lint/auxiliary/lint_output_format.rs new file mode 100644 index 000000000..4e3547250 --- /dev/null +++ b/src/test/ui/lint/auxiliary/lint_output_format.rs @@ -0,0 +1,20 @@ +#![crate_name="lint_output_format"] +#![crate_type = "lib"] +#![feature(staged_api)] +#![unstable(feature = "unstable_test_feature", issue = "none")] + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0", note = "text")] +pub fn foo() -> usize { + 20 +} + +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub fn bar() -> usize { + 40 +} + +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub fn baz() -> usize { + 30 +} diff --git a/src/test/ui/lint/auxiliary/lint_stability.rs b/src/test/ui/lint/auxiliary/lint_stability.rs new file mode 100644 index 000000000..99c29dcdd --- /dev/null +++ b/src/test/ui/lint/auxiliary/lint_stability.rs @@ -0,0 +1,188 @@ +#![crate_name="lint_stability"] +#![crate_type = "lib"] +#![feature(staged_api)] +#![feature(associated_type_defaults)] +#![stable(feature = "lint_stability", since = "1.0.0")] + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0", note = "text")] +pub fn deprecated() {} +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0", note = "text")] +pub fn deprecated_text() {} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[deprecated(since = "99.99.99", note = "text")] +pub fn deprecated_future() {} + +#[unstable(feature = "unstable_test_feature", issue = "none")] +#[deprecated(since = "1.0.0", note = "text")] +pub fn deprecated_unstable() {} +#[unstable(feature = "unstable_test_feature", issue = "none")] +#[deprecated(since = "1.0.0", note = "text")] +pub fn deprecated_unstable_text() {} + +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub fn unstable() {} +#[unstable(feature = "unstable_test_feature", reason = "text", issue = "none")] +pub fn unstable_text() {} + +#[stable(feature = "rust1", since = "1.0.0")] +pub fn stable() {} +#[stable(feature = "rust1", since = "1.0.0")] +pub fn stable_text() {} + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct MethodTester; + +impl MethodTester { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0", note = "text")] + pub fn method_deprecated(&self) {} + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0", note = "text")] + pub fn method_deprecated_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "none")] + #[deprecated(since = "1.0.0", note = "text")] + pub fn method_deprecated_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", issue = "none")] + #[deprecated(since = "1.0.0", note = "text")] + pub fn method_deprecated_unstable_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub fn method_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "none")] + pub fn method_unstable_text(&self) {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub fn method_stable(&self) {} + #[stable(feature = "rust1", since = "1.0.0")] + pub fn method_stable_text(&self) {} +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub trait Trait { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0", note = "text")] + fn trait_deprecated(&self) {} + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0", note = "text")] + fn trait_deprecated_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "none")] + #[deprecated(since = "1.0.0", note = "text")] + fn trait_deprecated_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", issue = "none")] + #[deprecated(since = "1.0.0", note = "text")] + fn trait_deprecated_unstable_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "none")] + fn trait_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "none")] + fn trait_unstable_text(&self) {} + + #[stable(feature = "rust1", since = "1.0.0")] + fn trait_stable(&self) {} + #[stable(feature = "rust1", since = "1.0.0")] + fn trait_stable_text(&self) {} +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub trait TraitWithAssociatedTypes { + #[unstable(feature = "unstable_test_feature", issue = "none")] + type TypeUnstable = u8; + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0", note = "text")] + type TypeDeprecated = u8; +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +impl Trait for MethodTester {} + +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub trait UnstableTrait { fn dummy(&self) { } } + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0", note = "text")] +pub trait DeprecatedTrait { + #[stable(feature = "stable_test_feature", since = "1.0.0")] fn dummy(&self) { } +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0", note = "text")] +pub struct DeprecatedStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize +} +#[unstable(feature = "unstable_test_feature", issue = "none")] +#[deprecated(since = "1.0.0", note = "text")] +pub struct DeprecatedUnstableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize +} +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub struct UnstableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize +} +#[stable(feature = "rust1", since = "1.0.0")] +pub struct StableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize +} +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub enum UnstableEnum {} +#[stable(feature = "rust1", since = "1.0.0")] +pub enum StableEnum {} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0", note = "text")] +pub struct DeprecatedUnitStruct; +#[unstable(feature = "unstable_test_feature", issue = "none")] +#[deprecated(since = "1.0.0", note = "text")] +pub struct DeprecatedUnstableUnitStruct; +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub struct UnstableUnitStruct; +#[stable(feature = "rust1", since = "1.0.0")] +pub struct StableUnitStruct; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub enum Enum { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[deprecated(since = "1.0.0", note = "text")] + DeprecatedVariant, + #[unstable(feature = "unstable_test_feature", issue = "none")] + #[deprecated(since = "1.0.0", note = "text")] + DeprecatedUnstableVariant, + #[unstable(feature = "unstable_test_feature", issue = "none")] + UnstableVariant, + + #[stable(feature = "rust1", since = "1.0.0")] + StableVariant, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[deprecated(since = "1.0.0", note = "text")] +pub struct DeprecatedTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); +#[unstable(feature = "unstable_test_feature", issue = "none")] +#[deprecated(since = "1.0.0", note = "text")] +pub struct DeprecatedUnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub struct UnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); +#[stable(feature = "rust1", since = "1.0.0")] +pub struct StableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[macro_export] +macro_rules! macro_test { + () => (deprecated()); +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[macro_export] +macro_rules! macro_test_arg { + ($func:expr) => ($func); +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[macro_export] +macro_rules! macro_test_arg_nested { + ($func:ident) => (macro_test_arg!($func())); +} diff --git a/src/test/ui/lint/auxiliary/lint_stability_fields.rs b/src/test/ui/lint/auxiliary/lint_stability_fields.rs new file mode 100644 index 000000000..e72a501e1 --- /dev/null +++ b/src/test/ui/lint/auxiliary/lint_stability_fields.rs @@ -0,0 +1,66 @@ +#![feature(staged_api)] +#![stable(feature = "rust1", since = "1.0.0")] + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct Stable { + pub inherit: u8, + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub override1: u8, + #[deprecated(since = "1.0.0", note = "text")] + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub override2: u8, + #[stable(feature = "rust2", since = "2.0.0")] + pub override3: u8, +} + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct Stable2(#[stable(feature = "rust2", since = "2.0.0")] pub u8, + #[unstable(feature = "unstable_test_feature", issue = "none")] pub u8, + #[unstable(feature = "unstable_test_feature", issue = "none")] + #[deprecated(since = "1.0.0", note = "text")] pub u8, + pub u8); + +#[stable(feature = "rust1", since = "1.0.0")] +pub enum Stable3 { + Inherit(u8), + InheritOverride(#[stable(feature = "rust2", since = "2.0.0")] u8), + #[stable(feature = "rust2", since = "2.0.0")] + Override1, + #[unstable(feature = "unstable_test_feature", issue = "none")] + Override2, + #[deprecated(since = "1.0.0", note = "text")] + #[unstable(feature = "unstable_test_feature", issue = "none")] + Override3, +} + +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub struct Unstable { + pub inherit: u8, + #[stable(feature = "rust1", since = "1.0.0")] + pub override1: u8, + #[deprecated(since = "1.0.0", note = "text")] + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub override2: u8, +} + +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub struct Unstable2(pub u8, + #[stable(feature = "rust1", since = "1.0.0")] pub u8, + #[unstable(feature = "unstable_test_feature", issue = "none")] + #[deprecated(since = "1.0.0", note = "text")] pub u8); + +#[unstable(feature = "unstable_test_feature", issue = "none")] +#[deprecated(since = "1.0.0", note = "text")] +pub struct Deprecated { + pub inherit: u8, + #[stable(feature = "rust1", since = "1.0.0")] + pub override1: u8, + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub override2: u8, +} + +#[unstable(feature = "unstable_test_feature", issue = "none")] +#[deprecated(since = "1.0.0", note = "text")] +pub struct Deprecated2(pub u8, + #[stable(feature = "rust1", since = "1.0.0")] pub u8, + #[unstable(feature = "unstable_test_feature", issue = "none")] pub u8); diff --git a/src/test/ui/lint/auxiliary/lints-in-foreign-macros.rs b/src/test/ui/lint/auxiliary/lints-in-foreign-macros.rs new file mode 100644 index 000000000..b969d9dba --- /dev/null +++ b/src/test/ui/lint/auxiliary/lints-in-foreign-macros.rs @@ -0,0 +1,14 @@ +#[macro_export] +macro_rules! bar { + () => {use std::string::ToString;} +} + +#[macro_export] +macro_rules! baz { + ($i:item) => ($i) +} + +#[macro_export] +macro_rules! baz2 { + ($($i:tt)*) => ($($i)*) +} diff --git a/src/test/ui/lint/auxiliary/stability-cfg2.rs b/src/test/ui/lint/auxiliary/stability-cfg2.rs new file mode 100644 index 000000000..c995038e5 --- /dev/null +++ b/src/test/ui/lint/auxiliary/stability-cfg2.rs @@ -0,0 +1,5 @@ +// compile-flags:--cfg foo + +#![cfg_attr(foo, unstable(feature = "unstable_test_feature", issue = "none"))] +#![cfg_attr(not(foo), stable(feature = "test_feature", since = "1.0.0"))] +#![feature(staged_api)] diff --git a/src/test/ui/lint/auxiliary/stability_cfg1.rs b/src/test/ui/lint/auxiliary/stability_cfg1.rs new file mode 100644 index 000000000..2e027cc27 --- /dev/null +++ b/src/test/ui/lint/auxiliary/stability_cfg1.rs @@ -0,0 +1,3 @@ +#![cfg_attr(foo, experimental)] +#![cfg_attr(not(foo), stable(feature = "test_feature", since = "1.0.0"))] +#![feature(staged_api)] diff --git a/src/test/ui/lint/auxiliary/stability_cfg2.rs b/src/test/ui/lint/auxiliary/stability_cfg2.rs new file mode 100644 index 000000000..c995038e5 --- /dev/null +++ b/src/test/ui/lint/auxiliary/stability_cfg2.rs @@ -0,0 +1,5 @@ +// compile-flags:--cfg foo + +#![cfg_attr(foo, unstable(feature = "unstable_test_feature", issue = "none"))] +#![cfg_attr(not(foo), stable(feature = "test_feature", since = "1.0.0"))] +#![feature(staged_api)] diff --git a/src/test/ui/lint/auxiliary/unaligned_references_external_crate.rs b/src/test/ui/lint/auxiliary/unaligned_references_external_crate.rs new file mode 100644 index 000000000..fb486c6b5 --- /dev/null +++ b/src/test/ui/lint/auxiliary/unaligned_references_external_crate.rs @@ -0,0 +1,28 @@ +#[macro_export] +macro_rules! mac { + ( + $(#[$attrs:meta])* + pub struct $ident:ident { + $( + $(#[$pin:ident])? + $field_vis:vis $field:ident: $field_ty:ty + ),+ $(,)? + } + ) => { + $(#[$attrs])* + pub struct $ident { + $( + $field_vis $field: $field_ty + ),+ + } + + const _: () = { + #[deny(unaligned_references)] + fn __f(this: &$ident) { + $( + let _ = &this.$field; + )+ + } + }; + }; +} |