Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ impl CombineAttributeParser for AllowInternalUnstableParser {
type Item = (Symbol, Span);
const CONVERT: ConvertFn<Self::Item> =
|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);

Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
9 changes: 2 additions & 7 deletions compiler/rustc_attr_parsing/src/attributes/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 2 additions & 4 deletions tests/ui/internal/internal-unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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
_ => {}
}

Expand Down
49 changes: 23 additions & 26 deletions tests/ui/internal/internal-unstable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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`.
Loading