@@ -9,6 +9,7 @@ use rustc_errors::{pluralize, PResult};
99use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed } ;
1010use rustc_span:: hygiene:: { LocalExpnId , Transparency } ;
1111use rustc_span:: symbol:: { sym, Ident , MacroRulesNormalizedIdent } ;
12+ use rustc_macros:: SessionDiagnostic ;
1213use rustc_span:: Span ;
1314
1415use smallvec:: { smallvec, SmallVec } ;
@@ -53,6 +54,13 @@ impl<'a> Iterator for Frame<'a> {
5354 }
5455}
5556
57+ #[ derive( SessionDiagnostic ) ]
58+ #[ error( expand:: expr_repeat_no_syntax_vars) ]
59+ struct NoSyntaxVarsExprRepeat {
60+ #[ primary_span]
61+ span : Span ,
62+ }
63+
5664/// This can do Macro-By-Example transcription.
5765/// - `interp` is a map of meta-variables to the tokens (non-terminals) they matched in the
5866/// invocation. We are assuming we already know there is a match.
@@ -165,11 +173,7 @@ pub(super) fn transcribe<'a>(
165173 seq @ mbe:: TokenTree :: Sequence ( _, delimited) => {
166174 match lockstep_iter_size ( & seq, interp, & repeats) {
167175 LockstepIterSize :: Unconstrained => {
168- return Err ( cx. struct_span_err (
169- seq. span ( ) , /* blame macro writer */
170- "attempted to repeat an expression containing no syntax variables \
171- matched as repeating at this depth",
172- ) ) ;
176+ return Err ( cx. create_err ( NoSyntaxVarsExprRepeat { span : seq. span ( ) } ) ) ;
173177 }
174178
175179 LockstepIterSize :: Contradiction ( msg) => {
0 commit comments