Skip to content

Commit 0e4bfb5

Browse files
authored
Rollup merge of rust-lang#149789 - JonathanBrouwer:remove-lifetime-param, r=jdonszelmann
Cleanup in the attribute parsers * Removes a bunch of unused lifetimes in the attribute parsers * Creates two variants of `PathParser`, because we statically know which variant we're in r? `@jdonszelmann`
2 parents 3fee0ee + aa6db80 commit 0e4bfb5

26 files changed

+190
-218
lines changed

compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ impl<S: Stage> CombineAttributeParser<S> for AllowInternalUnstableParser {
1717
]);
1818
const TEMPLATE: AttributeTemplate = template!(Word, List: &["feat1, feat2, ..."]);
1919

20-
fn extend<'c>(
21-
cx: &'c mut AcceptContext<'_, '_, S>,
22-
args: &'c ArgParser<'_>,
20+
fn extend(
21+
cx: &mut AcceptContext<'_, '_, S>,
22+
args: &ArgParser,
2323
) -> impl IntoIterator<Item = Self::Item> {
2424
parse_unstable(cx, args, <Self as CombineAttributeParser<S>>::PATH[0])
2525
.into_iter()
@@ -39,9 +39,9 @@ impl<S: Stage> CombineAttributeParser<S> for UnstableFeatureBoundParser {
3939
]);
4040
const TEMPLATE: AttributeTemplate = template!(Word, List: &["feat1, feat2, ..."]);
4141

42-
fn extend<'c>(
43-
cx: &'c mut AcceptContext<'_, '_, S>,
44-
args: &'c ArgParser<'_>,
42+
fn extend(
43+
cx: &mut AcceptContext<'_, '_, S>,
44+
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 });
@@ -67,17 +67,17 @@ impl<S: Stage> CombineAttributeParser<S> for AllowConstFnUnstableParser {
6767
]);
6868
const TEMPLATE: AttributeTemplate = template!(Word, List: &["feat1, feat2, ..."]);
6969

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

