Skip to content

Commit 02b09f5

Browse files
committed
Setup unstable feature attr parser
1 parent a944850 commit 02b09f5

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 [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;
@@ -75,6 +75,7 @@ attribute_groups!(
7575
// tidy-alphabetical-start
7676
Combine<AllowConstFnUnstableParser>,
7777
Combine<AllowInternalUnstableParser>,
78+
Combine<AllowUnstableFeatureParser>,
7879
Combine<ReprParser>,
7980
// tidy-alphabetical-end
8081

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ symbols! {
442442
allow_fail,
443443
allow_internal_unsafe,
444444
allow_internal_unstable,
445+
allow_unstable_feature,
445446
altivec,
446447
alu32,
447448
always,

0 commit comments

Comments
 (0)