1
Fork 0

Rollup merge of #131522 - c410-f3r:unlock-rfc-2011, r=chenyukang

[macro_metavar_expr_concat] Fix #128346

Fix #128346
Fix #131393

The syntax is invalid in both issues so I guess that theoretically the compiler should have aborted early.

This PR tries to fix a local problem but let me know if there are better options.

cc `@petrochenkov` if you are interested
This commit is contained in:
Jacob Pratt 2024-12-26 21:56:47 -05:00 committed by GitHub
commit b919afa70f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 17 deletions

View file

@ -697,8 +697,10 @@ fn transcribe_metavar_expr<'a>(
MetaVarExprConcatElem::Var(ident) => {
match matched_from_ident(dcx, *ident, interp)? {
NamedMatch::MatchedSeq(named_matches) => {
let curr_idx = repeats.last().unwrap().0;
match &named_matches[curr_idx] {
let Some((curr_idx, _)) = repeats.last() else {
return Err(dcx.struct_span_err(sp.entire(), "invalid syntax"));
};
match &named_matches[*curr_idx] {
// FIXME(c410-f3r) Nested repetitions are unimplemented
MatchedSeq(_) => unimplemented!(),
MatchedSingle(pnr) => {