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
2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/deprecation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ impl<S: Stage> SingleAttributeParser<S> for DeprecationParser {
Allow(Target::TyAlias),
Allow(Target::Use),
Allow(Target::ForeignFn),
Allow(Target::ForeignStatic),
Allow(Target::ForeignTy),
Allow(Target::Field),
Allow(Target::Trait),
Allow(Target::AssocTy),
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,9 @@ pub(crate) fn allowed_targets_applied(
if !features.stmt_expr_attributes() {
allowed_targets.retain(|t| !matches!(t, Target::Expression | Target::Statement));
}
if !features.extern_types() {
allowed_targets.retain(|t| !matches!(t, Target::ForeignTy));
}
}

// We define groups of "similar" targets.
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/deprecation/deprecation-sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ impl Default for X {
}
}

unsafe extern "C" {
#[deprecated]
static FOO: std::ffi::c_int;
}

fn main() { }
2 changes: 1 addition & 1 deletion tests/ui/deprecation/deprecation-sanity.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ LL | #[deprecated = "hello"]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates
= help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates
= note: `#[deny(useless_deprecated)]` on by default

error: aborting due to 10 previous errors
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/where-clauses/unsupported_attribute.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ error: `#[deprecated]` attribute cannot be used on where predicates
LL | #[deprecated] T: Trait,
| ^^^^^^^^^^^^^
|
= help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates
= help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates

error: `#[deprecated]` attribute cannot be used on where predicates
--> $DIR/unsupported_attribute.rs:25:5
|
LL | #[deprecated] 'a: 'static,
| ^^^^^^^^^^^^^
|
= help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates
= help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates

error: `#[automatically_derived]` attribute cannot be used on where predicates
--> $DIR/unsupported_attribute.rs:26:5
Expand Down
Loading