Skip to content

Commit 1b0c5c8

Browse files
Rollup merge of #158233 - kantnero:allow-unstable-attr-on-target, r=JonathanBrouwer
Allow the unstable attribute on foreign type While working the `FnPtr` trait in #156176 @carbotaniuman was trying to implement `Code` as an extern type but got an error as the current stability infrastructure does not allow `unstable` attribute on foreign type. #158200 This PR fixes that by allowing the `unstable` attribute on ForeignTy and adds test to verify. @rustbot r? @JonathanBrouwer
2 parents f76d5a0 + 94888f0 commit 1b0c5c8

4 files changed

Lines changed: 63 additions & 44 deletions

File tree

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[
4040
Allow(Target::Static),
4141
Allow(Target::ForeignFn),
4242
Allow(Target::ForeignStatic),
43+
Allow(Target::ForeignTy),
4344
Allow(Target::ExternCrate),
4445
]);
4546

tests/ui/lint/auxiliary/lint_stability.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![crate_name="lint_stability"]
22
#![crate_type = "lib"]
3+
#![feature(extern_types)]
34
#![feature(staged_api)]
45
#![feature(associated_type_defaults)]
56
#![stable(feature = "lint_stability", since = "1.0.0")]
@@ -186,3 +187,8 @@ macro_rules! macro_test_arg {
186187
macro_rules! macro_test_arg_nested {
187188
($func:ident) => (macro_test_arg!($func()));
188189
}
190+
191+
extern "C" {
192+
#[unstable(feature = "unstable_test_feature", issue = "none")]
193+
pub type UnstableForeignType;
194+
}

tests/ui/lint/lint-stability.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![allow(deprecated)]
77
#![allow(dead_code)]
88
#![feature(staged_api)]
9-
9+
#![feature(extern_types)]
1010
#![stable(feature = "rust1", since = "1.0.0")]
1111

1212
#[macro_use]
@@ -18,6 +18,9 @@ mod cross_crate {
1818

1919
use lint_stability::*;
2020

21+
fn test_foreign_type(_: &mut UnstableForeignType) { //~ ERROR use of unstable library feature
22+
}
23+
2124
fn test() {
2225
type Foo = MethodTester;
2326
let foo = MethodTester;

0 commit comments

Comments
 (0)