File tree 4 files changed +46
-17
lines changed
compiler/rustc_expand/src/mbe
ui/macros/macro-metavar-expr-concat
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>(
696
696
MetaVarExprConcatElem :: Var ( ident) => {
697
697
match matched_from_ident ( dcx, * ident, interp) ? {
698
698
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] {
701
703
// FIXME(c410-f3r) Nested repetitions are unimplemented
702
704
MatchedSeq ( _) => unimplemented ! ( ) ,
703
705
MatchedSingle ( pnr) => {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- //@ run-pass
2
-
3
1
#![ feature( macro_metavar_expr_concat) ]
4
2
5
3
macro_rules! one_rep {
@@ -10,9 +8,29 @@ macro_rules! one_rep {
10
8
} ;
11
9
}
12
10
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
+
13
28
fn main ( ) {
14
29
one_rep ! ( A B C ) ;
15
30
assert_eq ! ( AZ , 3 ) ;
16
31
assert_eq ! ( BZ , 3 ) ;
17
32
assert_eq ! ( CZ , 3 ) ;
33
+ issue_128346 ! ( A B C ) ;
34
+ issue_131393 ! ( u8 ) ;
35
+ issue_131393 ! ( u16 le) ;
18
36
}
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