@@ -9,6 +9,7 @@ use rustc_errors::{pluralize, PResult};
9
9
use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed } ;
10
10
use rustc_span:: hygiene:: { LocalExpnId , Transparency } ;
11
11
use rustc_span:: symbol:: { sym, Ident , MacroRulesNormalizedIdent } ;
12
+ use rustc_macros:: SessionDiagnostic ;
12
13
use rustc_span:: Span ;
13
14
14
15
use smallvec:: { smallvec, SmallVec } ;
@@ -53,6 +54,13 @@ impl<'a> Iterator for Frame<'a> {
53
54
}
54
55
}
55
56
57
+ #[ derive( SessionDiagnostic ) ]
58
+ #[ error( expand:: expr_repeat_no_syntax_vars) ]
59
+ struct NoSyntaxVarsExprRepeat {
60
+ #[ primary_span]
61
+ span : Span ,
62
+ }
63
+
56
64
/// This can do Macro-By-Example transcription.
57
65
/// - `interp` is a map of meta-variables to the tokens (non-terminals) they matched in the
58
66
/// invocation. We are assuming we already know there is a match.
@@ -165,11 +173,7 @@ pub(super) fn transcribe<'a>(
165
173
seq @ mbe:: TokenTree :: Sequence ( _, delimited) => {
166
174
match lockstep_iter_size ( & seq, interp, & repeats) {
167
175
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 ( ) } ) ) ;
173
177
}
174
178
175
179
LockstepIterSize :: Contradiction ( msg) => {
0 commit comments