From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../accidental-stable-in-unstable.rs | 10 + .../accidental-stable-in-unstable.stderr | 11 + .../stability-attribute/allow-unstable-reexport.rs | 30 ++ .../allow-unstable-reexport.stderr | 27 ++ .../allowed-through-unstable.rs | 9 + .../allowed-through-unstable.stderr | 12 + .../auxiliary/allowed-through-unstable-core.rs | 14 + .../auxiliary/ctor-stability.rs | 8 + .../stability-attribute/auxiliary/default_body.rs | 29 ++ .../auxiliary/lint-stability-reexport.rs | 9 + .../auxiliary/lint-stability.rs | 188 +++++++++ .../auxiliary/stability-attribute-implies.rs | 8 + .../auxiliary/stability_attribute_issue.rs | 9 + .../auxiliary/stable-in-unstable-core.rs | 8 + .../auxiliary/stable-in-unstable-std.rs | 11 + .../auxiliary/unstable_generic_param.rs | 229 ++++++++++ tests/ui/stability-attribute/ctor-stability.rs | 8 + .../default-body-stability-err.rs | 19 + .../default-body-stability-err.stderr | 38 ++ .../default-body-stability-ok-enables.rs | 18 + .../default-body-stability-ok-impls.rs | 21 + .../generics-default-stability-trait.rs | 33 ++ .../generics-default-stability-trait.stderr | 27 ++ .../generics-default-stability-where.rs | 11 + .../generics-default-stability-where.stderr | 11 + .../generics-default-stability.rs | 251 +++++++++++ .../generics-default-stability.stderr | 469 +++++++++++++++++++++ tests/ui/stability-attribute/issue-106589.rs | 10 + tests/ui/stability-attribute/issue-106589.stderr | 15 + tests/ui/stability-attribute/issue-28075.rs | 13 + tests/ui/stability-attribute/issue-28075.stderr | 11 + tests/ui/stability-attribute/issue-28388-3.rs | 11 + tests/ui/stability-attribute/issue-28388-3.stderr | 11 + .../issue-99286-stable-intrinsics.rs | 17 + .../stability-attribute/missing-const-stability.rs | 33 ++ .../missing-const-stability.stderr | 23 + .../missing-stability-attr-at-top-level.rs | 4 + .../missing-stability-attr-at-top-level.stderr | 11 + .../stability-attribute-implies-missing.rs | 10 + .../stability-attribute-implies-missing.stderr | 8 + .../stability-attribute-implies-no-feature.rs | 13 + .../stability-attribute-implies-no-feature.stderr | 21 + .../stability-attribute-implies-using-stable.rs | 15 + ...stability-attribute-implies-using-stable.stderr | 22 + .../stability-attribute-implies-using-unstable.rs | 17 + ...ability-attribute-implies-using-unstable.stderr | 22 + .../stability-attribute-issue-43027.rs | 15 + .../stability-attribute-issue.rs | 12 + .../stability-attribute-issue.stderr | 21 + ...tability-attribute-non-staged-force-unstable.rs | 5 + ...lity-attribute-non-staged-force-unstable.stderr | 15 + .../stability-attribute-non-staged.rs | 3 + .../stability-attribute-non-staged.stderr | 15 + .../stability-attribute-sanity-2.rs | 17 + .../stability-attribute-sanity-2.stderr | 24 ++ .../stability-attribute-sanity-3.rs | 12 + .../stability-attribute-sanity-3.stderr | 10 + .../stability-attribute-sanity-4.rs | 29 ++ .../stability-attribute-sanity-4.stderr | 39 ++ .../stability-attribute-sanity.rs | 76 ++++ .../stability-attribute-sanity.stderr | 136 ++++++ .../stability-attribute-trait-impl.rs | 43 ++ .../stability-attribute-trait-impl.stderr | 31 ++ .../stability-in-private-module.rs | 4 + .../stability-in-private-module.stderr | 12 + tests/ui/stability-attribute/stable-in-unstable.rs | 54 +++ .../stability-attribute/stable-in-unstable.stderr | 57 +++ .../suggest-vec-allocator-api.rs | 9 + .../suggest-vec-allocator-api.stderr | 49 +++ 69 files changed, 2493 insertions(+) create mode 100644 tests/ui/stability-attribute/accidental-stable-in-unstable.rs create mode 100644 tests/ui/stability-attribute/accidental-stable-in-unstable.stderr create mode 100644 tests/ui/stability-attribute/allow-unstable-reexport.rs create mode 100644 tests/ui/stability-attribute/allow-unstable-reexport.stderr create mode 100644 tests/ui/stability-attribute/allowed-through-unstable.rs create mode 100644 tests/ui/stability-attribute/allowed-through-unstable.stderr create mode 100644 tests/ui/stability-attribute/auxiliary/allowed-through-unstable-core.rs create mode 100644 tests/ui/stability-attribute/auxiliary/ctor-stability.rs create mode 100644 tests/ui/stability-attribute/auxiliary/default_body.rs create mode 100644 tests/ui/stability-attribute/auxiliary/lint-stability-reexport.rs create mode 100644 tests/ui/stability-attribute/auxiliary/lint-stability.rs create mode 100644 tests/ui/stability-attribute/auxiliary/stability-attribute-implies.rs create mode 100644 tests/ui/stability-attribute/auxiliary/stability_attribute_issue.rs create mode 100644 tests/ui/stability-attribute/auxiliary/stable-in-unstable-core.rs create mode 100644 tests/ui/stability-attribute/auxiliary/stable-in-unstable-std.rs create mode 100644 tests/ui/stability-attribute/auxiliary/unstable_generic_param.rs create mode 100644 tests/ui/stability-attribute/ctor-stability.rs create mode 100644 tests/ui/stability-attribute/default-body-stability-err.rs create mode 100644 tests/ui/stability-attribute/default-body-stability-err.stderr create mode 100644 tests/ui/stability-attribute/default-body-stability-ok-enables.rs create mode 100644 tests/ui/stability-attribute/default-body-stability-ok-impls.rs create mode 100644 tests/ui/stability-attribute/generics-default-stability-trait.rs create mode 100644 tests/ui/stability-attribute/generics-default-stability-trait.stderr create mode 100644 tests/ui/stability-attribute/generics-default-stability-where.rs create mode 100644 tests/ui/stability-attribute/generics-default-stability-where.stderr create mode 100644 tests/ui/stability-attribute/generics-default-stability.rs create mode 100644 tests/ui/stability-attribute/generics-default-stability.stderr create mode 100644 tests/ui/stability-attribute/issue-106589.rs create mode 100644 tests/ui/stability-attribute/issue-106589.stderr create mode 100644 tests/ui/stability-attribute/issue-28075.rs create mode 100644 tests/ui/stability-attribute/issue-28075.stderr create mode 100644 tests/ui/stability-attribute/issue-28388-3.rs create mode 100644 tests/ui/stability-attribute/issue-28388-3.stderr create mode 100644 tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs create mode 100644 tests/ui/stability-attribute/missing-const-stability.rs create mode 100644 tests/ui/stability-attribute/missing-const-stability.stderr create mode 100644 tests/ui/stability-attribute/missing-stability-attr-at-top-level.rs create mode 100644 tests/ui/stability-attribute/missing-stability-attr-at-top-level.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-implies-missing.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-implies-missing.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-implies-no-feature.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-implies-no-feature.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-implies-using-stable.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-implies-using-stable.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-implies-using-unstable.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-implies-using-unstable.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-issue-43027.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-issue.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-issue.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-non-staged-force-unstable.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-non-staged.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-non-staged.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-sanity-2.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-sanity-2.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-sanity-3.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-sanity-3.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-sanity-4.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-sanity-4.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-sanity.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-sanity.stderr create mode 100644 tests/ui/stability-attribute/stability-attribute-trait-impl.rs create mode 100644 tests/ui/stability-attribute/stability-attribute-trait-impl.stderr create mode 100644 tests/ui/stability-attribute/stability-in-private-module.rs create mode 100644 tests/ui/stability-attribute/stability-in-private-module.stderr create mode 100644 tests/ui/stability-attribute/stable-in-unstable.rs create mode 100644 tests/ui/stability-attribute/stable-in-unstable.stderr create mode 100644 tests/ui/stability-attribute/suggest-vec-allocator-api.rs create mode 100644 tests/ui/stability-attribute/suggest-vec-allocator-api.stderr (limited to 'tests/ui/stability-attribute') diff --git a/tests/ui/stability-attribute/accidental-stable-in-unstable.rs b/tests/ui/stability-attribute/accidental-stable-in-unstable.rs new file mode 100644 index 000000000..f8bbe90cf --- /dev/null +++ b/tests/ui/stability-attribute/accidental-stable-in-unstable.rs @@ -0,0 +1,10 @@ +#![crate_type = "lib"] +extern crate core; + +// Known accidental stabilizations with no known users, slated for un-stabilization +// fully stable @ core::char::UNICODE_VERSION +use core::unicode::UNICODE_VERSION; //~ ERROR use of unstable library feature 'unicode_internals' + +// Known accidental stabilizations with known users +// fully stable @ core::mem::transmute +use core::intrinsics::transmute; // depended upon by rand_core diff --git a/tests/ui/stability-attribute/accidental-stable-in-unstable.stderr b/tests/ui/stability-attribute/accidental-stable-in-unstable.stderr new file mode 100644 index 000000000..ff733822c --- /dev/null +++ b/tests/ui/stability-attribute/accidental-stable-in-unstable.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'unicode_internals' + --> $DIR/accidental-stable-in-unstable.rs:6:5 + | +LL | use core::unicode::UNICODE_VERSION; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(unicode_internals)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/allow-unstable-reexport.rs b/tests/ui/stability-attribute/allow-unstable-reexport.rs new file mode 100644 index 000000000..937913954 --- /dev/null +++ b/tests/ui/stability-attribute/allow-unstable-reexport.rs @@ -0,0 +1,30 @@ +// Allow an unstable re-export without requiring a feature gate. +// #94972 + +// aux-build:lint-stability.rs +// aux-build:lint-stability-reexport.rs +#![feature(staged_api)] +#![stable(feature = "lint_stability", since = "1.0.0")] + +extern crate lint_stability; +extern crate lint_stability_reexport; + +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub use lint_stability::unstable; + +// We want to confirm that using a re-export through another crate behaves +// the same way as using an item directly +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub use lint_stability_reexport::unstable_text; + +// Ensure items which aren't marked as unstable can't re-export unstable items +#[stable(feature = "lint_stability", since = "1.0.0")] +pub use lint_stability::unstable as unstable2; +//~^ ERROR use of unstable library feature 'unstable_test_feature' + +fn main() { + // Since we didn't enable the feature in this crate, we still can't + // use these items, even though they're in scope from the `use`s which are now allowed. + unstable(); //~ ERROR use of unstable library feature 'unstable_test_feature' + unstable_text(); //~ ERROR use of unstable library feature 'unstable_test_feature' +} diff --git a/tests/ui/stability-attribute/allow-unstable-reexport.stderr b/tests/ui/stability-attribute/allow-unstable-reexport.stderr new file mode 100644 index 000000000..a11da9dc8 --- /dev/null +++ b/tests/ui/stability-attribute/allow-unstable-reexport.stderr @@ -0,0 +1,27 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/allow-unstable-reexport.rs:22:9 + | +LL | pub use lint_stability::unstable as unstable2; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/allow-unstable-reexport.rs:28:5 + | +LL | unstable(); + | ^^^^^^^^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/allow-unstable-reexport.rs:29:5 + | +LL | unstable_text(); + | ^^^^^^^^^^^^^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/allowed-through-unstable.rs b/tests/ui/stability-attribute/allowed-through-unstable.rs new file mode 100644 index 000000000..ff0228e4d --- /dev/null +++ b/tests/ui/stability-attribute/allowed-through-unstable.rs @@ -0,0 +1,9 @@ +// Test for new `#[rustc_allowed_through_unstable_modules]` attribute +// +// aux-build:allowed-through-unstable-core.rs +#![crate_type = "lib"] + +extern crate allowed_through_unstable_core; + +use allowed_through_unstable_core::unstable_module::OldStableTraitAllowedThoughUnstable; +use allowed_through_unstable_core::unstable_module::NewStableTraitNotAllowedThroughUnstable; //~ ERROR use of unstable library feature 'unstable_test_feature' diff --git a/tests/ui/stability-attribute/allowed-through-unstable.stderr b/tests/ui/stability-attribute/allowed-through-unstable.stderr new file mode 100644 index 000000000..132c00b89 --- /dev/null +++ b/tests/ui/stability-attribute/allowed-through-unstable.stderr @@ -0,0 +1,12 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/allowed-through-unstable.rs:9:5 + | +LL | use allowed_through_unstable_core::unstable_module::NewStableTraitNotAllowedThroughUnstable; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #1 for more information + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/auxiliary/allowed-through-unstable-core.rs b/tests/ui/stability-attribute/auxiliary/allowed-through-unstable-core.rs new file mode 100644 index 000000000..b597009a3 --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/allowed-through-unstable-core.rs @@ -0,0 +1,14 @@ +#![crate_type = "lib"] +#![feature(staged_api)] +#![feature(rustc_attrs)] +#![stable(feature = "stable_test_feature", since = "1.2.0")] + +#[unstable(feature = "unstable_test_feature", issue = "1")] +pub mod unstable_module { + #[stable(feature = "stable_test_feature", since = "1.2.0")] + #[rustc_allowed_through_unstable_modules] + pub trait OldStableTraitAllowedThoughUnstable {} + + #[stable(feature = "stable_test_feature", since = "1.2.0")] + pub trait NewStableTraitNotAllowedThroughUnstable {} +} diff --git a/tests/ui/stability-attribute/auxiliary/ctor-stability.rs b/tests/ui/stability-attribute/auxiliary/ctor-stability.rs new file mode 100644 index 000000000..74c6023d7 --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/ctor-stability.rs @@ -0,0 +1,8 @@ +#![crate_type = "lib"] +#![feature(staged_api)] +#![stable(feature = "none", since = "1.0")] + +#[stable(feature = "none", since = "1.0")] +pub enum Foo { + A, +} diff --git a/tests/ui/stability-attribute/auxiliary/default_body.rs b/tests/ui/stability-attribute/auxiliary/default_body.rs new file mode 100644 index 000000000..3a177419d --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/default_body.rs @@ -0,0 +1,29 @@ +#![crate_type = "lib"] +#![feature(staged_api, rustc_attrs)] +#![stable(feature = "stable_feature", since = "1.0.0")] + +#[stable(feature = "stable_feature", since = "1.0.0")] +pub trait JustTrait { + #[stable(feature = "stable_feature", since = "1.0.0")] + #[rustc_default_body_unstable(feature = "constant_default_body", issue = "none")] + const CONSTANT: usize = 0; + + #[rustc_default_body_unstable(feature = "fun_default_body", issue = "none")] + #[stable(feature = "stable_feature", since = "1.0.0")] + fn fun() {} +} + +#[rustc_must_implement_one_of(eq, neq)] +#[stable(feature = "stable_feature", since = "1.0.0")] +pub trait Equal { + #[rustc_default_body_unstable(feature = "eq_default_body", issue = "none")] + #[stable(feature = "stable_feature", since = "1.0.0")] + fn eq(&self, other: &Self) -> bool { + !self.neq(other) + } + + #[stable(feature = "stable_feature", since = "1.0.0")] + fn neq(&self, other: &Self) -> bool { + !self.eq(other) + } +} diff --git a/tests/ui/stability-attribute/auxiliary/lint-stability-reexport.rs b/tests/ui/stability-attribute/auxiliary/lint-stability-reexport.rs new file mode 100644 index 000000000..9884731d5 --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/lint-stability-reexport.rs @@ -0,0 +1,9 @@ +#![crate_type = "lib"] +#![feature(staged_api)] +#![stable(feature = "lint_stability", since = "1.0.0")] + +extern crate lint_stability; + +// Re-exporting without enabling the feature "unstable_test_feature" in this crate +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub use lint_stability::unstable_text; diff --git a/tests/ui/stability-attribute/auxiliary/lint-stability.rs b/tests/ui/stability-attribute/auxiliary/lint-stability.rs new file mode 100644 index 000000000..99c29dcdd --- /dev/null +++ b/tests/ui/stability-attribute/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/tests/ui/stability-attribute/auxiliary/stability-attribute-implies.rs b/tests/ui/stability-attribute/auxiliary/stability-attribute-implies.rs new file mode 100644 index 000000000..468be1bc1 --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/stability-attribute-implies.rs @@ -0,0 +1,8 @@ +#![feature(staged_api)] +#![stable(feature = "stability_attribute_implies", since = "1.0.0")] + +#[stable(feature = "foo", since = "1.62.0")] +pub fn foo() {} + +#[unstable(feature = "foobar", issue = "1", implied_by = "foo")] +pub fn foobar() {} diff --git a/tests/ui/stability-attribute/auxiliary/stability_attribute_issue.rs b/tests/ui/stability-attribute/auxiliary/stability_attribute_issue.rs new file mode 100644 index 000000000..4e5333289 --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/stability_attribute_issue.rs @@ -0,0 +1,9 @@ +#![feature(staged_api)] +#![stable(feature = "stable_test_feature", since = "1.2.0")] + + +#[unstable(feature = "unstable_test_feature", issue = "1")] +pub fn unstable() {} + +#[unstable(feature = "unstable_test_feature", reason = "message", issue = "2")] +pub fn unstable_msg() {} diff --git a/tests/ui/stability-attribute/auxiliary/stable-in-unstable-core.rs b/tests/ui/stability-attribute/auxiliary/stable-in-unstable-core.rs new file mode 100644 index 000000000..e45b00f99 --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/stable-in-unstable-core.rs @@ -0,0 +1,8 @@ +#![feature(staged_api)] +#![stable(feature = "stable_test_feature", since = "1.2.0")] + +#[unstable(feature = "unstable_test_feature", issue = "1")] +pub mod new_unstable_module { + #[stable(feature = "stable_test_feature", since = "1.2.0")] + pub trait OldTrait {} +} diff --git a/tests/ui/stability-attribute/auxiliary/stable-in-unstable-std.rs b/tests/ui/stability-attribute/auxiliary/stable-in-unstable-std.rs new file mode 100644 index 000000000..28ad8c28d --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/stable-in-unstable-std.rs @@ -0,0 +1,11 @@ +#![feature(staged_api)] +#![feature(unstable_test_feature)] +#![stable(feature = "stable_test_feature", since = "1.2.0")] + +extern crate stable_in_unstable_core; + +#[stable(feature = "stable_test_feature", since = "1.2.0")] +pub mod old_stable_module { + #[stable(feature = "stable_test_feature", since = "1.2.0")] + pub use stable_in_unstable_core::new_unstable_module::OldTrait; +} diff --git a/tests/ui/stability-attribute/auxiliary/unstable_generic_param.rs b/tests/ui/stability-attribute/auxiliary/unstable_generic_param.rs new file mode 100644 index 000000000..1d6a6bd4e --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/unstable_generic_param.rs @@ -0,0 +1,229 @@ +#![crate_type = "lib"] +#![feature(staged_api)] +#![stable(feature = "stable_test_feature", since = "1.0.0")] + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub trait Trait1<#[unstable(feature = "unstable_default", issue = "none")] T = ()> { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + fn foo() -> T; +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub trait Trait2<#[unstable(feature = "unstable_default", issue = "none")] T = usize> { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + fn foo() -> T; +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub trait Trait3 { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + fn foo() -> T; +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct Struct1<#[unstable(feature = "unstable_default", issue = "none")] T = usize> { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub field: T, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct Struct2 { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub field: T, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct Struct3 { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub field1: A, + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub field2: B, +} + +#[deprecated(since = "1.1.0", note = "test")] +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct Struct4 { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub field: A, +} + +#[deprecated(since = "1.1.0", note = "test")] +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct Struct5<#[unstable(feature = "unstable_default", issue = "none")] A = usize> { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub field: A, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct Struct6<#[unstable(feature = "unstable_default6", issue = "none")] T = usize> { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub field: T, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const STRUCT1: Struct1 = Struct1 { field: 1 }; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const STRUCT2: Struct2 = Struct2 { field: 1 }; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const STRUCT3: Struct3 = Struct3 { field1: 1, field2: 2 }; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const STRUCT4: Struct4 = Struct4 { field: 1 }; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const STRUCT5: Struct5 = Struct5 { field: 1 }; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub enum Enum1<#[unstable(feature = "unstable_default", issue = "none")] T = usize> { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + Some(#[stable(feature = "stable_test_feature", since = "1.0.0")] T), + #[stable(feature = "stable_test_feature", since = "1.0.0")] + None, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub enum Enum2 { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + Some(#[stable(feature = "stable_test_feature", since = "1.0.0")] T), + #[stable(feature = "stable_test_feature", since = "1.0.0")] + None, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub enum Enum3 { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + Ok(#[stable(feature = "stable_test_feature", since = "1.0.0")] T), + #[stable(feature = "stable_test_feature", since = "1.0.0")] + Err(#[stable(feature = "stable_test_feature", since = "1.0.0")] E), +} + +#[deprecated(since = "1.1.0", note = "test")] +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub enum Enum4 { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + Some(#[stable(feature = "stable_test_feature", since = "1.0.0")] T), + #[stable(feature = "stable_test_feature", since = "1.0.0")] + None, +} + +#[deprecated(since = "1.1.0", note = "test")] +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub enum Enum5<#[unstable(feature = "unstable_default", issue = "none")] T = usize> { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + Some(#[stable(feature = "stable_test_feature", since = "1.0.0")] T), + #[stable(feature = "stable_test_feature", since = "1.0.0")] + None, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub enum Enum6<#[unstable(feature = "unstable_default6", issue = "none")] T = usize> { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + Some(#[stable(feature = "stable_test_feature", since = "1.0.0")] T), + #[stable(feature = "stable_test_feature", since = "1.0.0")] + None, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ENUM1: Enum1 = Enum1::Some(1); + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ENUM2: Enum2 = Enum2::Some(1); + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ENUM3: Enum3 = Enum3::Ok(1); +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ENUM3B: Enum3 = Enum3::Err(1); + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ENUM4: Enum4 = Enum4::Some(1); + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ENUM5: Enum5 = Enum5::Some(1); + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub type Alias1<#[unstable(feature = "unstable_default", issue = "none")] T = usize> = Option; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub type Alias2 = Option; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub type Alias3 = + Result; + +#[deprecated(since = "1.1.0", note = "test")] +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub type Alias4 = Option; + +#[deprecated(since = "1.1.0", note = "test")] +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub type Alias5<#[unstable(feature = "unstable_default", issue = "none")] T = usize> = Option; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub type Alias6<#[unstable(feature = "unstable_default6", issue = "none")] T = usize> = Option; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ALIAS1: Alias1 = Alias1::Some(1); + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ALIAS2: Alias2 = Alias2::Some(1); + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ALIAS3: Alias3 = Alias3::Ok(1); +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ALIAS3B: Alias3 = Alias3::Err(1); + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ALIAS4: Alias4 = Alias4::Some(1); + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub const ALIAS5: Alias5 = Alias5::Some(1); + + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub trait Alloc {} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct System {} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +impl Alloc for System {} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct Box1 { + ptr: *mut T, + alloc: A, +} + +impl Box1 { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub fn new(mut t: T) -> Self { + unsafe { Self { ptr: &mut t, alloc: System {} } } + } +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct Box2 { + ptr: *mut T, + alloc: A, +} + +impl Box2 { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub fn new(mut t: T) -> Self { + Self { ptr: &mut t, alloc: System {} } + } +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub struct Box3 { + ptr: *mut T, +} + +impl Box3 { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub fn new(mut t: T) -> Self { + Self { ptr: &mut t } + } +} diff --git a/tests/ui/stability-attribute/ctor-stability.rs b/tests/ui/stability-attribute/ctor-stability.rs new file mode 100644 index 000000000..fcab0cb10 --- /dev/null +++ b/tests/ui/stability-attribute/ctor-stability.rs @@ -0,0 +1,8 @@ +// aux-build:ctor-stability.rs +// check-pass + +extern crate ctor_stability; + +fn main() { + let _ = ctor_stability::Foo::A; +} diff --git a/tests/ui/stability-attribute/default-body-stability-err.rs b/tests/ui/stability-attribute/default-body-stability-err.rs new file mode 100644 index 000000000..ecb281bcc --- /dev/null +++ b/tests/ui/stability-attribute/default-body-stability-err.rs @@ -0,0 +1,19 @@ +// aux-build:default_body.rs +#![crate_type = "lib"] + +extern crate default_body; + +use default_body::{Equal, JustTrait}; + +struct Type; + +impl JustTrait for Type {} +//~^ ERROR not all trait items implemented, missing: `CONSTANT` [E0046] +//~| ERROR not all trait items implemented, missing: `fun` [E0046] + +impl Equal for Type { + //~^ ERROR not all trait items implemented, missing: `eq` [E0046] + fn neq(&self, other: &Self) -> bool { + false + } +} diff --git a/tests/ui/stability-attribute/default-body-stability-err.stderr b/tests/ui/stability-attribute/default-body-stability-err.stderr new file mode 100644 index 000000000..ef666f30f --- /dev/null +++ b/tests/ui/stability-attribute/default-body-stability-err.stderr @@ -0,0 +1,38 @@ +error[E0046]: not all trait items implemented, missing: `CONSTANT` + --> $DIR/default-body-stability-err.rs:10:1 + | +LL | impl JustTrait for Type {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: default implementation of `CONSTANT` is unstable + = note: use of unstable library feature 'constant_default_body' + = help: add `#![feature(constant_default_body)]` to the crate attributes to enable + +error[E0046]: not all trait items implemented, missing: `fun` + --> $DIR/default-body-stability-err.rs:10:1 + | +LL | impl JustTrait for Type {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: default implementation of `fun` is unstable + = note: use of unstable library feature 'fun_default_body' + = help: add `#![feature(fun_default_body)]` to the crate attributes to enable + +error[E0046]: not all trait items implemented, missing: `eq` + --> $DIR/default-body-stability-err.rs:14:1 + | +LL | / impl Equal for Type { +LL | | +LL | | fn neq(&self, other: &Self) -> bool { +LL | | false +LL | | } +LL | | } + | |_^ + | + = note: default implementation of `eq` is unstable + = note: use of unstable library feature 'eq_default_body' + = help: add `#![feature(eq_default_body)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/stability-attribute/default-body-stability-ok-enables.rs b/tests/ui/stability-attribute/default-body-stability-ok-enables.rs new file mode 100644 index 000000000..bdc7522f4 --- /dev/null +++ b/tests/ui/stability-attribute/default-body-stability-ok-enables.rs @@ -0,0 +1,18 @@ +// check-pass +// aux-build:default_body.rs +#![crate_type = "lib"] +#![feature(fun_default_body, eq_default_body, constant_default_body)] + +extern crate default_body; + +use default_body::{Equal, JustTrait}; + +struct Type; + +impl JustTrait for Type {} + +impl Equal for Type { + fn neq(&self, other: &Self) -> bool { + false + } +} diff --git a/tests/ui/stability-attribute/default-body-stability-ok-impls.rs b/tests/ui/stability-attribute/default-body-stability-ok-impls.rs new file mode 100644 index 000000000..e1f5c0170 --- /dev/null +++ b/tests/ui/stability-attribute/default-body-stability-ok-impls.rs @@ -0,0 +1,21 @@ +// check-pass +// aux-build:default_body.rs +#![crate_type = "lib"] + +extern crate default_body; + +use default_body::{Equal, JustTrait}; + +struct Type; + +impl JustTrait for Type { + const CONSTANT: usize = 1; + + fn fun() {} +} + +impl Equal for Type { + fn eq(&self, other: &Self) -> bool { + false + } +} diff --git a/tests/ui/stability-attribute/generics-default-stability-trait.rs b/tests/ui/stability-attribute/generics-default-stability-trait.rs new file mode 100644 index 000000000..d436088e4 --- /dev/null +++ b/tests/ui/stability-attribute/generics-default-stability-trait.rs @@ -0,0 +1,33 @@ +// aux-build:unstable_generic_param.rs +#![feature(unstable_default6)] + +extern crate unstable_generic_param; + +use unstable_generic_param::*; + +struct R; + +impl Trait1 for S { + fn foo() -> () { () } // ok +} + +struct S; + +impl Trait1 for S { //~ ERROR use of unstable library feature 'unstable_default' + fn foo() -> usize { 0 } +} + +impl Trait1 for S { //~ ERROR use of unstable library feature 'unstable_default' + fn foo() -> isize { 0 } +} + +impl Trait2 for S { //~ ERROR use of unstable library feature 'unstable_default' + fn foo() -> usize { 0 } +} + +impl Trait3 for S { + fn foo() -> usize { 0 } // ok +} + +fn main() { +} diff --git a/tests/ui/stability-attribute/generics-default-stability-trait.stderr b/tests/ui/stability-attribute/generics-default-stability-trait.stderr new file mode 100644 index 000000000..03e61b78e --- /dev/null +++ b/tests/ui/stability-attribute/generics-default-stability-trait.stderr @@ -0,0 +1,27 @@ +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability-trait.rs:16:13 + | +LL | impl Trait1 for S { + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability-trait.rs:20:13 + | +LL | impl Trait1 for S { + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability-trait.rs:24:13 + | +LL | impl Trait2 for S { + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/generics-default-stability-where.rs b/tests/ui/stability-attribute/generics-default-stability-where.rs new file mode 100644 index 000000000..4afbca262 --- /dev/null +++ b/tests/ui/stability-attribute/generics-default-stability-where.rs @@ -0,0 +1,11 @@ +// aux-build:unstable_generic_param.rs + +extern crate unstable_generic_param; + +use unstable_generic_param::*; + +impl Trait3 for T where T: Trait2 { //~ ERROR use of unstable library feature 'unstable_default' + fn foo() -> usize { T::foo() } +} + +fn main() {} diff --git a/tests/ui/stability-attribute/generics-default-stability-where.stderr b/tests/ui/stability-attribute/generics-default-stability-where.stderr new file mode 100644 index 000000000..61253adc8 --- /dev/null +++ b/tests/ui/stability-attribute/generics-default-stability-where.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability-where.rs:7:45 + | +LL | impl Trait3 for T where T: Trait2 { + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/generics-default-stability.rs b/tests/ui/stability-attribute/generics-default-stability.rs new file mode 100644 index 000000000..300cc34d6 --- /dev/null +++ b/tests/ui/stability-attribute/generics-default-stability.rs @@ -0,0 +1,251 @@ +// aux-build:unstable_generic_param.rs +#![feature(unstable_default6)] + +extern crate unstable_generic_param; + +use unstable_generic_param::*; + +struct R; + +impl Trait1 for S { + fn foo() -> () { () } // ok +} + +struct S; + +impl Trait3 for S { + fn foo() -> usize { 0 } // ok +} + +fn main() { + let _ = S; + + let _: Struct1 = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default' + + let _ = STRUCT1; // ok + let _: Struct1 = STRUCT1; // ok + let _: Struct1 = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default' + let _: Struct1 = Struct1 { field: 0 }; //~ ERROR use of unstable library feature 'unstable_default' + + // Instability is not enforced for generic type parameters used in public fields. + // Note how the unstable type default `usize` leaks, + // and can be used without the 'unstable_default' feature. + let _ = STRUCT1.field; + let _ = Struct1 { field: 1 }; + let _ = Struct1 { field: () }; + let _ = Struct1 { field: 1isize }; + let _: Struct1 = Struct1 { field: 1 }; + let _: usize = STRUCT1.field; + let _ = STRUCT1.field + 1; + let _ = STRUCT1.field + 1usize; + + let _ = Struct2 { field: 1 }; // ok + let _: Struct2 = Struct2 { field: 1 }; // ok + let _: Struct2 = Struct2 { field: 1 }; // ok + + let _ = STRUCT2; + let _: Struct2 = STRUCT2; // ok + let _: Struct2 = STRUCT2; // ok + let _: Struct2 = Struct2 { field: 0 }; // ok + let _ = STRUCT2.field; // ok + let _: usize = STRUCT2.field; // ok + let _ = STRUCT2.field + 1; // ok + let _ = STRUCT2.field + 1usize; // ok + + let _ = STRUCT3; + let _: Struct3 = STRUCT3; // ok + let _: Struct3 = STRUCT3; //~ ERROR use of unstable library feature 'unstable_default' + let _: Struct3 = STRUCT3; // ok + let _: Struct3 = Struct3 { field1: 0, field2: 0 }; //~ ERROR use of unstable library feature 'unstable_default' + let _: Struct3 = Struct3 { field1: 0, field2: 0 }; //~ ERROR use of unstable library feature 'unstable_default' + let _ = STRUCT3.field1; // ok + let _: isize = STRUCT3.field1; // ok + let _ = STRUCT3.field1 + 1; // ok + // Note the aforementioned leak. + let _: usize = STRUCT3.field2; // ok + let _: Struct3 = Struct3 { field1: 0, field2: 0 }; // ok + let _ = STRUCT3.field2 + 1; // ok + let _ = STRUCT3.field2 + 1usize; // ok + + let _ = STRUCT4; + let _: Struct4 = Struct4 { field: 1 }; + //~^ use of deprecated struct `unstable_generic_param::Struct4`: test [deprecated] + //~^^ use of deprecated struct `unstable_generic_param::Struct4`: test [deprecated] + //~^^^ use of deprecated field `unstable_generic_param::Struct4::field`: test [deprecated] + let _ = STRUCT4; + let _: Struct4 = STRUCT4; //~ use of deprecated struct `unstable_generic_param::Struct4`: test [deprecated] + let _: Struct4 = STRUCT4; //~ use of deprecated struct `unstable_generic_param::Struct4`: test [deprecated] + let _: Struct4 = Struct4 { field: 0 }; + //~^ use of deprecated struct `unstable_generic_param::Struct4`: test [deprecated] + //~^^ use of deprecated struct `unstable_generic_param::Struct4`: test [deprecated] + //~^^^ use of deprecated field `unstable_generic_param::Struct4::field`: test [deprecated] + + let _ = STRUCT5; + let _: Struct5 = Struct5 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default' + //~^ use of deprecated struct `unstable_generic_param::Struct5`: test [deprecated] + //~^^ use of deprecated struct `unstable_generic_param::Struct5`: test [deprecated] + //~^^^ use of deprecated field `unstable_generic_param::Struct5::field`: test [deprecated] + let _ = STRUCT5; + let _: Struct5 = STRUCT5; //~ use of deprecated struct `unstable_generic_param::Struct5`: test [deprecated] + let _: Struct5 = STRUCT5; //~ ERROR use of unstable library feature 'unstable_default' + //~^ use of deprecated struct `unstable_generic_param::Struct5`: test [deprecated] + let _: Struct5 = Struct5 { field: 0 }; //~ ERROR use of unstable library feature 'unstable_default' + //~^ use of deprecated struct `unstable_generic_param::Struct5`: test [deprecated] + //~^^ use of deprecated struct `unstable_generic_param::Struct5`: test [deprecated] + //~^^^ use of deprecated field `unstable_generic_param::Struct5::field`: test [deprecated] + + let _: Struct6 = Struct6 { field: 1 }; // ok + let _: Struct6 = Struct6 { field: 0 }; // ok + + let _: Alias1 = Alias1::Some(1); //~ ERROR use of unstable library feature 'unstable_default' + + let _ = ALIAS1; // ok + let _: Alias1 = ALIAS1; // ok + let _: Alias1 = ALIAS1; //~ ERROR use of unstable library feature 'unstable_default' + let _: Alias1 = Alias1::Some(0); //~ ERROR use of unstable library feature 'unstable_default' + + // Instability is not enforced for generic type parameters used in public fields. + // Note how the unstable type default `usize` leaks, + // and can be used without the 'unstable_default' feature. + let _ = Alias1::Some(1); + let _ = Alias1::Some(()); + let _ = Alias1::Some(1isize); + let _: Alias1 = Alias1::Some(1); + let _: usize = ALIAS1.unwrap(); + let _ = ALIAS1.unwrap() + 1; + let _ = ALIAS1.unwrap() + 1usize; + + let _ = Alias2::Some(1); // ok + let _: Alias2 = Alias2::Some(1); // ok + let _: Alias2 = Alias2::Some(1); // ok + + let _ = ALIAS2; + let _: Alias2 = ALIAS2; // ok + let _: Alias2 = ALIAS2; // ok + let _: Alias2 = Alias2::Some(0); // ok + let _ = ALIAS2.unwrap(); // ok + let _: usize = ALIAS2.unwrap(); // ok + let _ = ALIAS2.unwrap() + 1; // ok + let _ = ALIAS2.unwrap() + 1usize; // ok + + let _ = ALIAS3; + let _: Alias3 = ALIAS3; // ok + let _: Alias3 = ALIAS3; //~ ERROR use of unstable library feature 'unstable_default' + let _: Alias3 = ALIAS3; // ok + let _: Alias3 = Alias3::Ok(0); //~ ERROR use of unstable library feature 'unstable_default' + let _: Alias3 = Alias3::Ok(0); //~ ERROR use of unstable library feature 'unstable_default' + let _ = ALIAS3.unwrap(); // ok + let _: isize = ALIAS3.unwrap(); // ok + let _ = ALIAS3.unwrap() + 1; // ok + // Note the aforementioned leak. + let _: usize = ALIAS3B.unwrap_err(); // ok + let _: Alias3 = Alias3::Err(0); // ok + let _ = ALIAS3B.unwrap_err() + 1; // ok + let _ = ALIAS3B.unwrap_err() + 1usize; // ok + + let _ = ALIAS4; + let _: Alias4 = Alias4::Some(1); + //~^ use of deprecated type alias `unstable_generic_param::Alias4`: test [deprecated] + //~^^ use of deprecated type alias `unstable_generic_param::Alias4`: test [deprecated] + let _ = ALIAS4; + let _: Alias4 = ALIAS4; //~ use of deprecated type alias `unstable_generic_param::Alias4`: test [deprecated] + let _: Alias4 = ALIAS4; //~ use of deprecated type alias `unstable_generic_param::Alias4`: test [deprecated] + let _: Alias4 = Alias4::Some(0); + //~^ use of deprecated type alias `unstable_generic_param::Alias4`: test [deprecated] + //~^^ use of deprecated type alias `unstable_generic_param::Alias4`: test [deprecated] + + let _ = ALIAS5; + let _: Alias5 = Alias5::Some(1); //~ ERROR use of unstable library feature 'unstable_default' + //~^ use of deprecated type alias `unstable_generic_param::Alias5`: test [deprecated] + //~^^ use of deprecated type alias `unstable_generic_param::Alias5`: test [deprecated] + let _ = ALIAS5; + let _: Alias5 = ALIAS5; //~ use of deprecated type alias `unstable_generic_param::Alias5`: test [deprecated] + let _: Alias5 = ALIAS5; //~ ERROR use of unstable library feature 'unstable_default' + //~^ use of deprecated type alias `unstable_generic_param::Alias5`: test [deprecated] + let _: Alias5 = Alias5::Some(0); //~ ERROR use of unstable library feature 'unstable_default' + //~^ use of deprecated type alias `unstable_generic_param::Alias5`: test [deprecated] + //~^^ use of deprecated type alias `unstable_generic_param::Alias5`: test [deprecated] + + let _: Alias6 = Alias6::Some(1); // ok + let _: Alias6 = Alias6::Some(0); // ok + + let _: Enum1 = Enum1::Some(1); //~ ERROR use of unstable library feature 'unstable_default' + + let _ = ENUM1; // ok + let _: Enum1 = ENUM1; // ok + let _: Enum1 = ENUM1; //~ ERROR use of unstable library feature 'unstable_default' + let _: Enum1 = Enum1::Some(0); //~ ERROR use of unstable library feature 'unstable_default' + + // Instability is not enforced for generic type parameters used in public fields. + // Note how the unstable type default `usize` leaks, + // and can be used without the 'unstable_default' feature. + let _ = Enum1::Some(1); + let _ = Enum1::Some(()); + let _ = Enum1::Some(1isize); + let _: Enum1 = Enum1::Some(1); + if let Enum1::Some(x) = ENUM1 {let _: usize = x;} + if let Enum1::Some(x) = ENUM1 {let _ = x + 1;} + if let Enum1::Some(x) = ENUM1 {let _ = x + 1usize;} + + let _ = Enum2::Some(1); // ok + let _: Enum2 = Enum2::Some(1); // ok + let _: Enum2 = Enum2::Some(1); // ok + + let _ = ENUM2; + let _: Enum2 = ENUM2; // ok + let _: Enum2 = ENUM2; // ok + let _: Enum2 = Enum2::Some(0); // ok + if let Enum2::Some(x) = ENUM2 {let _ = x;} // ok + if let Enum2::Some(x) = ENUM2 {let _: usize = x;} // ok + if let Enum2::Some(x) = ENUM2 {let _ = x + 1;} // ok + if let Enum2::Some(x) = ENUM2 {let _ = x + 1usize;} // ok + + let _ = ENUM3; + let _: Enum3 = ENUM3; // ok + let _: Enum3 = ENUM3; //~ ERROR use of unstable library feature 'unstable_default' + let _: Enum3 = ENUM3; // ok + let _: Enum3 = Enum3::Ok(0); //~ ERROR use of unstable library feature 'unstable_default' + let _: Enum3 = Enum3::Ok(0); //~ ERROR use of unstable library feature 'unstable_default' + if let Enum3::Ok(x) = ENUM3 {let _ = x;} // ok + if let Enum3::Ok(x) = ENUM3 {let _: isize = x;} // ok + if let Enum3::Ok(x) = ENUM3 {let _ = x + 1;} // ok + // Note the aforementioned leak. + if let Enum3::Err(x) = ENUM3B {let _: usize = x;} // ok + let _: Enum3 = Enum3::Err(0); // ok + if let Enum3::Err(x) = ENUM3B {let _ = x + 1;} // ok + if let Enum3::Err(x) = ENUM3B {let _ = x + 1usize;} // ok + + let _ = ENUM4; + let _: Enum4 = Enum4::Some(1); + //~^ use of deprecated tuple variant `unstable_generic_param::Enum4::Some`: test [deprecated] + //~^^ use of deprecated enum `unstable_generic_param::Enum4`: test [deprecated] + let _ = ENUM4; + let _: Enum4 = ENUM4; //~ use of deprecated enum `unstable_generic_param::Enum4`: test [deprecated] + let _: Enum4 = ENUM4; //~ use of deprecated enum `unstable_generic_param::Enum4`: test [deprecated] + let _: Enum4 = Enum4::Some(0); + //~^ use of deprecated tuple variant `unstable_generic_param::Enum4::Some`: test [deprecated] + //~^^ use of deprecated enum `unstable_generic_param::Enum4`: test [deprecated] + + let _ = ENUM5; + let _: Enum5 = Enum5::Some(1); //~ ERROR use of unstable library feature 'unstable_default' + //~^ use of deprecated tuple variant `unstable_generic_param::Enum5::Some`: test [deprecated] + //~^^ use of deprecated enum `unstable_generic_param::Enum5`: test [deprecated] + let _ = ENUM5; + let _: Enum5 = ENUM5; //~ use of deprecated enum `unstable_generic_param::Enum5`: test [deprecated] + let _: Enum5 = ENUM5; //~ ERROR use of unstable library feature 'unstable_default' + //~^ use of deprecated enum `unstable_generic_param::Enum5`: test [deprecated] + let _: Enum5 = Enum5::Some(0); //~ ERROR use of unstable library feature 'unstable_default' + //~^ use of deprecated tuple variant `unstable_generic_param::Enum5::Some`: test [deprecated] + //~^^ use of deprecated enum `unstable_generic_param::Enum5`: test [deprecated] + + let _: Enum6 = Enum6::Some(1); // ok + let _: Enum6 = Enum6::Some(0); // ok + + let _: Box1 = Box1::new(1); //~ ERROR use of unstable library feature 'box_alloc_param' + let _: Box1 = Box1::new(1); // ok + + let _: Box2 = Box2::new(1); // ok + let _: Box2 = Box2::new(1); // ok + + let _: Box3 = Box3::new(1); // ok +} diff --git a/tests/ui/stability-attribute/generics-default-stability.stderr b/tests/ui/stability-attribute/generics-default-stability.stderr new file mode 100644 index 000000000..e094a10c8 --- /dev/null +++ b/tests/ui/stability-attribute/generics-default-stability.stderr @@ -0,0 +1,469 @@ +warning: use of deprecated struct `unstable_generic_param::Struct4`: test + --> $DIR/generics-default-stability.rs:71:29 + | +LL | let _: Struct4 = Struct4 { field: 1 }; + | ^^^^^^^ + | + = note: `#[warn(deprecated)]` on by default + +warning: use of deprecated struct `unstable_generic_param::Struct4`: test + --> $DIR/generics-default-stability.rs:71:12 + | +LL | let _: Struct4 = Struct4 { field: 1 }; + | ^^^^^^^ + +warning: use of deprecated struct `unstable_generic_param::Struct4`: test + --> $DIR/generics-default-stability.rs:76:12 + | +LL | let _: Struct4 = STRUCT4; + | ^^^^^^^ + +warning: use of deprecated struct `unstable_generic_param::Struct4`: test + --> $DIR/generics-default-stability.rs:77:12 + | +LL | let _: Struct4 = STRUCT4; + | ^^^^^^^ + +warning: use of deprecated struct `unstable_generic_param::Struct4`: test + --> $DIR/generics-default-stability.rs:78:29 + | +LL | let _: Struct4 = Struct4 { field: 0 }; + | ^^^^^^^ + +warning: use of deprecated struct `unstable_generic_param::Struct4`: test + --> $DIR/generics-default-stability.rs:78:12 + | +LL | let _: Struct4 = Struct4 { field: 0 }; + | ^^^^^^^ + +warning: use of deprecated struct `unstable_generic_param::Struct5`: test + --> $DIR/generics-default-stability.rs:84:29 + | +LL | let _: Struct5 = Struct5 { field: 1 }; + | ^^^^^^^ + +warning: use of deprecated struct `unstable_generic_param::Struct5`: test + --> $DIR/generics-default-stability.rs:84:12 + | +LL | let _: Struct5 = Struct5 { field: 1 }; + | ^^^^^^^ + +warning: use of deprecated struct `unstable_generic_param::Struct5`: test + --> $DIR/generics-default-stability.rs:89:12 + | +LL | let _: Struct5 = STRUCT5; + | ^^^^^^^ + +warning: use of deprecated struct `unstable_generic_param::Struct5`: test + --> $DIR/generics-default-stability.rs:90:12 + | +LL | let _: Struct5 = STRUCT5; + | ^^^^^^^ + +warning: use of deprecated struct `unstable_generic_param::Struct5`: test + --> $DIR/generics-default-stability.rs:92:29 + | +LL | let _: Struct5 = Struct5 { field: 0 }; + | ^^^^^^^ + +warning: use of deprecated struct `unstable_generic_param::Struct5`: test + --> $DIR/generics-default-stability.rs:92:12 + | +LL | let _: Struct5 = Struct5 { field: 0 }; + | ^^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias4`: test + --> $DIR/generics-default-stability.rs:147:28 + | +LL | let _: Alias4 = Alias4::Some(1); + | ^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias4`: test + --> $DIR/generics-default-stability.rs:147:12 + | +LL | let _: Alias4 = Alias4::Some(1); + | ^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias4`: test + --> $DIR/generics-default-stability.rs:151:12 + | +LL | let _: Alias4 = ALIAS4; + | ^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias4`: test + --> $DIR/generics-default-stability.rs:152:12 + | +LL | let _: Alias4 = ALIAS4; + | ^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias4`: test + --> $DIR/generics-default-stability.rs:153:28 + | +LL | let _: Alias4 = Alias4::Some(0); + | ^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias4`: test + --> $DIR/generics-default-stability.rs:153:12 + | +LL | let _: Alias4 = Alias4::Some(0); + | ^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias5`: test + --> $DIR/generics-default-stability.rs:158:28 + | +LL | let _: Alias5 = Alias5::Some(1); + | ^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias5`: test + --> $DIR/generics-default-stability.rs:158:12 + | +LL | let _: Alias5 = Alias5::Some(1); + | ^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias5`: test + --> $DIR/generics-default-stability.rs:162:12 + | +LL | let _: Alias5 = ALIAS5; + | ^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias5`: test + --> $DIR/generics-default-stability.rs:163:12 + | +LL | let _: Alias5 = ALIAS5; + | ^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias5`: test + --> $DIR/generics-default-stability.rs:165:28 + | +LL | let _: Alias5 = Alias5::Some(0); + | ^^^^^^ + +warning: use of deprecated type alias `unstable_generic_param::Alias5`: test + --> $DIR/generics-default-stability.rs:165:12 + | +LL | let _: Alias5 = Alias5::Some(0); + | ^^^^^^ + +warning: use of deprecated tuple variant `unstable_generic_param::Enum4::Some`: test + --> $DIR/generics-default-stability.rs:219:34 + | +LL | let _: Enum4 = Enum4::Some(1); + | ^^^^ + +warning: use of deprecated enum `unstable_generic_param::Enum4`: test + --> $DIR/generics-default-stability.rs:219:12 + | +LL | let _: Enum4 = Enum4::Some(1); + | ^^^^^ + +warning: use of deprecated enum `unstable_generic_param::Enum4`: test + --> $DIR/generics-default-stability.rs:223:12 + | +LL | let _: Enum4 = ENUM4; + | ^^^^^ + +warning: use of deprecated enum `unstable_generic_param::Enum4`: test + --> $DIR/generics-default-stability.rs:224:12 + | +LL | let _: Enum4 = ENUM4; + | ^^^^^ + +warning: use of deprecated tuple variant `unstable_generic_param::Enum4::Some`: test + --> $DIR/generics-default-stability.rs:225:34 + | +LL | let _: Enum4 = Enum4::Some(0); + | ^^^^ + +warning: use of deprecated enum `unstable_generic_param::Enum4`: test + --> $DIR/generics-default-stability.rs:225:12 + | +LL | let _: Enum4 = Enum4::Some(0); + | ^^^^^ + +warning: use of deprecated tuple variant `unstable_generic_param::Enum5::Some`: test + --> $DIR/generics-default-stability.rs:230:34 + | +LL | let _: Enum5 = Enum5::Some(1); + | ^^^^ + +warning: use of deprecated enum `unstable_generic_param::Enum5`: test + --> $DIR/generics-default-stability.rs:230:12 + | +LL | let _: Enum5 = Enum5::Some(1); + | ^^^^^ + +warning: use of deprecated enum `unstable_generic_param::Enum5`: test + --> $DIR/generics-default-stability.rs:234:12 + | +LL | let _: Enum5 = ENUM5; + | ^^^^^ + +warning: use of deprecated enum `unstable_generic_param::Enum5`: test + --> $DIR/generics-default-stability.rs:235:12 + | +LL | let _: Enum5 = ENUM5; + | ^^^^^ + +warning: use of deprecated tuple variant `unstable_generic_param::Enum5::Some`: test + --> $DIR/generics-default-stability.rs:237:34 + | +LL | let _: Enum5 = Enum5::Some(0); + | ^^^^ + +warning: use of deprecated enum `unstable_generic_param::Enum5`: test + --> $DIR/generics-default-stability.rs:237:12 + | +LL | let _: Enum5 = Enum5::Some(0); + | ^^^^^ + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:23:20 + | +LL | let _: Struct1 = Struct1 { field: 1 }; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:27:20 + | +LL | let _: Struct1 = STRUCT1; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:28:20 + | +LL | let _: Struct1 = Struct1 { field: 0 }; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:57:27 + | +LL | let _: Struct3 = STRUCT3; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:59:27 + | +LL | let _: Struct3 = Struct3 { field1: 0, field2: 0 }; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:60:27 + | +LL | let _: Struct3 = Struct3 { field1: 0, field2: 0 }; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:84:20 + | +LL | let _: Struct5 = Struct5 { field: 1 }; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:90:20 + | +LL | let _: Struct5 = STRUCT5; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:92:20 + | +LL | let _: Struct5 = Struct5 { field: 0 }; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:100:19 + | +LL | let _: Alias1 = Alias1::Some(1); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:104:19 + | +LL | let _: Alias1 = ALIAS1; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:105:19 + | +LL | let _: Alias1 = Alias1::Some(0); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:133:26 + | +LL | let _: Alias3 = ALIAS3; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:135:26 + | +LL | let _: Alias3 = Alias3::Ok(0); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:136:26 + | +LL | let _: Alias3 = Alias3::Ok(0); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:158:19 + | +LL | let _: Alias5 = Alias5::Some(1); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:163:19 + | +LL | let _: Alias5 = ALIAS5; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:165:19 + | +LL | let _: Alias5 = Alias5::Some(0); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:172:18 + | +LL | let _: Enum1 = Enum1::Some(1); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:176:18 + | +LL | let _: Enum1 = ENUM1; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:177:18 + | +LL | let _: Enum1 = Enum1::Some(0); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:205:25 + | +LL | let _: Enum3 = ENUM3; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:207:25 + | +LL | let _: Enum3 = Enum3::Ok(0); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:208:25 + | +LL | let _: Enum3 = Enum3::Ok(0); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:230:18 + | +LL | let _: Enum5 = Enum5::Some(1); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:235:18 + | +LL | let _: Enum5 = ENUM5; + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:237:18 + | +LL | let _: Enum5 = Enum5::Some(0); + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'box_alloc_param' + --> $DIR/generics-default-stability.rs:244:24 + | +LL | let _: Box1 = Box1::new(1); + | ^^^^^^ + | + = help: add `#![feature(box_alloc_param)]` to the crate attributes to enable + +warning: use of deprecated field `unstable_generic_param::Struct4::field`: test + --> $DIR/generics-default-stability.rs:71:39 + | +LL | let _: Struct4 = Struct4 { field: 1 }; + | ^^^^^^^^ + +warning: use of deprecated field `unstable_generic_param::Struct4::field`: test + --> $DIR/generics-default-stability.rs:78:39 + | +LL | let _: Struct4 = Struct4 { field: 0 }; + | ^^^^^^^^ + +warning: use of deprecated field `unstable_generic_param::Struct5::field`: test + --> $DIR/generics-default-stability.rs:84:39 + | +LL | let _: Struct5 = Struct5 { field: 1 }; + | ^^^^^^^^ + +warning: use of deprecated field `unstable_generic_param::Struct5::field`: test + --> $DIR/generics-default-stability.rs:92:39 + | +LL | let _: Struct5 = Struct5 { field: 0 }; + | ^^^^^^^^ + +error: aborting due to 28 previous errors; 40 warnings emitted + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/issue-106589.rs b/tests/ui/stability-attribute/issue-106589.rs new file mode 100644 index 000000000..3cad9a3d2 --- /dev/null +++ b/tests/ui/stability-attribute/issue-106589.rs @@ -0,0 +1,10 @@ +// #![feature(staged_api)] // note: `staged_api` not enabled + +#![stable(feature = "foo", since = "1.0.0")] +//~^ ERROR stability attributes may not be used outside of the standard library + +#[unstable(feature = "foo", issue = "none")] +//~^ ERROR stability attributes may not be used outside of the standard library +fn foo_unstable() {} + +fn main() {} diff --git a/tests/ui/stability-attribute/issue-106589.stderr b/tests/ui/stability-attribute/issue-106589.stderr new file mode 100644 index 000000000..ccf3f7164 --- /dev/null +++ b/tests/ui/stability-attribute/issue-106589.stderr @@ -0,0 +1,15 @@ +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-106589.rs:6:1 + | +LL | #[unstable(feature = "foo", issue = "none")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-106589.rs:3:1 + | +LL | #![stable(feature = "foo", since = "1.0.0")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0734`. diff --git a/tests/ui/stability-attribute/issue-28075.rs b/tests/ui/stability-attribute/issue-28075.rs new file mode 100644 index 000000000..6b4ea46f3 --- /dev/null +++ b/tests/ui/stability-attribute/issue-28075.rs @@ -0,0 +1,13 @@ +// Unstable entities should be caught in import lists + +// aux-build:lint-stability.rs + +#![allow(warnings)] + +extern crate lint_stability; + +use lint_stability::{unstable, deprecated}; +//~^ ERROR use of unstable library feature 'unstable_test_feature' + +fn main() { +} diff --git a/tests/ui/stability-attribute/issue-28075.stderr b/tests/ui/stability-attribute/issue-28075.stderr new file mode 100644 index 000000000..7e53bb544 --- /dev/null +++ b/tests/ui/stability-attribute/issue-28075.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/issue-28075.rs:9:22 + | +LL | use lint_stability::{unstable, deprecated}; + | ^^^^^^^^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/issue-28388-3.rs b/tests/ui/stability-attribute/issue-28388-3.rs new file mode 100644 index 000000000..7ba993501 --- /dev/null +++ b/tests/ui/stability-attribute/issue-28388-3.rs @@ -0,0 +1,11 @@ +// Prefix in imports with empty braces should be resolved and checked privacy, stability, etc. + +// aux-build:lint-stability.rs + +extern crate lint_stability; + +use lint_stability::UnstableEnum::{}; +//~^ ERROR use of unstable library feature 'unstable_test_feature' +use lint_stability::StableEnum::{}; // OK + +fn main() {} diff --git a/tests/ui/stability-attribute/issue-28388-3.stderr b/tests/ui/stability-attribute/issue-28388-3.stderr new file mode 100644 index 000000000..d2e46683b --- /dev/null +++ b/tests/ui/stability-attribute/issue-28388-3.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/issue-28388-3.rs:7:5 + | +LL | use lint_stability::UnstableEnum::{}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs b/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs new file mode 100644 index 000000000..b9eee9922 --- /dev/null +++ b/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs @@ -0,0 +1,17 @@ +// check-pass +// +// Regression test for issue #99286 +// Tests that stabilized intrinsics are accessible +// through 'std::intrinsics', even though the module +// is unstable. + +#![allow(unused_imports)] +#![allow(deprecated)] + +use std::intrinsics::drop_in_place as _; +use std::intrinsics::copy_nonoverlapping as _; +use std::intrinsics::copy as _; +use std::intrinsics::write_bytes as _; +use std::intrinsics::{drop_in_place, copy_nonoverlapping, copy, write_bytes}; + +fn main() {} diff --git a/tests/ui/stability-attribute/missing-const-stability.rs b/tests/ui/stability-attribute/missing-const-stability.rs new file mode 100644 index 000000000..6eff899bf --- /dev/null +++ b/tests/ui/stability-attribute/missing-const-stability.rs @@ -0,0 +1,33 @@ +#![feature(staged_api)] +#![feature(const_trait_impl)] +#![stable(feature = "stable", since = "1.0.0")] + +#[stable(feature = "stable", since = "1.0.0")] +pub const fn foo() {} //~ ERROR function has missing const stability attribute + +#[unstable(feature = "unstable", issue = "none")] +pub const fn bar() {} // ok because function is unstable + +#[stable(feature = "stable", since = "1.0.0")] +pub struct Foo; +impl Foo { + #[stable(feature = "stable", since = "1.0.0")] + pub const fn foo() {} //~ ERROR associated function has missing const stability attribute + + #[unstable(feature = "unstable", issue = "none")] + pub const fn bar() {} // ok because function is unstable +} + +#[stable(feature = "stable", since = "1.0.0")] +#[const_trait] +pub trait Bar { + #[stable(feature = "stable", since = "1.0.0")] + fn fun(); +} +#[stable(feature = "stable", since = "1.0.0")] +impl const Bar for Foo { + //~^ ERROR implementation has missing const stability attribute + fn fun() {} +} + +fn main() {} diff --git a/tests/ui/stability-attribute/missing-const-stability.stderr b/tests/ui/stability-attribute/missing-const-stability.stderr new file mode 100644 index 000000000..4cfbe1528 --- /dev/null +++ b/tests/ui/stability-attribute/missing-const-stability.stderr @@ -0,0 +1,23 @@ +error: function has missing const stability attribute + --> $DIR/missing-const-stability.rs:6:1 + | +LL | pub const fn foo() {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: implementation has missing const stability attribute + --> $DIR/missing-const-stability.rs:28:1 + | +LL | / impl const Bar for Foo { +LL | | +LL | | fn fun() {} +LL | | } + | |_^ + +error: associated function has missing const stability attribute + --> $DIR/missing-const-stability.rs:15:5 + | +LL | pub const fn foo() {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/stability-attribute/missing-stability-attr-at-top-level.rs b/tests/ui/stability-attribute/missing-stability-attr-at-top-level.rs new file mode 100644 index 000000000..38faa2469 --- /dev/null +++ b/tests/ui/stability-attribute/missing-stability-attr-at-top-level.rs @@ -0,0 +1,4 @@ +#![feature(staged_api)] +//~^ ERROR module has missing stability attribute + +fn main() {} diff --git a/tests/ui/stability-attribute/missing-stability-attr-at-top-level.stderr b/tests/ui/stability-attribute/missing-stability-attr-at-top-level.stderr new file mode 100644 index 000000000..c7ade234d --- /dev/null +++ b/tests/ui/stability-attribute/missing-stability-attr-at-top-level.stderr @@ -0,0 +1,11 @@ +error: module has missing stability attribute + --> $DIR/missing-stability-attr-at-top-level.rs:1:1 + | +LL | / #![feature(staged_api)] +LL | | +LL | | +LL | | fn main() {} + | |____________^ + +error: aborting due to previous error + diff --git a/tests/ui/stability-attribute/stability-attribute-implies-missing.rs b/tests/ui/stability-attribute/stability-attribute-implies-missing.rs new file mode 100644 index 000000000..613878536 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-implies-missing.rs @@ -0,0 +1,10 @@ +#![feature(staged_api)] +#![stable(feature = "stability_attribute_implies", since = "1.0.0")] + +// Tests that `implied_by = "bar"` results in an error being emitted if `bar` does not exist. + +#[unstable(feature = "foobar", issue = "1", implied_by = "bar")] +//~^ ERROR feature `bar` implying `foobar` does not exist +pub fn foobar() {} + +fn main() {} diff --git a/tests/ui/stability-attribute/stability-attribute-implies-missing.stderr b/tests/ui/stability-attribute/stability-attribute-implies-missing.stderr new file mode 100644 index 000000000..ff1856f17 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-implies-missing.stderr @@ -0,0 +1,8 @@ +error: feature `bar` implying `foobar` does not exist + --> $DIR/stability-attribute-implies-missing.rs:6:1 + | +LL | #[unstable(feature = "foobar", issue = "1", implied_by = "bar")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/stability-attribute/stability-attribute-implies-no-feature.rs b/tests/ui/stability-attribute/stability-attribute-implies-no-feature.rs new file mode 100644 index 000000000..947f9f73e --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-implies-no-feature.rs @@ -0,0 +1,13 @@ +// aux-build:stability-attribute-implies.rs + +// Tests that despite the `foobar` feature being implied by now-stable feature `foo`, if `foobar` +// isn't allowed in this crate then an error will be emitted. + +extern crate stability_attribute_implies; +use stability_attribute_implies::{foo, foobar}; +//~^ ERROR use of unstable library feature 'foobar' + +fn main() { + foo(); // no error - stable + foobar(); //~ ERROR use of unstable library feature 'foobar' +} diff --git a/tests/ui/stability-attribute/stability-attribute-implies-no-feature.stderr b/tests/ui/stability-attribute/stability-attribute-implies-no-feature.stderr new file mode 100644 index 000000000..c2331f676 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-implies-no-feature.stderr @@ -0,0 +1,21 @@ +error[E0658]: use of unstable library feature 'foobar' + --> $DIR/stability-attribute-implies-no-feature.rs:7:40 + | +LL | use stability_attribute_implies::{foo, foobar}; + | ^^^^^^ + | + = note: see issue #1 for more information + = help: add `#![feature(foobar)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'foobar' + --> $DIR/stability-attribute-implies-no-feature.rs:12:5 + | +LL | foobar(); + | ^^^^^^ + | + = note: see issue #1 for more information + = help: add `#![feature(foobar)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/stability-attribute-implies-using-stable.rs b/tests/ui/stability-attribute/stability-attribute-implies-using-stable.rs new file mode 100644 index 000000000..1a2d8e271 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-implies-using-stable.rs @@ -0,0 +1,15 @@ +// aux-build:stability-attribute-implies.rs +#![deny(stable_features)] +#![feature(foo)] +//~^ ERROR the feature `foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `foobar` + +// Tests that the use of `implied_by` in the `#[unstable]` attribute results in a diagnostic +// mentioning partial stabilization, and that given the implied unstable feature is unused (there +// is no `foobar` call), that the compiler suggests removing the flag. + +extern crate stability_attribute_implies; +use stability_attribute_implies::foo; + +fn main() { + foo(); +} diff --git a/tests/ui/stability-attribute/stability-attribute-implies-using-stable.stderr b/tests/ui/stability-attribute/stability-attribute-implies-using-stable.stderr new file mode 100644 index 000000000..c9b3f07cc --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-implies-using-stable.stderr @@ -0,0 +1,22 @@ +error: the feature `foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `foobar` + --> $DIR/stability-attribute-implies-using-stable.rs:3:12 + | +LL | #![feature(foo)] + | ^^^ + | +note: the lint level is defined here + --> $DIR/stability-attribute-implies-using-stable.rs:2:9 + | +LL | #![deny(stable_features)] + | ^^^^^^^^^^^^^^^ +help: if you are using features which are still unstable, change to using `foobar` + | +LL | #![feature(foobar)] + | ~~~~~~ +help: if you are using features which are now stable, remove this line + | +LL - #![feature(foo)] + | + +error: aborting due to previous error + diff --git a/tests/ui/stability-attribute/stability-attribute-implies-using-unstable.rs b/tests/ui/stability-attribute/stability-attribute-implies-using-unstable.rs new file mode 100644 index 000000000..3c73c5abf --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-implies-using-unstable.rs @@ -0,0 +1,17 @@ +// aux-build:stability-attribute-implies.rs +#![deny(stable_features)] +#![feature(foo)] +//~^ ERROR the feature `foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `foobar` + +// Tests that the use of `implied_by` in the `#[unstable]` attribute results in a diagnostic +// mentioning partial stabilization and that given the implied unstable feature is used (there is a +// `foobar` call), that the compiler suggests changing to that feature and doesn't error about its +// use. + +extern crate stability_attribute_implies; +use stability_attribute_implies::{foo, foobar}; + +fn main() { + foo(); + foobar(); // no error! +} diff --git a/tests/ui/stability-attribute/stability-attribute-implies-using-unstable.stderr b/tests/ui/stability-attribute/stability-attribute-implies-using-unstable.stderr new file mode 100644 index 000000000..9a5c7ef5a --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-implies-using-unstable.stderr @@ -0,0 +1,22 @@ +error: the feature `foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `foobar` + --> $DIR/stability-attribute-implies-using-unstable.rs:3:12 + | +LL | #![feature(foo)] + | ^^^ + | +note: the lint level is defined here + --> $DIR/stability-attribute-implies-using-unstable.rs:2:9 + | +LL | #![deny(stable_features)] + | ^^^^^^^^^^^^^^^ +help: if you are using features which are still unstable, change to using `foobar` + | +LL | #![feature(foobar)] + | ~~~~~~ +help: if you are using features which are now stable, remove this line + | +LL - #![feature(foo)] + | + +error: aborting due to previous error + diff --git a/tests/ui/stability-attribute/stability-attribute-issue-43027.rs b/tests/ui/stability-attribute/stability-attribute-issue-43027.rs new file mode 100644 index 000000000..3f4fdfd01 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-issue-43027.rs @@ -0,0 +1,15 @@ +// check-pass +#![feature(staged_api)] +#![stable(feature = "test", since = "0")] + +#[stable(feature = "test", since = "0")] +pub struct A(pub T); + +#[stable(feature = "test", since = "0")] +pub struct B(#[stable(feature = "test", since = "0")] pub T); + +fn main() { + // Make sure the field is used to fill the stability cache + A(0).0; + B(0).0; +} diff --git a/tests/ui/stability-attribute/stability-attribute-issue.rs b/tests/ui/stability-attribute/stability-attribute-issue.rs new file mode 100644 index 000000000..cda1aff13 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-issue.rs @@ -0,0 +1,12 @@ +// aux-build:stability_attribute_issue.rs +#![deny(deprecated)] + +extern crate stability_attribute_issue; +use stability_attribute_issue::*; + +fn main() { + unstable(); + //~^ ERROR use of unstable library feature 'unstable_test_feature' + unstable_msg(); + //~^ ERROR use of unstable library feature 'unstable_test_feature': message +} diff --git a/tests/ui/stability-attribute/stability-attribute-issue.stderr b/tests/ui/stability-attribute/stability-attribute-issue.stderr new file mode 100644 index 000000000..df4aec7e5 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-issue.stderr @@ -0,0 +1,21 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/stability-attribute-issue.rs:8:5 + | +LL | unstable(); + | ^^^^^^^^ + | + = note: see issue #1 for more information + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': message + --> $DIR/stability-attribute-issue.rs:10:5 + | +LL | unstable_msg(); + | ^^^^^^^^^^^^ + | + = note: see issue #2 for more information + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/stability-attribute-non-staged-force-unstable.rs b/tests/ui/stability-attribute/stability-attribute-non-staged-force-unstable.rs new file mode 100644 index 000000000..f61acc8aa --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-non-staged-force-unstable.rs @@ -0,0 +1,5 @@ +// compile-flags:-Zforce-unstable-if-unmarked + +#[unstable()] //~ ERROR: stability attributes may not be used +#[stable()] //~ ERROR: stability attributes may not be used +fn main() {} diff --git a/tests/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr b/tests/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr new file mode 100644 index 000000000..45d965ea0 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-non-staged-force-unstable.stderr @@ -0,0 +1,15 @@ +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/stability-attribute-non-staged-force-unstable.rs:3:1 + | +LL | #[unstable()] + | ^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/stability-attribute-non-staged-force-unstable.rs:4:1 + | +LL | #[stable()] + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0734`. diff --git a/tests/ui/stability-attribute/stability-attribute-non-staged.rs b/tests/ui/stability-attribute/stability-attribute-non-staged.rs new file mode 100644 index 000000000..4015f2f97 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-non-staged.rs @@ -0,0 +1,3 @@ +#[unstable()] //~ ERROR: stability attributes may not be used +#[stable()] //~ ERROR: stability attributes may not be used +fn main() {} diff --git a/tests/ui/stability-attribute/stability-attribute-non-staged.stderr b/tests/ui/stability-attribute/stability-attribute-non-staged.stderr new file mode 100644 index 000000000..391f3c274 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-non-staged.stderr @@ -0,0 +1,15 @@ +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/stability-attribute-non-staged.rs:1:1 + | +LL | #[unstable()] + | ^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/stability-attribute-non-staged.rs:2:1 + | +LL | #[stable()] + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0734`. diff --git a/tests/ui/stability-attribute/stability-attribute-sanity-2.rs b/tests/ui/stability-attribute/stability-attribute-sanity-2.rs new file mode 100644 index 000000000..de3ea4eac --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-sanity-2.rs @@ -0,0 +1,17 @@ +// More checks that stability attributes are used correctly + +#![feature(staged_api)] + +#![stable(feature = "stable_test_feature", since = "1.0.0")] + +#[stable(feature = "a", feature = "b", since = "1.0.0")] //~ ERROR multiple 'feature' items +fn f1() { } + +#[stable(feature = "a", sinse = "1.0.0")] //~ ERROR unknown meta item 'sinse' +fn f2() { } + +#[unstable(feature = "a", issue = "no")] +//~^ ERROR `issue` must be a non-zero numeric string or "none" +fn f3() { } + +fn main() { } diff --git a/tests/ui/stability-attribute/stability-attribute-sanity-2.stderr b/tests/ui/stability-attribute/stability-attribute-sanity-2.stderr new file mode 100644 index 000000000..8dbcc6c97 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-sanity-2.stderr @@ -0,0 +1,24 @@ +error[E0538]: multiple 'feature' items + --> $DIR/stability-attribute-sanity-2.rs:7:25 + | +LL | #[stable(feature = "a", feature = "b", since = "1.0.0")] + | ^^^^^^^^^^^^^ + +error[E0541]: unknown meta item 'sinse' + --> $DIR/stability-attribute-sanity-2.rs:10:25 + | +LL | #[stable(feature = "a", sinse = "1.0.0")] + | ^^^^^^^^^^^^^^^ expected one of `feature`, `since` + +error[E0545]: `issue` must be a non-zero numeric string or "none" + --> $DIR/stability-attribute-sanity-2.rs:13:27 + | +LL | #[unstable(feature = "a", issue = "no")] + | ^^^^^^^^---- + | | + | invalid digit found in string + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0538, E0541, E0545. +For more information about an error, try `rustc --explain E0538`. diff --git a/tests/ui/stability-attribute/stability-attribute-sanity-3.rs b/tests/ui/stability-attribute/stability-attribute-sanity-3.rs new file mode 100644 index 000000000..13ef3d3f5 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-sanity-3.rs @@ -0,0 +1,12 @@ +// More checks that stability attributes are used correctly + +#![feature(staged_api)] + +#![stable(feature = "stable_test_feature", since = "1.0.0")] + +#[macro_export] +macro_rules! mac { //~ ERROR macro has missing stability attribute + () => () +} + +fn main() { } diff --git a/tests/ui/stability-attribute/stability-attribute-sanity-3.stderr b/tests/ui/stability-attribute/stability-attribute-sanity-3.stderr new file mode 100644 index 000000000..b1c56ef22 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-sanity-3.stderr @@ -0,0 +1,10 @@ +error: macro has missing stability attribute + --> $DIR/stability-attribute-sanity-3.rs:8:1 + | +LL | / macro_rules! mac { +LL | | () => () +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/tests/ui/stability-attribute/stability-attribute-sanity-4.rs b/tests/ui/stability-attribute/stability-attribute-sanity-4.rs new file mode 100644 index 000000000..64f996352 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-sanity-4.rs @@ -0,0 +1,29 @@ +// Various checks that stability attributes are used correctly, per RFC 507 + +#![feature(staged_api)] + +#![stable(feature = "rust1", since = "1.0.0")] + +mod bogus_attribute_types_2 { + #[unstable] //~ ERROR malformed `unstable` attribute + fn f1() { } + + #[unstable = "b"] //~ ERROR malformed `unstable` attribute + fn f2() { } + + #[stable] //~ ERROR malformed `stable` attribute + fn f3() { } + + #[stable = "a"] //~ ERROR malformed `stable` attribute + fn f4() { } + + #[stable(feature = "a", since = "b")] + #[deprecated] //~ ERROR missing 'since' + fn f5() { } + + #[stable(feature = "a", since = "b")] + #[deprecated = "a"] //~ ERROR missing 'since' + fn f6() { } +} + +fn main() { } diff --git a/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr b/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr new file mode 100644 index 000000000..a76f5be1e --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr @@ -0,0 +1,39 @@ +error: malformed `unstable` attribute input + --> $DIR/stability-attribute-sanity-4.rs:8:5 + | +LL | #[unstable] + | ^^^^^^^^^^^ help: must be of the form: `#[unstable(feature = "name", reason = "...", issue = "N")]` + +error: malformed `unstable` attribute input + --> $DIR/stability-attribute-sanity-4.rs:11:5 + | +LL | #[unstable = "b"] + | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[unstable(feature = "name", reason = "...", issue = "N")]` + +error: malformed `stable` attribute input + --> $DIR/stability-attribute-sanity-4.rs:14:5 + | +LL | #[stable] + | ^^^^^^^^^ help: must be of the form: `#[stable(feature = "name", since = "version")]` + +error: malformed `stable` attribute input + --> $DIR/stability-attribute-sanity-4.rs:17:5 + | +LL | #[stable = "a"] + | ^^^^^^^^^^^^^^^ help: must be of the form: `#[stable(feature = "name", since = "version")]` + +error[E0542]: missing 'since' + --> $DIR/stability-attribute-sanity-4.rs:21:5 + | +LL | #[deprecated] + | ^^^^^^^^^^^^^ + +error[E0542]: missing 'since' + --> $DIR/stability-attribute-sanity-4.rs:25:5 + | +LL | #[deprecated = "a"] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0542`. diff --git a/tests/ui/stability-attribute/stability-attribute-sanity.rs b/tests/ui/stability-attribute/stability-attribute-sanity.rs new file mode 100644 index 000000000..cc30e6ab9 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-sanity.rs @@ -0,0 +1,76 @@ +// Various checks that stability attributes are used correctly, per RFC 507 + +#![feature(staged_api)] + +#![stable(feature = "rust1", since = "1.0.0")] + +mod bogus_attribute_types_1 { + #[stable(feature = "a", since = "b", reason)] //~ ERROR unknown meta item 'reason' [E0541] + fn f1() { } + + #[stable(feature = "a", since)] //~ ERROR incorrect meta item [E0539] + fn f2() { } + + #[stable(feature, since = "a")] //~ ERROR incorrect meta item [E0539] + fn f3() { } + + #[stable(feature = "a", since(b))] //~ ERROR incorrect meta item [E0539] + fn f5() { } + + #[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() { } + + #[unstable(feature = "b")] //~ ERROR missing 'issue' [E0547] + fn f2() { } + + #[stable(since = "a")] //~ ERROR missing 'feature' [E0546] + fn f3() { } +} + +mod missing_version { + #[stable(feature = "a")] //~ ERROR missing 'since' [E0542] + fn f1() { } + + #[stable(feature = "a", since = "b")] + #[deprecated(note = "a")] //~ ERROR missing 'since' [E0542] + fn f2() { } + + #[stable(feature = "a", since = "b")] + #[deprecated(since = "a")] //~ ERROR missing 'note' [E0543] + fn f3() { } +} + +#[unstable(feature = "b", issue = "none")] +#[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] +fn multiple2() { } + +#[stable(feature = "a", since = "b")] +#[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544] +fn multiple3() { } + +#[stable(feature = "a", since = "b")] //~ ERROR invalid stability version found +#[deprecated(since = "b", note = "text")] +#[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 +//~^ ERROR feature `a` is declared stable since 1.0.0 +#[deprecated(since = "invalid", note = "text")] +fn invalid_deprecation_version() {} + +#[deprecated(since = "a", note = "text")] +fn deprecated_without_unstable_or_stable() { } +//~^^ ERROR deprecated attribute must be paired with either stable or unstable attribute + +fn main() { } diff --git a/tests/ui/stability-attribute/stability-attribute-sanity.stderr b/tests/ui/stability-attribute/stability-attribute-sanity.stderr new file mode 100644 index 000000000..89a8425f5 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-sanity.stderr @@ -0,0 +1,136 @@ +error: multiple `deprecated` attributes + --> $DIR/stability-attribute-sanity.rs:62:1 + | +LL | #[deprecated(since = "b", note = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/stability-attribute-sanity.rs:61:1 + | +LL | #[deprecated(since = "b", note = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0541]: unknown meta item 'reason' + --> $DIR/stability-attribute-sanity.rs:8:42 + | +LL | #[stable(feature = "a", since = "b", reason)] + | ^^^^^^ expected one of `feature`, `since` + +error[E0539]: incorrect meta item + --> $DIR/stability-attribute-sanity.rs:11:29 + | +LL | #[stable(feature = "a", since)] + | ^^^^^ + +error[E0539]: incorrect meta item + --> $DIR/stability-attribute-sanity.rs:14:14 + | +LL | #[stable(feature, since = "a")] + | ^^^^^^^ + +error[E0539]: incorrect meta item + --> $DIR/stability-attribute-sanity.rs:17:29 + | +LL | #[stable(feature = "a", since(b))] + | ^^^^^^^^ + +error[E0539]: incorrect meta item + --> $DIR/stability-attribute-sanity.rs:20:14 + | +LL | #[stable(feature(b), since = "a")] + | ^^^^^^^^^^ + +error[E0546]: missing 'feature' + --> $DIR/stability-attribute-sanity.rs:25:5 + | +LL | #[unstable(issue = "none")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0547]: missing 'issue' + --> $DIR/stability-attribute-sanity.rs:28:5 + | +LL | #[unstable(feature = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0546]: missing 'feature' + --> $DIR/stability-attribute-sanity.rs:31:5 + | +LL | #[stable(since = "a")] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0542]: missing 'since' + --> $DIR/stability-attribute-sanity.rs:36:5 + | +LL | #[stable(feature = "a")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0542]: missing 'since' + --> $DIR/stability-attribute-sanity.rs:40:5 + | +LL | #[deprecated(note = "a")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0543]: missing 'note' + --> $DIR/stability-attribute-sanity.rs:44:5 + | +LL | #[deprecated(since = "a")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0544]: multiple stability levels + --> $DIR/stability-attribute-sanity.rs:49:1 + | +LL | #[stable(feature = "a", since = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0544]: multiple stability levels + --> $DIR/stability-attribute-sanity.rs:53:1 + | +LL | #[unstable(feature = "b", issue = "none")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0544]: multiple stability levels + --> $DIR/stability-attribute-sanity.rs:57:1 + | +LL | #[stable(feature = "a", since = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0544]: multiple stability levels + --> $DIR/stability-attribute-sanity.rs:64:1 + | +LL | #[rustc_const_unstable(feature = "d", issue = "none")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: invalid stability version found + --> $DIR/stability-attribute-sanity.rs:60:1 + | +LL | #[stable(feature = "a", since = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid stability version +... +LL | pub const fn multiple4() { } + | ---------------------------- the stability attribute annotates this item + +error: invalid deprecation version found + --> $DIR/stability-attribute-sanity.rs:67:1 + | +LL | #[stable(feature = "a", since = "1.0.0")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid deprecation version +... +LL | fn invalid_deprecation_version() {} + | ----------------------------------- the stability attribute annotates this item + +error[E0549]: deprecated attribute must be paired with either stable or unstable attribute + --> $DIR/stability-attribute-sanity.rs:72:1 + | +LL | #[deprecated(since = "a", note = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0711]: feature `a` is declared stable since 1.0.0, but was previously declared stable since b + --> $DIR/stability-attribute-sanity.rs:67:1 + | +LL | #[stable(feature = "a", since = "1.0.0")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 20 previous errors + +Some errors have detailed explanations: E0539, E0541, E0542, E0543, E0544, E0546, E0547, E0549, E0711. +For more information about an error, try `rustc --explain E0539`. diff --git a/tests/ui/stability-attribute/stability-attribute-trait-impl.rs b/tests/ui/stability-attribute/stability-attribute-trait-impl.rs new file mode 100644 index 000000000..0c771ae87 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-trait-impl.rs @@ -0,0 +1,43 @@ +#![feature(staged_api, never_type, c_unwind)] +//~^ ERROR module has missing stability attribute + +#[stable(feature = "a", since = "1")] +struct StableType; + +#[unstable(feature = "b", issue = "none")] +struct UnstableType; + +#[stable(feature = "c", since = "1")] +trait StableTrait {} + +#[unstable(feature = "d", issue = "none")] +trait UnstableTrait {} + +#[unstable(feature = "e", issue = "none")] +impl UnstableTrait for UnstableType {} + +#[unstable(feature = "f", issue = "none")] +impl StableTrait for UnstableType {} + +#[unstable(feature = "g", issue = "none")] +impl UnstableTrait for StableType {} + +#[unstable(feature = "h", issue = "none")] +impl StableTrait for ! {} + +// Note: If C-unwind is stabilized, switch this to another (unstable) ABI. +#[unstable(feature = "i", issue = "none")] +impl StableTrait for extern "C-unwind" fn() {} + +#[unstable(feature = "j", issue = "none")] +//~^ ERROR an `#[unstable]` annotation here has no effect [ineffective_unstable_trait_impl] +impl StableTrait for StableType {} + +#[unstable(feature = "k", issue = "none")] +//~^ ERROR an `#[unstable]` annotation here has no effect [ineffective_unstable_trait_impl] +impl StableTrait for fn() -> ! {} + +#[unstable(feature = "l", issue = "none")] +impl StableTrait for fn() -> UnstableType {} + +fn main() {} diff --git a/tests/ui/stability-attribute/stability-attribute-trait-impl.stderr b/tests/ui/stability-attribute/stability-attribute-trait-impl.stderr new file mode 100644 index 000000000..b91a1d2e1 --- /dev/null +++ b/tests/ui/stability-attribute/stability-attribute-trait-impl.stderr @@ -0,0 +1,31 @@ +error: an `#[unstable]` annotation here has no effect + --> $DIR/stability-attribute-trait-impl.rs:32:1 + | +LL | #[unstable(feature = "j", issue = "none")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #55436 for more information + = note: `#[deny(ineffective_unstable_trait_impl)]` on by default + +error: an `#[unstable]` annotation here has no effect + --> $DIR/stability-attribute-trait-impl.rs:36:1 + | +LL | #[unstable(feature = "k", issue = "none")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #55436 for more information + +error: module has missing stability attribute + --> $DIR/stability-attribute-trait-impl.rs:1:1 + | +LL | / #![feature(staged_api, never_type, c_unwind)] +LL | | +LL | | +LL | | #[stable(feature = "a", since = "1")] +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/stability-attribute/stability-in-private-module.rs b/tests/ui/stability-attribute/stability-in-private-module.rs new file mode 100644 index 000000000..f12e9198b --- /dev/null +++ b/tests/ui/stability-attribute/stability-in-private-module.rs @@ -0,0 +1,4 @@ +fn main() { + let _ = std::thread::thread_info::current_thread(); + //~^ERROR module `thread_info` is private +} diff --git a/tests/ui/stability-attribute/stability-in-private-module.stderr b/tests/ui/stability-attribute/stability-in-private-module.stderr new file mode 100644 index 000000000..2f02a2496 --- /dev/null +++ b/tests/ui/stability-attribute/stability-in-private-module.stderr @@ -0,0 +1,12 @@ +error[E0603]: module `thread_info` is private + --> $DIR/stability-in-private-module.rs:2:26 + | +LL | let _ = std::thread::thread_info::current_thread(); + | ^^^^^^^^^^^ private module + | +note: the module `thread_info` is defined here + --> $SRC_DIR/std/src/thread/mod.rs:LL:COL + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/stability-attribute/stable-in-unstable.rs b/tests/ui/stability-attribute/stable-in-unstable.rs new file mode 100644 index 000000000..226367c39 --- /dev/null +++ b/tests/ui/stability-attribute/stable-in-unstable.rs @@ -0,0 +1,54 @@ +// This test is meant to test that we can have a stable item in an unstable module, and that +// calling that item through the unstable module is unstable, but that re-exporting it from another +// crate in a stable module is fine. +// +// This is necessary to support moving items from `std` into `core` or `alloc` unstably while still +// exporting the original stable interface in `std`, such as moving `Error` into `core`. +// +// aux-build:stable-in-unstable-core.rs +// aux-build:stable-in-unstable-std.rs +#![crate_type = "lib"] + +extern crate stable_in_unstable_core; +extern crate stable_in_unstable_std; + +mod isolated1 { + use stable_in_unstable_core::new_unstable_module; //~ ERROR use of unstable library feature 'unstable_test_feature' + use stable_in_unstable_core::new_unstable_module::OldTrait; //~ ERROR use of unstable library feature 'unstable_test_feature' +} + +mod isolated2 { + use stable_in_unstable_std::old_stable_module::OldTrait; + + struct LocalType; + + impl OldTrait for LocalType {} +} + +mod isolated3 { + use stable_in_unstable_core::new_unstable_module::OldTrait; //~ ERROR use of unstable library feature 'unstable_test_feature' + + struct LocalType; + + impl OldTrait for LocalType {} +} + +mod isolated4 { + struct LocalType; + + impl stable_in_unstable_core::new_unstable_module::OldTrait for LocalType {} //~ ERROR use of unstable library feature 'unstable_test_feature' +} + +mod isolated5 { + struct LocalType; + + impl stable_in_unstable_std::old_stable_module::OldTrait for LocalType {} +} + +mod isolated6 { + use stable_in_unstable_core::new_unstable_module::{OldTrait}; //~ ERROR use of unstable library feature 'unstable_test_feature' +} + +mod isolated7 { + use stable_in_unstable_core::new_unstable_module::*; //~ ERROR use of unstable library feature 'unstable_test_feature' +} diff --git a/tests/ui/stability-attribute/stable-in-unstable.stderr b/tests/ui/stability-attribute/stable-in-unstable.stderr new file mode 100644 index 000000000..b5e3e5f12 --- /dev/null +++ b/tests/ui/stability-attribute/stable-in-unstable.stderr @@ -0,0 +1,57 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/stable-in-unstable.rs:16:9 + | +LL | use stable_in_unstable_core::new_unstable_module; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #1 for more information + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/stable-in-unstable.rs:17:9 + | +LL | use stable_in_unstable_core::new_unstable_module::OldTrait; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #1 for more information + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/stable-in-unstable.rs:29:9 + | +LL | use stable_in_unstable_core::new_unstable_module::OldTrait; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #1 for more information + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/stable-in-unstable.rs:39:10 + | +LL | impl stable_in_unstable_core::new_unstable_module::OldTrait for LocalType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #1 for more information + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/stable-in-unstable.rs:49:56 + | +LL | use stable_in_unstable_core::new_unstable_module::{OldTrait}; + | ^^^^^^^^ + | + = note: see issue #1 for more information + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/stable-in-unstable.rs:53:9 + | +LL | use stable_in_unstable_core::new_unstable_module::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #1 for more information + = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/suggest-vec-allocator-api.rs b/tests/ui/stability-attribute/suggest-vec-allocator-api.rs new file mode 100644 index 000000000..fac52ab77 --- /dev/null +++ b/tests/ui/stability-attribute/suggest-vec-allocator-api.rs @@ -0,0 +1,9 @@ +fn main() { + let _: Vec = vec![]; //~ ERROR use of unstable library feature 'allocator_api' + #[rustfmt::skip] + let _: Vec< + String, + _> = vec![]; //~ ERROR use of unstable library feature 'allocator_api' + let _ = Vec::::new(); //~ ERROR use of unstable library feature 'allocator_api' + let _boxed: Box = Box::new(10); //~ ERROR use of unstable library feature 'allocator_api' +} diff --git a/tests/ui/stability-attribute/suggest-vec-allocator-api.stderr b/tests/ui/stability-attribute/suggest-vec-allocator-api.stderr new file mode 100644 index 000000000..41e5787b8 --- /dev/null +++ b/tests/ui/stability-attribute/suggest-vec-allocator-api.stderr @@ -0,0 +1,49 @@ +error[E0658]: use of unstable library feature 'allocator_api' + --> $DIR/suggest-vec-allocator-api.rs:2:20 + | +LL | let _: Vec = vec![]; + | ----^ + | | + | help: consider wrapping the inner types in tuple: `(u8, _)` + | + = note: see issue #32838 for more information + = help: add `#![feature(allocator_api)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'allocator_api' + --> $DIR/suggest-vec-allocator-api.rs:6:9 + | +LL | _> = vec![]; + | ^ + | + = note: see issue #32838 for more information + = help: add `#![feature(allocator_api)]` to the crate attributes to enable +help: consider wrapping the inner types in tuple + | +LL ~ let _: Vec<( +LL + String, +LL ~ _)> = vec![]; + | + +error[E0658]: use of unstable library feature 'allocator_api' + --> $DIR/suggest-vec-allocator-api.rs:8:26 + | +LL | let _boxed: Box = Box::new(10); + | ^ + | + = note: see issue #32838 for more information + = help: add `#![feature(allocator_api)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'allocator_api' + --> $DIR/suggest-vec-allocator-api.rs:7:24 + | +LL | let _ = Vec::::new(); + | -----^ + | | + | help: consider wrapping the inner types in tuple: `(u16, _)` + | + = note: see issue #32838 for more information + = help: add `#![feature(allocator_api)]` to the crate attributes to enable + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0658`. -- cgit v1.2.3