@@ -9,7 +9,7 @@ use rustc_ast::mut_visit::{self, MutVisitor};
9
9
use rustc_ast:: token:: { self , Delimiter , Token , TokenKind } ;
10
10
use rustc_ast:: tokenstream:: { DelimSpacing , DelimSpan , Spacing , TokenStream , TokenTree } ;
11
11
use rustc_data_structures:: fx:: FxHashMap ;
12
- use rustc_errors:: { pluralize , Diag , PResult } ;
12
+ use rustc_errors:: { Diag , PResult } ;
13
13
use rustc_parse:: parser:: ParseNtResult ;
14
14
use rustc_span:: hygiene:: { LocalExpnId , Transparency } ;
15
15
use rustc_span:: symbol:: { sym, Ident , MacroRulesNormalizedIdent } ;
@@ -206,14 +206,18 @@ pub(super) fn transcribe<'a>(
206
206
. create_err ( NoSyntaxVarsExprRepeat { span : seq. span ( ) } ) ) ;
207
207
}
208
208
209
- LockstepIterSize :: Contradiction ( msg ) => {
209
+ LockstepIterSize :: Contradiction { var1_id , var1_len , var2_id , var2_len } => {
210
210
// FIXME: this really ought to be caught at macro definition time... It
211
211
// happens when two meta-variables are used in the same repetition in a
212
212
// sequence, but they come from different sequence matchers and repeat
213
213
// different amounts.
214
- return Err ( cx
215
- . dcx ( )
216
- . create_err ( MetaVarsDifSeqMatchers { span : seq. span ( ) , msg } ) ) ;
214
+ return Err ( cx. dcx ( ) . create_err ( MetaVarsDifSeqMatchers {
215
+ span : seq. span ( ) ,
216
+ var1_id,
217
+ var1_len,
218
+ var2_id,
219
+ var2_len,
220
+ } ) ) ;
217
221
}
218
222
219
223
LockstepIterSize :: Constraint ( len, _) => {
@@ -459,7 +463,7 @@ enum LockstepIterSize {
459
463
Constraint ( usize , MacroRulesNormalizedIdent ) ,
460
464
461
465
/// Two `Constraint`s on the same sequence had different lengths. This is an error.
462
- Contradiction ( String ) ,
466
+ Contradiction { var1_id : String , var1_len : usize , var2_id : String , var2_len : usize } ,
463
467
}
464
468
465
469
impl LockstepIterSize {
@@ -470,23 +474,17 @@ impl LockstepIterSize {
470
474
fn with ( self , other : LockstepIterSize ) -> LockstepIterSize {
471
475
match self {
472
476
LockstepIterSize :: Unconstrained => other,
473
- LockstepIterSize :: Contradiction ( _ ) => self ,
477
+ LockstepIterSize :: Contradiction { .. } => self ,
474
478
LockstepIterSize :: Constraint ( l_len, l_id) => match other {
475
479
LockstepIterSize :: Unconstrained => self ,
476
- LockstepIterSize :: Contradiction ( _ ) => other,
480
+ LockstepIterSize :: Contradiction { .. } => other,
477
481
LockstepIterSize :: Constraint ( r_len, _) if l_len == r_len => self ,
478
- LockstepIterSize :: Constraint ( r_len, r_id) => {
479
- let msg = format ! (
480
- "meta-variable `{}` repeats {} time{}, but `{}` repeats {} time{}" ,
481
- l_id,
482
- l_len,
483
- pluralize!( l_len) ,
484
- r_id,
485
- r_len,
486
- pluralize!( r_len) ,
487
- ) ;
488
- LockstepIterSize :: Contradiction ( msg)
489
- }
482
+ LockstepIterSize :: Constraint ( r_len, r_id) => LockstepIterSize :: Contradiction {
483
+ var1_id : l_id. to_string ( ) ,
484
+ var1_len : l_len,
485
+ var2_id : r_id. to_string ( ) ,
486
+ var2_len : r_len,
487
+ } ,
490
488
} ,
491
489
}
492
490
}
0 commit comments