Skip to content

Commit d6819ac

Browse files
committed
Auto merge of #157570 - JonathanBrouwer:rollup-dEcv5PD, r=JonathanBrouwer
Rollup of 10 pull requests Successful merges: - #157447 (Move cross crate tests into the appropriate folder) - #145108 (Resolver: Batched Import Resolution) - #156119 (Further optimize `SliceIndex<str>` impl for `Range<usize>`) - #157289 (Add infallible primitive type lookups to template arg resolver) - #157540 (Cleanup and optimize `render_impls`) - #157543 (Reorganize `tests/ui/issues` [5/N]) - #156188 (riscv: promote d, e, and f target_features to CfgStableToggleUnstable) - #157323 (Document Repeat::last panic behavior) - #157545 (Suggest using comma to separate valid attribute list items) - #157559 (chore: Update annotate-snippets to 0.12.16)
2 parents 43a4909 + f230678 commit d6819ac

153 files changed

Lines changed: 1065 additions & 804 deletions

File tree

Some content is hidden

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

Cargo.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ dependencies = [
6464

6565
[[package]]
6666
name = "annotate-snippets"
67-
version = "0.12.15"
67+
version = "0.12.16"
6868
source = "registry+https://github.com/rust-lang/crates.io-index"
69-
checksum = "92570a3f9c98e7e84df84b71d0965ac99b1871fcd75a3773a3bd1bad13f64cf7"
69+
checksum = "f211a51805bc641f3ad5b7664c77d2547af685cc33b4cd8d31964027a46f13f1"
7070
dependencies = [
7171
"anstyle",
7272
"memchr",
@@ -3958,7 +3958,7 @@ dependencies = [
39583958
name = "rustc_errors"
39593959
version = "0.0.0"
39603960
dependencies = [
3961-
"annotate-snippets 0.12.15",
3961+
"annotate-snippets 0.12.16",
39623962
"anstream",
39633963
"anstyle",
39643964
"derive_setters",

compiler/rustc_attr_parsing/src/parser.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use thin_vec::ThinVec;
3030

3131
use crate::ShouldEmit;
3232
use crate::session_diagnostics::{
33-
InvalidMetaItem, InvalidMetaItemQuoteIdentSugg, InvalidMetaItemRemoveNegSugg, MetaBadDelim,
34-
MetaBadDelimSugg, SuffixedLiteralInAttribute,
33+
ExpectedComma, InvalidMetaItem, InvalidMetaItemQuoteIdentSugg, InvalidMetaItemRemoveNegSugg,
34+
MetaBadDelim, MetaBadDelimSugg, SuffixedLiteralInAttribute,
3535
};
3636

3737
#[derive(Clone, Debug)]
@@ -704,6 +704,29 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
704704
self.parser.dcx().create_err(err)
705705
}
706706

707+
fn should_continue_parsing_meta_items(&mut self) -> Result<bool, Diag<'sess>> {
708+
if self.parser.eat(exp!(Comma)) {
709+
return Ok(true);
710+
} else if self.parser.token == token::Eof {
711+
return Ok(false);
712+
}
713+
714+
let mut snapshot = self.parser.create_snapshot_for_diagnostic();
715+
if matches!(self.should_emit, ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed }) {
716+
let span = self.parser.prev_token.span.shrink_to_hi();
717+
self.should_emit = ShouldEmit::Nothing;
718+
match self.parse_meta_item_inner() {
719+
Ok(_) => {
720+
return Err(self.parser.dcx().create_err(ExpectedComma { span }));
721+
}
722+
Err(e) => {
723+
e.cancel();
724+
}
725+
}
726+
}
727+
snapshot.unexpected_any()
728+
}
729+
707730
fn parse(
708731
tokens: TokenStream,
709732
psess: &'sess ParseSess,
@@ -724,15 +747,11 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
724747
while this.parser.token != token::Eof {
725748
sub_parsers.push(this.parse_meta_item_inner()?);
726749

727-
if !this.parser.eat(exp!(Comma)) {
750+
if !this.should_continue_parsing_meta_items()? {
728751
break;
729752
}
730753
}
731754

732-
if parser.token != token::Eof {
733-
parser.unexpected()?;
734-
}
735-
736755
Ok(MetaItemListParser { sub_parsers, span })
737756
}
738757
}

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,3 +1032,16 @@ pub(crate) struct SanitizeInvalidStatic {
10321032
pub span: Span,
10331033
pub field: &'static str,
10341034
}
1035+
1036+
#[derive(Diagnostic)]
1037+
#[diag("attribute items not separated with `,`")]
1038+
pub(crate) struct ExpectedComma {
1039+
#[primary_span]
1040+
#[suggestion(
1041+
"try adding `,` here",
1042+
code = ",",
1043+
applicability = "maybe-incorrect",
1044+
style = "short"
1045+
)]
1046+
pub span: Span,
1047+
}

compiler/rustc_errors/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
annotate-snippets = { version = "0.12.15", features = ["simd"] }
8+
annotate-snippets = { version = "0.12.16", features = ["simd"] }
99
anstream = "0.6.20"
1010
anstyle = "1.0.13"
1111
derive_setters = "0.1.6"

0 commit comments

Comments
 (0)