This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +46
-17
lines changed
compiler/rustc_expand/src/mbe
ui/macros/macro-metavar-expr-concat Expand file tree Collapse file tree 4 files changed +46
-17
lines changed Original file line number Diff line number Diff line change @@ -696,8 +696,10 @@ fn transcribe_metavar_expr<'a>(
696696 MetaVarExprConcatElem :: Var ( ident) => {
697697 match matched_from_ident ( dcx, * ident, interp) ? {
698698 NamedMatch :: MatchedSeq ( named_matches) => {
699- let curr_idx = repeats. last ( ) . unwrap ( ) . 0 ;
700- match & named_matches[ curr_idx] {
699+ let Some ( ( curr_idx, _) ) = repeats. last ( ) else {
700+ return Err ( dcx. struct_span_err ( sp. entire ( ) , "invalid syntax" ) ) ;
701+ } ;
702+ match & named_matches[ * curr_idx] {
701703 // FIXME(c410-f3r) Nested repetitions are unimplemented
702704 MatchedSeq ( _) => unimplemented ! ( ) ,
703705 MatchedSingle ( pnr) => {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- //@ run-pass
2-
31#![ feature( macro_metavar_expr_concat) ]
42
53macro_rules! one_rep {
@@ -10,9 +8,29 @@ macro_rules! one_rep {
108 } ;
119}
1210
11+ macro_rules! issue_128346 {
12+ ( $( $a: ident) * ) => {
13+ A (
14+ const ${ concat( $a, Z ) } : i32 = 3 ;
15+ //~^ ERROR invalid syntax
16+ ) *
17+ } ;
18+ }
19+
20+ macro_rules! issue_131393 {
21+ ( $t: ident $( $en: ident) ?) => {
22+ read:: <${ concat( $t, $en) } >( )
23+ //~^ ERROR invalid syntax
24+ //~| ERROR invalid syntax
25+ }
26+ }
27+
1328fn main ( ) {
1429 one_rep ! ( A B C ) ;
1530 assert_eq ! ( AZ , 3 ) ;
1631 assert_eq ! ( BZ , 3 ) ;
1732 assert_eq ! ( CZ , 3 ) ;
33+ issue_128346 ! ( A B C ) ;
34+ issue_131393 ! ( u8 ) ;
35+ issue_131393 ! ( u16 le) ;
1836}
Original file line number Diff line number Diff line change 1+ error: invalid syntax
2+ --> $DIR/repetitions.rs:14:20
3+ |
4+ LL | const ${concat($a, Z)}: i32 = 3;
5+ | ^^^^^^^^^^^^^^^
6+
7+ error: invalid syntax
8+ --> $DIR/repetitions.rs:22:17
9+ |
10+ LL | read::<${concat($t, $en)}>()
11+ | ^^^^^^^^^^^^^^^^^
12+
13+ error: invalid syntax
14+ --> $DIR/repetitions.rs:22:17
15+ |
16+ LL | read::<${concat($t, $en)}>()
17+ | ^^^^^^^^^^^^^^^^^
18+ |
19+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
20+
21+ error: aborting due to 3 previous errors
22+
You can’t perform that action at this time.
0 commit comments