Skip to content

Commit a69ba29

Browse files
Fix deprecation attribute on foreign statics & types
1 parent e8f90b1 commit a69ba29

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ impl<S: Stage> SingleAttributeParser<S> for DeprecationParser {
5454
Allow(Target::TyAlias),
5555
Allow(Target::Use),
5656
Allow(Target::ForeignFn),
57+
Allow(Target::ForeignStatic),
58+
Allow(Target::ForeignTy),
5759
Allow(Target::Field),
5860
Allow(Target::Trait),
5961
Allow(Target::AssocTy),

tests/ui/deprecation/deprecation-sanity.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,9 @@ impl Default for X {
4242
}
4343
}
4444

45+
unsafe extern "C" {
46+
#[deprecated]
47+
static FOO: std::ffi::c_int;
48+
}
49+
4550
fn main() { }

tests/ui/deprecation/deprecation-sanity.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ LL | #[deprecated = "hello"]
177177
| ^^^^^^^^^^^^^^^^^^^^^^^
178178
|
179179
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
180-
= 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
180+
= 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
181181
= note: `#[deny(useless_deprecated)]` on by default
182182

183183
error: aborting due to 10 previous errors

tests/ui/where-clauses/unsupported_attribute.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ error: `#[deprecated]` attribute cannot be used on where predicates
6464
LL | #[deprecated] T: Trait,
6565
| ^^^^^^^^^^^^^
6666
|
67-
= 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
67+
= 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
6868

6969
error: `#[deprecated]` attribute cannot be used on where predicates
7070
--> $DIR/unsupported_attribute.rs:25:5
7171
|
7272
LL | #[deprecated] 'a: 'static,
7373
| ^^^^^^^^^^^^^
7474
|
75-
= 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
75+
= 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
7676

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

0 commit comments

Comments
 (0)