Skip to content

Commit d6b05d5

Browse files
authored
Unrolled build for #145485
Rollup merge of #145485 - JonathanBrouwer:fix-deprecation-targets, r=jdonszelmann Fix deprecation attributes on foreign statics r? ````````@jdonszelmann```````` Fixes #145437
2 parents 425a9c0 + a69ba29 commit d6b05d5

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-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),

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,9 @@ pub(crate) fn allowed_targets_applied(
10601060
if !features.stmt_expr_attributes() {
10611061
allowed_targets.retain(|t| !matches!(t, Target::Expression | Target::Statement));
10621062
}
1063+
if !features.extern_types() {
1064+
allowed_targets.retain(|t| !matches!(t, Target::ForeignTy));
1065+
}
10631066
}
10641067

10651068
// We define groups of "similar" targets.

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)