Added first migration for repeated expressions without syntax vars

This commit is contained in:
nidnogg 2022-08-16 18:34:13 -03:00
parent a39bdb1d6b
commit 7e15fbab75
2 changed files with 12 additions and 5 deletions

View file

@ -9,6 +9,7 @@ use rustc_errors::{pluralize, PResult};
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
use rustc_span::hygiene::{LocalExpnId, Transparency};
use rustc_span::symbol::{sym, Ident, MacroRulesNormalizedIdent};
use rustc_macros::SessionDiagnostic;
use rustc_span::Span;
use smallvec::{smallvec, SmallVec};
@ -53,6 +54,13 @@ impl<'a> Iterator for Frame<'a> {
}
}
#[derive(SessionDiagnostic)]
#[error(expand::expr_repeat_no_syntax_vars)]
struct NoSyntaxVarsExprRepeat {
#[primary_span]
span: Span,
}
/// This can do Macro-By-Example transcription.
/// - `interp` is a map of meta-variables to the tokens (non-terminals) they matched in the
/// invocation. We are assuming we already know there is a match.
@ -165,11 +173,7 @@ pub(super) fn transcribe<'a>(
seq @ mbe::TokenTree::Sequence(_, delimited) => {
match lockstep_iter_size(&seq, interp, &repeats) {
LockstepIterSize::Unconstrained => {
return Err(cx.struct_span_err(
seq.span(), /* blame macro writer */
"attempted to repeat an expression containing no syntax variables \
matched as repeating at this depth",
));
return Err(cx.create_err(NoSyntaxVarsExprRepeat { span: seq.span() }));
}
LockstepIterSize::Contradiction(msg) => {