about summary refs log tree commit diff
path: root/compiler/rustc_expand
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-09-02 17:08:54 +0200
committerGitHub <noreply@github.com>2025-09-02 17:08:54 +0200
commit7b2bfa361e74c0c0b34bfe3c52e696d8bc6d4330 (patch)
tree2df1fbc1d75d6bc950b15ff569908801303b5d9f /compiler/rustc_expand
parent5d855c6b9e72d1dd55bfcb0d86e80116bc3c0272 (diff)
parentf6e7c81061c24a2210149ff94670d8672bd0224a (diff)
downloadrust-7b2bfa361e74c0c0b34bfe3c52e696d8bc6d4330.tar.gz
rust-7b2bfa361e74c0c0b34bfe3c52e696d8bc6d4330.zip
Rollup merge of #146064 - jullanggit:patch-1, r=fmease
Add compiler error when trying to use concat metavar expr in repetitions

## Disclaimer
This is my first PR to rust, so if I missed/could improve something about this PR, please excuse and tell me!
## The improvement
The [metavar_expr_concat feature](https://github.com/rust-lang/rust/issues/124225) currently does not seem to support nested repetitions, and throws an ICE without much explanation if the relevant code path is hit.
This PR adds a draft compiler error that attempts to explain the issue. I am not 100% sure what all the ways of triggering this error are, so the message is currently pretty generic, please do correct me if there's something wrong with it or it could be improved.

Thank you for you time!

Fixes rust-lang/rust#140479.
Diffstat (limited to 'compiler/rustc_expand')
-rw-r--r--compiler/rustc_expand/src/mbe/transcribe.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs
index 174844d6ad6..e4e4866b64c 100644
--- a/compiler/rustc_expand/src/mbe/transcribe.rs
+++ b/compiler/rustc_expand/src/mbe/transcribe.rs
@@ -556,7 +556,12 @@ fn metavar_expr_concat<'tx>(
                         };
                         match &named_matches[*curr_idx] {
                             // FIXME(c410-f3r) Nested repetitions are unimplemented
-                            MatchedSeq(_) => unimplemented!(),
+                            MatchedSeq(_) => {
+                                return Err(dcx.struct_span_err(
+                                    ident.span,
+                                    "nested repetitions with `${concat(...)}` metavariable expressions are not yet supported",
+                                ));
+                            }
                             MatchedSingle(pnr) => extract_symbol_from_pnr(dcx, pnr, ident.span)?,
                         }
                     }