Skip to content

Commit 1605ec0

Browse files
committed
Auto merge of #155775 - JonathanBrouwer:cleanup_stage, r=<try>
Remove attribute parsing `Stage`
2 parents fb76025 + 92e7c93 commit 1605ec0

57 files changed

Lines changed: 573 additions & 740 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use std::sync::Arc;
4141
use rustc_ast::node_id::NodeMap;
4242
use rustc_ast::visit::Visitor;
4343
use rustc_ast::{self as ast, *};
44-
use rustc_attr_parsing::{AttributeParser, EmitAttribute, Late, OmitDoc};
44+
use rustc_attr_parsing::{AttributeParser, EmitAttribute, OmitDoc, Recovery, ShouldEmit};
4545
use rustc_data_structures::fingerprint::Fingerprint;
4646
use rustc_data_structures::fx::FxIndexSet;
4747
use rustc_data_structures::sorted_map::SortedMap;
@@ -223,7 +223,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
223223
tcx.sess,
224224
tcx.features(),
225225
registered_tools,
226-
Late,
226+
ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed },
227227
),
228228
delayed_lints: Vec::new(),
229229
}

compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::prelude::*;
44
use crate::session_diagnostics;
55

66
pub(crate) struct AllowInternalUnstableParser;
7-
impl<S: Stage> CombineAttributeParser<S> for AllowInternalUnstableParser {
7+
impl CombineAttributeParser for AllowInternalUnstableParser {
88
const PATH: &[Symbol] = &[sym::allow_internal_unstable];
99
type Item = (Symbol, Span);
1010
const CONVERT: ConvertFn<Self::Item> =
@@ -18,17 +18,17 @@ impl<S: Stage> CombineAttributeParser<S> for AllowInternalUnstableParser {
1818
const TEMPLATE: AttributeTemplate = template!(Word, List: &["feat1, feat2, ..."]);
1919

2020
fn extend(
21-
cx: &mut AcceptContext<'_, '_, S>,
21+
cx: &mut AcceptContext<'_, '_>,
2222
args: &ArgParser,
2323
) -> impl IntoIterator<Item = Self::Item> {
24-
parse_unstable(cx, args, <Self as CombineAttributeParser<S>>::PATH[0])
24+
parse_unstable(cx, args, <Self as CombineAttributeParser>::PATH[0])
2525
.into_iter()
2626
.zip(iter::repeat(cx.attr_span))
2727
}
2828
}
2929

3030
pub(crate) struct UnstableFeatureBoundParser;
31-
impl<S: Stage> CombineAttributeParser<S> for UnstableFeatureBoundParser {
31+
impl CombineAttributeParser for UnstableFeatureBoundParser {
3232
const PATH: &[rustc_span::Symbol] = &[sym::unstable_feature_bound];
3333
type Item = (Symbol, Span);
3434
const CONVERT: ConvertFn<Self::Item> = |items, _| AttributeKind::UnstableFeatureBound(items);
@@ -40,20 +40,20 @@ impl<S: Stage> CombineAttributeParser<S> for UnstableFeatureBoundParser {
4040
const TEMPLATE: AttributeTemplate = template!(Word, List: &["feat1, feat2, ..."]);
4141

4242
fn extend(
43-
cx: &mut AcceptContext<'_, '_, S>,
43+
cx: &mut AcceptContext<'_, '_>,
4444
args: &ArgParser,
4545
) -> impl IntoIterator<Item = Self::Item> {
4646
if !cx.features().staged_api() {
4747
cx.emit_err(session_diagnostics::StabilityOutsideStd { span: cx.attr_span });
4848
}
49-
parse_unstable(cx, args, <Self as CombineAttributeParser<S>>::PATH[0])
49+
parse_unstable(cx, args, <Self as CombineAttributeParser>::PATH[0])
5050
.into_iter()
5151
.zip(iter::repeat(cx.attr_span))
5252
}
5353
}
5454

5555
pub(crate) struct RustcAllowConstFnUnstableParser;
56-
impl<S: Stage> CombineAttributeParser<S> for RustcAllowConstFnUnstableParser {
56+
impl CombineAttributeParser for RustcAllowConstFnUnstableParser {
5757
const PATH: &[Symbol] = &[sym::rustc_allow_const_fn_unstable];
5858
type Item = Symbol;
5959
const CONVERT: ConvertFn<Self::Item> =
@@ -67,15 +67,15 @@ impl<S: Stage> CombineAttributeParser<S> for RustcAllowConstFnUnstableParser {
6767
const TEMPLATE: AttributeTemplate = template!(Word, List: &["feat1, feat2, ..."]);
6868

6969
fn extend(
70-
cx: &mut AcceptContext<'_, '_, S>,
70+
cx: &mut AcceptContext<'_, '_>,
7171
args: &ArgParser,
7272
) -> impl IntoIterator<Item = Self::Item> {
73-
parse_unstable(cx, args, <Self as CombineAttributeParser<S>>::PATH[0])
73+
parse_unstable(cx, args, <Self as CombineAttributeParser>::PATH[0])
7474
}
7575
}
7676

77-
fn parse_unstable<S: Stage>(
78-
cx: &AcceptContext<'_, '_, S>,
77+
fn parse_unstable(
78+
cx: &AcceptContext<'_, '_>,
7979
args: &ArgParser,
8080
symbol: Symbol,
8181
) -> impl IntoIterator<Item = Symbol> {

compiler/rustc_attr_parsing/src/attributes/autodiff.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ use thin_vec::ThinVec;
1010

1111
use crate::attributes::SingleAttributeParser;
1212
use crate::attributes::prelude::Allow;
13-
use crate::context::{AcceptContext, Stage};
13+
use crate::context::AcceptContext;
1414
use crate::parser::{ArgParser, MetaItemOrLitParser};
1515
use crate::target_checking::AllowedTargets;
1616

1717
pub(crate) struct RustcAutodiffParser;
1818

19-
impl<S: Stage> SingleAttributeParser<S> for RustcAutodiffParser {
19+
impl SingleAttributeParser for RustcAutodiffParser {
2020
const PATH: &[Symbol] = &[sym::rustc_autodiff];
2121
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
2222
Allow(Target::Fn),
@@ -30,7 +30,7 @@ impl<S: Stage> SingleAttributeParser<S> for RustcAutodiffParser {
3030
"https://doc.rust-lang.org/std/autodiff/index.html"
3131
);
3232

33-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
33+
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
3434
let list = match args {
3535
ArgParser::NoArgs => return Some(AttributeKind::RustcAutodiff(None)),
3636
ArgParser::List(list) => list,

compiler/rustc_attr_parsing/src/attributes/body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::prelude::*;
44

55
pub(crate) struct CoroutineParser;
66

7-
impl<S: Stage> NoArgsAttributeParser<S> for CoroutineParser {
7+
impl NoArgsAttributeParser for CoroutineParser {
88
const PATH: &[Symbol] = &[sym::coroutine];
99
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Closure)]);
1010
const CREATE: fn(rustc_span::Span) -> AttributeKind = |span| AttributeKind::Coroutine(span);

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_span::{ErrorGuaranteed, Span, Symbol, sym};
2020
use thin_vec::ThinVec;
2121

2222
use crate::attributes::AttributeSafety;
23-
use crate::context::{AcceptContext, ShouldEmit, Stage};
23+
use crate::context::{AcceptContext, ShouldEmit};
2424
use crate::parser::{
2525
AllowExprMetavar, ArgParser, MetaItemListParser, MetaItemOrLitParser, NameValueParser,
2626
};
@@ -40,10 +40,7 @@ const CFG_ATTR_TEMPLATE: AttributeTemplate = template!(
4040
"https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute"
4141
);
4242

43-
pub fn parse_cfg<S: Stage>(
44-
cx: &mut AcceptContext<'_, '_, S>,
45-
args: &ArgParser,
46-
) -> Option<CfgEntry> {
43+
pub fn parse_cfg(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<CfgEntry> {
4744
let ArgParser::List(list) = args else {
4845
let attr_span = cx.attr_span;
4946
cx.adcx().expected_list(attr_span, args);
@@ -85,8 +82,8 @@ pub fn parse_cfg<S: Stage>(
8582
parse_cfg_entry(cx, single).ok()
8683
}
8784

88-
pub fn parse_cfg_entry<S: Stage>(
89-
cx: &mut AcceptContext<'_, '_, S>,
85+
pub fn parse_cfg_entry(
86+
cx: &mut AcceptContext<'_, '_>,
9087
item: &MetaItemOrLitParser,
9188
) -> Result<CfgEntry, ErrorGuaranteed> {
9289
Ok(match item {
@@ -130,8 +127,8 @@ pub fn parse_cfg_entry<S: Stage>(
130127
})
131128
}
132129

133-
fn parse_cfg_entry_version<S: Stage>(
134-
cx: &mut AcceptContext<'_, '_, S>,
130+
fn parse_cfg_entry_version(
131+
cx: &mut AcceptContext<'_, '_>,
135132
list: &MetaItemListParser,
136133
meta_span: Span,
137134
) -> Result<CfgEntry, ErrorGuaranteed> {
@@ -162,8 +159,8 @@ fn parse_cfg_entry_version<S: Stage>(
162159
Ok(CfgEntry::Version(min_version, list.span))
163160
}
164161

165-
fn parse_cfg_entry_target<S: Stage>(
166-
cx: &mut AcceptContext<'_, '_, S>,
162+
fn parse_cfg_entry_target(
163+
cx: &mut AcceptContext<'_, '_>,
167164
list: &MetaItemListParser,
168165
meta_span: Span,
169166
) -> Result<CfgEntry, ErrorGuaranteed> {
@@ -205,12 +202,12 @@ fn parse_cfg_entry_target<S: Stage>(
205202
Ok(CfgEntry::All(result, list.span))
206203
}
207204

208-
pub(crate) fn parse_name_value<S: Stage>(
205+
pub(crate) fn parse_name_value(
209206
name: Symbol,
210207
name_span: Span,
211208
value: Option<&NameValueParser>,
212209
span: Span,
213-
cx: &mut AcceptContext<'_, '_, S>,
210+
cx: &mut AcceptContext<'_, '_>,
214211
) -> Result<CfgEntry, ErrorGuaranteed> {
215212
try_gate_cfg(name, span, cx.sess(), cx.features_option());
216213

compiler/rustc_attr_parsing/src/attributes/cfi_encoding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::prelude::*;
22
pub(crate) struct CfiEncodingParser;
3-
impl<S: Stage> SingleAttributeParser<S> for CfiEncodingParser {
3+
impl SingleAttributeParser for CfiEncodingParser {
44
const PATH: &[Symbol] = &[sym::cfi_encoding];
55
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
66
Allow(Target::Struct),
@@ -10,7 +10,7 @@ impl<S: Stage> SingleAttributeParser<S> for CfiEncodingParser {
1010
]);
1111
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "encoding");
1212

13-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
13+
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
1414
let Some(name_value) = args.name_value() else {
1515
let attr_span = cx.attr_span;
1616
cx.adcx().expected_name_value(attr_span, Some(sym::cfi_encoding));

0 commit comments

Comments
 (0)