@@ -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 } ;
@@ -200,14 +200,18 @@ pub(super) fn transcribe<'a>(
200
200
. create_err ( NoSyntaxVarsExprRepeat { span : seq. span ( ) } ) ) ;
201
201
}
202
202
203
- LockstepIterSize :: Contradiction ( msg ) => {
203
+ LockstepIterSize :: Contradiction { var1_id , var1_len , var2_id , var2_len } => {
204
204
// FIXME: this really ought to be caught at macro definition time... It
205
205
// happens when two meta-variables are used in the same repetition in a
206
206
// sequence, but they come from different sequence matchers and repeat
207
207
// different amounts.
208
- return Err ( cx
209
- . dcx ( )
210
- . create_err ( MetaVarsDifSeqMatchers { span : seq. span ( ) , msg } ) ) ;
208
+ return Err ( cx. dcx ( ) . create_err ( MetaVarsDifSeqMatchers {
209
+ span : seq. span ( ) ,
210
+ var1_id,
211
+ var1_len,
212
+ var2_id,
213
+ var2_len,
214
+ } ) ) ;
211
215
}
212
216
213
217
LockstepIterSize :: Constraint ( len, _) => {
@@ -447,7 +451,7 @@ enum LockstepIterSize {
447
451
Constraint ( usize , MacroRulesNormalizedIdent ) ,
448
452
449
453
/// Two `Constraint`s on the same sequence had different lengths. This is an error.
450
- Contradiction ( String ) ,
454
+ Contradiction { var1_id : String , var1_len : usize , var2_id : String , var2_len : usize } ,
451
455
}
452
456
453
457
impl LockstepIterSize {
@@ -458,23 +462,17 @@ impl LockstepIterSize {
458
462
fn with ( self , other : LockstepIterSize ) -> LockstepIterSize {
459
463
match self {
460
464
LockstepIterSize :: Unconstrained => other,
461
- LockstepIterSize :: Contradiction ( _ ) => self ,
465
+ LockstepIterSize :: Contradiction { .. } => self ,
462
466
LockstepIterSize :: Constraint ( l_len, l_id) => match other {
463
467
LockstepIterSize :: Unconstrained => self ,
464
- LockstepIterSize :: Contradiction ( _ ) => other,
468
+ LockstepIterSize :: Contradiction { .. } => other,
465
469
LockstepIterSize :: Constraint ( r_len, _) if l_len == r_len => self ,
466
- LockstepIterSize :: Constraint ( r_len, r_id) => {
467
- let msg = format ! (
468
- "meta-variable `{}` repeats {} time{}, but `{}` repeats {} time{}" ,
469
- l_id,
470
- l_len,
471
- pluralize!( l_len) ,
472
- r_id,
473
- r_len,
474
- pluralize!( r_len) ,
475
- ) ;
476
- LockstepIterSize :: Contradiction ( msg)
477
- }
470
+ LockstepIterSize :: Constraint ( r_len, r_id) => LockstepIterSize :: Contradiction {
471
+ var1_id : l_id. to_string ( ) ,
472
+ var1_len : l_len,
473
+ var2_id : r_id. to_string ( ) ,
474
+ var2_len : r_len,
475
+ } ,
478
476
} ,
479
477
}
480
478
}
0 commit comments