Skip to content

Commit 91dec80

Browse files
committed
add expected_list_with_num_args_or_more attribute parsing error
1 parent a6525d5 commit 91dec80

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,10 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
490490
self.emit_parse_error(span, AttributeParseErrorReason::ExpectedList)
491491
}
492492

493+
pub(crate) fn expected_list_with_num_args_or_more(&self, args: usize, span: Span) -> ErrorGuaranteed {
494+
self.emit_parse_error(span, AttributeParseErrorReason::ExpectedListWithNumArgsOrMore { args})
495+
}
496+
493497
pub(crate) fn expected_list_or_no_args(&self, span: Span) -> ErrorGuaranteed {
494498
self.emit_parse_error(span, AttributeParseErrorReason::ExpectedListOrNoArgs)
495499
}

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@ pub(crate) enum AttributeParseErrorReason<'a> {
520520
ExpectedSingleArgument,
521521
ExpectedList,
522522
ExpectedListOrNoArgs,
523+
ExpectedListWithNumArgsOrMore {
524+
args: usize,
525+
},
523526
ExpectedNameValueOrNoArgs,
524527
UnexpectedLiteral,
525528
ExpectedNameValue(Option<Symbol>),
@@ -596,6 +599,9 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError<'_> {
596599
AttributeParseErrorReason::ExpectedListOrNoArgs => {
597600
diag.span_label(self.span, "expected a list or no arguments here");
598601
}
602+
AttributeParseErrorReason::ExpectedListWithNumArgsOrMore { args } => {
603+
diag.span_label(self.span, format!("expected {args} or more items"));
604+
}
599605
AttributeParseErrorReason::ExpectedNameValueOrNoArgs => {
600606
diag.span_label(self.span, "didn't expect a list here");
601607
}

0 commit comments

Comments
 (0)