@@ -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 } ;
@@ -200,14 +200,18 @@ pub(super) fn transcribe<'a>(
200200 . create_err ( NoSyntaxVarsExprRepeat { span : seq. span ( ) } ) ) ;
201201 }
202202
203- LockstepIterSize :: Contradiction ( msg ) => {
203+ LockstepIterSize :: Contradiction { var1_id , var1_len , var2_id , var2_len } => {
204204 // FIXME: this really ought to be caught at macro definition time... It
205205 // happens when two meta-variables are used in the same repetition in a
206206 // sequence, but they come from different sequence matchers and repeat
207207 // 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+ } ) ) ;
211215 }
212216
213217 LockstepIterSize :: Constraint ( len, _) => {
@@ -447,7 +451,7 @@ enum LockstepIterSize {
447451 Constraint ( usize , MacroRulesNormalizedIdent ) ,
448452
449453 /// 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 } ,
451455}
452456
453457impl LockstepIterSize {
@@ -458,23 +462,17 @@ impl LockstepIterSize {
458462 fn with ( self , other : LockstepIterSize ) -> LockstepIterSize {
459463 match self {
460464 LockstepIterSize :: Unconstrained => other,
461- LockstepIterSize :: Contradiction ( _ ) => self ,
465+ LockstepIterSize :: Contradiction { .. } => self ,
462466 LockstepIterSize :: Constraint ( l_len, l_id) => match other {
463467 LockstepIterSize :: Unconstrained => self ,
464- LockstepIterSize :: Contradiction ( _ ) => other,
468+ LockstepIterSize :: Contradiction { .. } => other,
465469 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+ } ,
478476 } ,
479477 }
480478 }
0 commit comments