@@ -9,7 +9,7 @@ use rustc_ast::mut_visit::{self, MutVisitor};
99use rustc_ast:: token:: { self , Delimiter , Token , TokenKind } ;
1010use rustc_ast:: tokenstream:: { DelimSpacing , DelimSpan , Spacing , TokenStream , TokenTree } ;
1111use rustc_data_structures:: fx:: FxHashMap ;
12- use rustc_errors:: { pluralize , Diag , PResult } ;
12+ use rustc_errors:: { Diag , PResult } ;
1313use rustc_parse:: parser:: ParseNtResult ;
1414use rustc_span:: hygiene:: { LocalExpnId , Transparency } ;
1515use rustc_span:: symbol:: { sym, Ident , MacroRulesNormalizedIdent } ;
@@ -206,14 +206,18 @@ pub(super) fn transcribe<'a>(
206206 . create_err ( NoSyntaxVarsExprRepeat { span : seq. span ( ) } ) ) ;
207207 }
208208
209- LockstepIterSize :: Contradiction ( msg ) => {
209+ LockstepIterSize :: Contradiction { var1_id , var1_len , var2_id , var2_len } => {
210210 // FIXME: this really ought to be caught at macro definition time... It
211211 // happens when two meta-variables are used in the same repetition in a
212212 // sequence, but they come from different sequence matchers and repeat
213213 // 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+ } ) ) ;
217221 }
218222
219223 LockstepIterSize :: Constraint ( len, _) => {
@@ -459,7 +463,7 @@ enum LockstepIterSize {
459463 Constraint ( usize , MacroRulesNormalizedIdent ) ,
460464
461465 /// 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 } ,
463467}
464468
465469impl LockstepIterSize {
@@ -470,23 +474,17 @@ impl LockstepIterSize {
470474 fn with ( self , other : LockstepIterSize ) -> LockstepIterSize {
471475 match self {
472476 LockstepIterSize :: Unconstrained => other,
473- LockstepIterSize :: Contradiction ( _ ) => self ,
477+ LockstepIterSize :: Contradiction { .. } => self ,
474478 LockstepIterSize :: Constraint ( l_len, l_id) => match other {
475479 LockstepIterSize :: Unconstrained => self ,
476- LockstepIterSize :: Contradiction ( _ ) => other,
480+ LockstepIterSize :: Contradiction { .. } => other,
477481 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+ } ,
490488 } ,
491489 }
492490 }
0 commit comments