Added first migration for repeated expressions without syntax vars
This commit is contained in:
parent
a39bdb1d6b
commit
7e15fbab75
@ -3,3 +3,6 @@ expand_explain_doc_comment_outer =
|
|||||||
|
|
||||||
expand_explain_doc_comment_inner =
|
expand_explain_doc_comment_inner =
|
||||||
inner doc comments expand to `#![doc = "..."]`, which is what this macro attempted to match
|
inner doc comments expand to `#![doc = "..."]`, which is what this macro attempted to match
|
||||||
|
|
||||||
|
expand_expr_repeat_no_syntax_vars =
|
||||||
|
attempted to repeat an expression containing no syntax variables matched as repeating at this depth
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
||||||
use rustc_span::hygiene::{LocalExpnId, Transparency};
|
use rustc_span::hygiene::{LocalExpnId, Transparency};
|
||||||
use rustc_span::symbol::{sym, Ident, MacroRulesNormalizedIdent};
|
use rustc_span::symbol::{sym, Ident, MacroRulesNormalizedIdent};
|
||||||
|
use rustc_macros::SessionDiagnostic;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
@ -53,6 +54,13 @@ fn next(&mut self) -> Option<&'a mbe::TokenTree> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(SessionDiagnostic)]
|
||||||
|
#[error(expand::expr_repeat_no_syntax_vars)]
|
||||||
|
struct NoSyntaxVarsExprRepeat {
|
||||||
|
#[primary_span]
|
||||||
|
span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
/// This can do Macro-By-Example transcription.
|
/// This can do Macro-By-Example transcription.
|
||||||
/// - `interp` is a map of meta-variables to the tokens (non-terminals) they matched in the
|
/// - `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.
|
/// 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) => {
|
seq @ mbe::TokenTree::Sequence(_, delimited) => {
|
||||||
match lockstep_iter_size(&seq, interp, &repeats) {
|
match lockstep_iter_size(&seq, interp, &repeats) {
|
||||||
LockstepIterSize::Unconstrained => {
|
LockstepIterSize::Unconstrained => {
|
||||||
return Err(cx.struct_span_err(
|
return Err(cx.create_err(NoSyntaxVarsExprRepeat { span: seq.span() }));
|
||||||
seq.span(), /* blame macro writer */
|
|
||||||
"attempted to repeat an expression containing no syntax variables \
|
|
||||||
matched as repeating at this depth",
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LockstepIterSize::Contradiction(msg) => {
|
LockstepIterSize::Contradiction(msg) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user