diff --git a/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs b/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs index 743d3c9b5e76e..667c2d0838a25 100644 --- a/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs +++ b/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs @@ -12,12 +12,8 @@ impl CombineAttributeParser for AllowInternalUnstableParser { type Item = (Symbol, Span); const CONVERT: ConvertFn = |items, span| AttributeKind::AllowInternalUnstable(items, span); - const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[ - Allow(Target::MacroDef), - Allow(Target::Fn), - Warn(Target::Field), - Warn(Target::Arm), - ]); + const ALLOWED_TARGETS: AllowedTargets<'_> = + AllowedTargets::AllowList(&[Allow(Target::MacroDef), Allow(Target::Fn)]); const TEMPLATE: AttributeTemplate = template!(Word, List: &["feat1, feat2, ..."]); const STABILITY: AttributeStability = unstable!(allow_internal_unstable); diff --git a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs index c9625521aec44..92b61fe00b1b9 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -131,12 +131,8 @@ pub(crate) struct AllowInternalUnsafeParser; impl NoArgsAttributeParser for AllowInternalUnsafeParser { const PATH: &[Symbol] = &[sym::allow_internal_unsafe]; const ON_DUPLICATE: OnDuplicate = OnDuplicate::Ignore; - const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[ - Allow(Target::Fn), - Allow(Target::MacroDef), - Warn(Target::Field), - Warn(Target::Arm), - ]); + const ALLOWED_TARGETS: AllowedTargets<'_> = + AllowedTargets::AllowList(&[Allow(Target::Fn), Allow(Target::MacroDef)]); const STABILITY: AttributeStability = unstable!(allow_internal_unsafe); const CREATE: fn(Span) -> AttributeKind = |span| AttributeKind::AllowInternalUnsafe(span); diff --git a/compiler/rustc_attr_parsing/src/attributes/traits.rs b/compiler/rustc_attr_parsing/src/attributes/traits.rs index 1d0d26ea62cb3..e55a033eb3188 100644 --- a/compiler/rustc_attr_parsing/src/attributes/traits.rs +++ b/compiler/rustc_attr_parsing/src/attributes/traits.rs @@ -8,7 +8,7 @@ use crate::attributes::{NoArgsAttributeParser, SingleAttributeParser}; use crate::context::AcceptContext; use crate::parser::ArgParser; use crate::target_checking::AllowedTargets; -use crate::target_checking::Policy::{Allow, Warn}; +use crate::target_checking::Policy::Allow; pub(crate) struct RustcSkipDuringMethodDispatchParser; impl SingleAttributeParser for RustcSkipDuringMethodDispatchParser { @@ -63,12 +63,7 @@ impl NoArgsAttributeParser for RustcParenSugarParser { pub(crate) struct MarkerParser; impl NoArgsAttributeParser for MarkerParser { const PATH: &[Symbol] = &[sym::marker]; - const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[ - Allow(Target::Trait), - Warn(Target::Field), - Warn(Target::Arm), - Warn(Target::MacroDef), - ]); + const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Trait)]); const STABILITY: AttributeStability = unstable!(marker_trait_attr); const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::Marker; } diff --git a/tests/ui/internal/internal-unstable.rs b/tests/ui/internal/internal-unstable.rs index 5564852e98888..41aa76dea3f7b 100644 --- a/tests/ui/internal/internal-unstable.rs +++ b/tests/ui/internal/internal-unstable.rs @@ -8,8 +8,7 @@ extern crate internal_unstable; struct Baz { #[allow_internal_unstable] //~ ERROR `allow_internal_unstable` expects a list of feature names - //~^ WARN cannot be used on - //~| WARN previously accepted + //~^ ERROR cannot be used on baz: u8, } @@ -59,8 +58,7 @@ fn main() { match true { #[allow_internal_unstable] //~ ERROR `allow_internal_unstable` expects a list of feature names - //~^ WARN cannot be used on - //~| WARN previously accepted + //~^ ERROR cannot be used on _ => {} } diff --git a/tests/ui/internal/internal-unstable.stderr b/tests/ui/internal/internal-unstable.stderr index b816dc6f7454c..924d512e99836 100644 --- a/tests/ui/internal/internal-unstable.stderr +++ b/tests/ui/internal/internal-unstable.stderr @@ -4,14 +4,30 @@ error: `allow_internal_unstable` expects a list of feature names LL | #[allow_internal_unstable] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: the `allow_internal_unstable` attribute cannot be used on struct fields + --> $DIR/internal-unstable.rs:10:7 + | +LL | #[allow_internal_unstable] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: the `allow_internal_unstable` attribute can be applied to functions and macro defs + error: `allow_internal_unstable` expects a list of feature names - --> $DIR/internal-unstable.rs:61:9 + --> $DIR/internal-unstable.rs:60:9 | LL | #[allow_internal_unstable] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: the `allow_internal_unstable` attribute cannot be used on match arms + --> $DIR/internal-unstable.rs:60:11 + | +LL | #[allow_internal_unstable] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: the `allow_internal_unstable` attribute can be applied to functions and macro defs + error[E0658]: use of unstable library feature `function` - --> $DIR/internal-unstable.rs:50:25 + --> $DIR/internal-unstable.rs:49:25 | LL | pass_through_allow!(internal_unstable::unstable()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +36,7 @@ LL | pass_through_allow!(internal_unstable::unstable()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable library feature `function` - --> $DIR/internal-unstable.rs:52:27 + --> $DIR/internal-unstable.rs:51:27 | LL | pass_through_noallow!(internal_unstable::unstable()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -29,7 +45,7 @@ LL | pass_through_noallow!(internal_unstable::unstable()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable library feature `function` - --> $DIR/internal-unstable.rs:56:22 + --> $DIR/internal-unstable.rs:55:22 | LL | println!("{:?}", internal_unstable::unstable()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -38,7 +54,7 @@ LL | println!("{:?}", internal_unstable::unstable()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable library feature `function` - --> $DIR/internal-unstable.rs:58:10 + --> $DIR/internal-unstable.rs:57:10 | LL | bar!(internal_unstable::unstable()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +63,7 @@ LL | bar!(internal_unstable::unstable()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable library feature `function` - --> $DIR/internal-unstable.rs:20:9 + --> $DIR/internal-unstable.rs:19:9 | LL | internal_unstable::unstable(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -59,25 +75,6 @@ LL | bar!(internal_unstable::unstable()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: this error originates in the macro `foo` which comes from the expansion of the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: the `allow_internal_unstable` attribute cannot be used on struct fields - --> $DIR/internal-unstable.rs:10:7 - | -LL | #[allow_internal_unstable] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: the `allow_internal_unstable` attribute can be applied to functions and macro defs - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: requested on the command line with `-W unused-attributes` - -warning: the `allow_internal_unstable` attribute cannot be used on match arms - --> $DIR/internal-unstable.rs:61:11 - | -LL | #[allow_internal_unstable] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: the `allow_internal_unstable` attribute can be applied to functions and macro defs - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -error: aborting due to 7 previous errors; 2 warnings emitted +error: aborting due to 9 previous errors For more information about this error, try `rustc --explain E0658`.