Skip to content

Commit 12b8d89

Browse files
Rollup merge of #77183 - bugadani:issue-77088, r=varkor
Allow multiple allow_internal_unstable attributes Fixes #77088
2 parents a7bdf85 + 54c9c94 commit 12b8d89

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

compiler/rustc_attr/src/builtin.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -1022,14 +1022,21 @@ pub fn find_transparency(
10221022

10231023
pub fn allow_internal_unstable<'a>(
10241024
sess: &'a Session,
1025-
attrs: &[Attribute],
1025+
attrs: &'a [Attribute],
10261026
) -> Option<impl Iterator<Item = Symbol> + 'a> {
1027-
let attr = sess.find_by_name(attrs, sym::allow_internal_unstable)?;
1028-
let list = attr.meta_item_list().or_else(|| {
1029-
sess.diagnostic()
1030-
.span_err(attr.span, "allow_internal_unstable expects list of feature names");
1031-
None
1032-
})?;
1027+
let attrs = sess.filter_by_name(attrs, sym::allow_internal_unstable);
1028+
let list = attrs
1029+
.filter_map(move |attr| {
1030+
attr.meta_item_list().or_else(|| {
1031+
sess.diagnostic().span_err(
1032+
attr.span,
1033+
"`allow_internal_unstable` expects a list of feature names",
1034+
);
1035+
None
1036+
})
1037+
})
1038+
.flatten();
1039+
10331040
Some(list.into_iter().filter_map(move |it| {
10341041
let name = it.ident().map(|ident| ident.name);
10351042
if name.is_none() {

src/test/ui/internal/auxiliary/internal_unstable.rs

+9
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ macro_rules! access_field_allow {
5252
($e: expr) => { $e.x }
5353
}
5454

55+
// regression test for #77088
56+
#[stable(feature = "stable", since = "1.0.0")]
57+
#[allow_internal_unstable(struct_field)]
58+
#[allow_internal_unstable(struct2_field)]
59+
#[macro_export]
60+
macro_rules! access_field_allow2 {
61+
($e: expr) => { $e.x }
62+
}
63+
5564
#[stable(feature = "stable", since = "1.0.0")]
5665
#[allow_internal_unstable()]
5766
#[macro_export]

src/test/ui/internal/internal-unstable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ fn main() {
2828
construct_unstable_allow!(0);
2929
|x: internal_unstable::Foo| { call_method_allow!(x) };
3030
|x: internal_unstable::Bar| { access_field_allow!(x) };
31+
|x: internal_unstable::Bar| { access_field_allow2!(x) }; // regression test for #77088
3132

3233
// bad.
3334
pass_through_allow!(internal_unstable::unstable()); //~ ERROR use of unstable

src/test/ui/internal/internal-unstable.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error[E0658]: use of unstable library feature 'function'
2-
--> $DIR/internal-unstable.rs:33:25
2+
--> $DIR/internal-unstable.rs:34:25
33
|
44
LL | pass_through_allow!(internal_unstable::unstable());
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: add `#![feature(function)]` to the crate attributes to enable
88

99
error[E0658]: use of unstable library feature 'function'
10-
--> $DIR/internal-unstable.rs:35:27
10+
--> $DIR/internal-unstable.rs:36:27
1111
|
1212
LL | pass_through_noallow!(internal_unstable::unstable());
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414
|
1515
= help: add `#![feature(function)]` to the crate attributes to enable
1616

1717
error[E0658]: use of unstable library feature 'function'
18-
--> $DIR/internal-unstable.rs:39:22
18+
--> $DIR/internal-unstable.rs:40:22
1919
|
2020
LL | println!("{:?}", internal_unstable::unstable());
2121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2222
|
2323
= help: add `#![feature(function)]` to the crate attributes to enable
2424

2525
error[E0658]: use of unstable library feature 'function'
26-
--> $DIR/internal-unstable.rs:41:10
26+
--> $DIR/internal-unstable.rs:42:10
2727
|
2828
LL | bar!(internal_unstable::unstable());
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)