7878
fn parse_unstable<S: Stage>(
7979
cx: &AcceptContext<'_, '_, S>,
80-
args: &ArgParser<'_>,
80+
args: &ArgParser,
8181
symbol: Symbol,
8282
) -> impl IntoIterator<Item = Symbol> {
8383
let mut res = Vec::new();

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ const CFG_ATTR_TEMPLATE: AttributeTemplate = template!(
3535
"https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute"
3636
);
3737

38-
pub fn parse_cfg<'c, S: Stage>(
39-
cx: &'c mut AcceptContext<'_, '_, S>,
40-
args: &'c ArgParser<'_>,
38+
pub fn parse_cfg<S: Stage>(
39+
cx: &mut AcceptContext<'_, '_, S>,
40+
args: &ArgParser,
4141
) -> Option<CfgEntry> {
4242
let ArgParser::List(list) = args else {
4343
cx.expected_list(cx.attr_span);
@@ -52,7 +52,7 @@ pub fn parse_cfg<'c, S: Stage>(
5252

5353
pub fn parse_cfg_entry<S: Stage>(
5454
cx: &mut AcceptContext<'_, '_, S>,
55-
item: &MetaItemOrLitParser<'_>,
55+
item: &MetaItemOrLitParser,
5656
) -> Result<CfgEntry, ErrorGuaranteed> {
5757
Ok(match item {
5858
MetaItemOrLitParser::MetaItemParser(meta) => match meta.args() {
@@ -98,7 +98,7 @@ pub fn parse_cfg_entry<S: Stage>(
9898

9999
fn parse_cfg_entry_version<S: Stage>(
100100
cx: &mut AcceptContext<'_, '_, S>,
101-
list: &MetaItemListParser<'_>,
101+
list: &MetaItemListParser,
102102
meta_span: Span,
103103
) -> Result<CfgEntry, ErrorGuaranteed> {
104104
try_gate_cfg(sym::version, meta_span, cx.sess(), cx.features_option());
@@ -130,7 +130,7 @@ fn parse_cfg_entry_version<S: Stage>(
130130

131131
fn parse_cfg_entry_target<S: Stage>(
132132
cx: &mut AcceptContext<'_, '_, S>,
133-
list: &MetaItemListParser<'_>,
133+
list: &MetaItemListParser,
134134
meta_span: Span,
135135
) -> Result<CfgEntry, ErrorGuaranteed> {
136136
if let Some(features) = cx.features_option()

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl<S: Stage> SingleAttributeParser<S> for OptimizeParser {
2323
]);
2424
const TEMPLATE: AttributeTemplate = template!(List: &["size", "speed", "none"]);
2525

26-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
26+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
2727
let Some(list) = args.list() else {
2828
cx.expected_list(cx.attr_span);
2929
return None;
@@ -84,7 +84,7 @@ impl<S: Stage> SingleAttributeParser<S> for CoverageParser {
8484
]);
8585
const TEMPLATE: AttributeTemplate = template!(OneOf: &[sym::off, sym::on]);
8686

87-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
87+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
8888
let Some(args) = args.list() else {
8989
cx.expected_specific_argument_and_list(cx.attr_span, &[sym::on, sym::off]);
9090
return None;
@@ -135,7 +135,7 @@ impl<S: Stage> SingleAttributeParser<S> for ExportNameParser {
135135
]);
136136
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");
137137

138-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
138+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
139139
let Some(nv) = args.name_value() else {
140140
cx.expected_name_value(cx.attr_span, None);
141141
return None;
@@ -164,7 +164,7 @@ impl<S: Stage> SingleAttributeParser<S> for ObjcClassParser {
164164
AllowedTargets::AllowList(&[Allow(Target::ForeignStatic)]);
165165
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "ClassName");
166166

167-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
167+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
168168
let Some(nv) = args.name_value() else {
169169
cx.expected_name_value(cx.attr_span, None);
170170
return None;
@@ -196,7 +196,7 @@ impl<S: Stage> SingleAttributeParser<S> for ObjcSelectorParser {
196196
AllowedTargets::AllowList(&[Allow(Target::ForeignStatic)]);
197197
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "methodName");
198198

199-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
199+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
200200
let Some(nv) = args.name_value() else {
201201
cx.expected_name_value(cx.attr_span, None);
202202
return None;
@@ -472,10 +472,10 @@ impl<S: Stage> AttributeParser<S> for UsedParser {
472472
}
473473
}
474474

475-
fn parse_tf_attribute<'c, S: Stage>(
476-
cx: &'c mut AcceptContext<'_, '_, S>,
477-
args: &'c ArgParser<'_>,
478-
) -> impl IntoIterator<Item = (Symbol, Span)> + 'c {
475+
fn parse_tf_attribute<S: Stage>(
476+
cx: &mut AcceptContext<'_, '_, S>,
477+
args: &ArgParser,
478+
) -> impl IntoIterator<Item = (Symbol, Span)> {
479479
let mut features = Vec::new();
480480
let ArgParser::List(list) = args else {
481481
cx.expected_list(cx.attr_span);
@@ -529,10 +529,10 @@ impl<S: Stage> CombineAttributeParser<S> for TargetFeatureParser {
529529
};
530530
const TEMPLATE: AttributeTemplate = template!(List: &["enable = \"feat1, feat2\""]);
531531

532-
fn extend<'c>(
533-
cx: &'c mut AcceptContext<'_, '_, S>,
534-
args: &'c ArgParser<'_>,
535-
) -> impl IntoIterator<Item = Self::Item> + 'c {
532+
fn extend(
533+
cx: &mut AcceptContext<'_, '_, S>,
534+
args: &ArgParser,
535+
) -> impl IntoIterator<Item = Self::Item> {
536536
parse_tf_attribute(cx, args)
537537
}
538538

@@ -567,10 +567,10 @@ impl<S: Stage> CombineAttributeParser<S> for ForceTargetFeatureParser {
567567
Allow(Target::Method(MethodKind::TraitImpl)),
568568
]);
569569

570-
fn extend<'c>(
571-
cx: &'c mut AcceptContext<'_, '_, S>,
572-
args: &'c ArgParser<'_>,
573-
) -> impl IntoIterator<Item = Self::Item> + 'c {
570+
fn extend(
571+
cx: &mut AcceptContext<'_, '_, S>,
572+
args: &ArgParser,
573+
) -> impl IntoIterator<Item = Self::Item> {
574574
parse_tf_attribute(cx, args)
575575
}
576576
}
@@ -599,7 +599,7 @@ impl<S: Stage> SingleAttributeParser<S> for SanitizeParser {
599599
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
600600
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
601601

602-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
602+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
603603
let Some(list) = args.list() else {
604604
cx.expected_list(cx.attr_span);
605605
return None;

compiler/rustc_attr_parsing/src/attributes/crate_level.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl<S: Stage> SingleAttributeParser<S> for CrateNameParser {
1111
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");
1212
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::CrateLevel;
1313

14-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
14+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
1515
let ArgParser::NameValue(n) = args else {
1616
cx.expected_name_value(cx.attr_span, None);
1717
return None;
@@ -35,7 +35,7 @@ impl<S: Stage> SingleAttributeParser<S> for RecursionLimitParser {
3535
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "N", "https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute");
3636
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::CrateLevel;
3737

38-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
38+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
3939
let ArgParser::NameValue(nv) = args else {
4040
cx.expected_name_value(cx.attr_span, None);
4141
return None;
@@ -58,7 +58,7 @@ impl<S: Stage> SingleAttributeParser<S> for MoveSizeLimitParser {
5858
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "N");
5959
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::CrateLevel;
6060

61-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
61+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
6262
let ArgParser::NameValue(nv) = args else {
6363
cx.expected_name_value(cx.attr_span, None);
6464
return None;
@@ -81,7 +81,7 @@ impl<S: Stage> SingleAttributeParser<S> for TypeLengthLimitParser {
8181
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "N");
8282
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::CrateLevel;
8383

84-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
84+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
8585
let ArgParser::NameValue(nv) = args else {
8686
cx.expected_name_value(cx.attr_span, None);
8787
return None;
@@ -104,7 +104,7 @@ impl<S: Stage> SingleAttributeParser<S> for PatternComplexityLimitParser {
104104
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "N");
105105
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::CrateLevel;
106106

107-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
107+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
108108
let ArgParser::NameValue(nv) = args else {
109109
cx.expected_name_value(cx.attr_span, None);
110110
return None;
@@ -154,7 +154,7 @@ impl<S: Stage> SingleAttributeParser<S> for WindowsSubsystemParser {
154154
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::CrateLevel;
155155
const TEMPLATE: AttributeTemplate = template!(NameValueStr: ["windows", "console"], "https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute");
156156

157-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
157+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
158158
let Some(nv) = args.name_value() else {
159159
cx.expected_name_value(
160160
args.span().unwrap_or(cx.inner_span),

compiler/rustc_attr_parsing/src/attributes/debugger.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ impl<S: Stage> CombineAttributeParser<S> for DebuggerViualizerParser {
1616
type Item = DebugVisualizer;
1717
const CONVERT: ConvertFn<Self::Item> = |v, _| AttributeKind::DebuggerVisualizer(v);
1818

19-
fn extend<'c>(
20-
cx: &'c mut AcceptContext<'_, '_, S>,
21-
args: &'c ArgParser<'_>,
22-
) -> impl IntoIterator<Item = Self::Item> + 'c {
19+
fn extend(
20+
cx: &mut AcceptContext<'_, '_, S>,
21+
args: &ArgParser,
22+
) -> impl IntoIterator<Item = Self::Item> {
2323
let Some(l) = args.list() else {
2424
cx.expected_list(args.span().unwrap_or(cx.attr_span));
2525
return None;

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn get<S: Stage>(
1212
cx: &AcceptContext<'_, '_, S>,
1313
name: Symbol,
1414
param_span: Span,
15-
arg: &ArgParser<'_>,
15+
arg: &ArgParser,
1616
item: &Option<Symbol>,
1717
) -> Option<Symbol> {
1818
if item.is_some() {
@@ -68,7 +68,7 @@ impl<S: Stage> SingleAttributeParser<S> for DeprecationParser {
6868
NameValueStr: "reason"
6969
);
7070

71-
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
71+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
7272
let features = cx.features();
7373

7474
let mut since = None;

0 commit comments

Comments
 (0)