Skip to content

Commit ffa7094

Browse files
committed
Setup unstable feature attr parser
1 parent ece7a29 commit ffa7094

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub enum AttributeKind {
162162
// tidy-alphabetical-start
163163
AllowConstFnUnstable(ThinVec<Symbol>),
164164
AllowInternalUnstable(ThinVec<(Symbol, Span)>),
165+
AllowUnstableFeature(ThinVec<(Symbol, Span)>),
165166
BodyStability {
166167
stability: DefaultBodyStability,
167168
/// Span of the `#[rustc_default_body_unstable(...)]` attribute

compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ impl CombineAttributeParser for AllowInternalUnstableParser {
2222
}
2323
}
2424

25+
pub(crate) struct AllowUnstableFeatureParser;
26+
impl CombineAttributeParser for AllowUnstableFeatureParser {
27+
const PATH: &'static [rustc_span::Symbol] = &[sym::allow_unstable_feature];
28+
type Item = (Symbol, Span);
29+
const CONVERT: ConvertFn<Self::Item> = AttributeKind::AllowUnstableFeature;
30+
31+
fn extend<'a>(
32+
cx: &'a AcceptContext<'a>,
33+
args: &'a ArgParser<'a>,
34+
) -> impl IntoIterator<Item = Self::Item> + 'a {
35+
parse_unstable(cx, args, Self::PATH[0]).into_iter().zip(iter::repeat(cx.attr_span))
36+
}
37+
}
38+
2539
pub(crate) struct AllowConstFnUnstableParser;
2640
impl CombineAttributeParser for AllowConstFnUnstableParser {
2741
const PATH: &'static [rustc_span::Symbol] = &[sym::rustc_allow_const_fn_unstable];

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::{AttrArgs, AttrItem, AttrPath, Attribute, HashIgnoredAttrId};
1111
use rustc_session::Session;
1212
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
1313

14-
use crate::attributes::allow_unstable::{AllowConstFnUnstableParser, AllowInternalUnstableParser};
14+
use crate::attributes::allow_unstable::{AllowConstFnUnstableParser, AllowInternalUnstableParser, AllowUnstableFeatureParser};
1515
use crate::attributes::confusables::ConfusablesParser;
1616
use crate::attributes::deprecation::DeprecationParser;
1717
use crate::attributes::repr::ReprParser;
@@ -70,6 +70,7 @@ attribute_groups!(
7070
// tidy-alphabetical-start
7171
Combine<AllowConstFnUnstableParser>,
7272
Combine<AllowInternalUnstableParser>,
73+
Combine<AllowUnstableFeatureParser>,
7374
Combine<ReprParser>,
7475
// tidy-alphabetical-end
7576

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ symbols! {
449449
allow_fail,
450450
allow_internal_unsafe,
451451
allow_internal_unstable,
452+
allow_unstable_feature,
452453
altivec,
453454
alu32,
454455
always,

0 commit comments

Comments
 (0)