Skip to content

Commit

Permalink
these errors can happen after all
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-i-m committed May 22, 2019
1 parent 50a0def commit 3f2dd24
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/libsyntax/ext/tt/transcribe.rs
Expand Up @@ -170,9 +170,11 @@ pub fn transcribe(
}

LockstepIterSize::Contradiction(ref msg) => {
// This should never happen because the macro parser should generate
// properly-sized matches for all meta-vars.
cx.span_bug(seq.span(), &msg[..]);
// FIXME: this really ought to be caught at macro definition time... It
// happens when two meta-variables are used in the same repetition in a
// sequence, but they come from different sequence matchers and repeat
// different amounts.
cx.span_fatal(seq.span(), &msg[..]);
}

LockstepIterSize::Constraint(len, _) => {
Expand All @@ -187,9 +189,10 @@ pub fn transcribe(
// Is the repetition empty?
if len == 0 {
if seq.op == quoted::KleeneOp::OneOrMore {
// This should be impossible because the macro parser would not
// match the given macro arm.
cx.span_bug(sp.entire(), "this must repeat at least once");
// FIXME: this really ought to be caught at macro definition
// time... It happens when the Kleene operator in the matcher and
// the body for the same meta-variable do not match.
cx.span_fatal(sp.entire(), "this must repeat at least once");
}
} else {
// 0 is the initial counter (we have done 0 repretitions so far). `len`
Expand Down Expand Up @@ -327,8 +330,7 @@ impl LockstepIterSize {
LockstepIterSize::Constraint(r_len, _) if l_len == r_len => self,
LockstepIterSize::Constraint(r_len, r_id) => {
let msg = format!(
"inconsistent lockstep iteration: \
'{}' has {} items, but '{}' has {}",
"meta-variable `{}` repeats {} times, but `{}` repeats {} times",
l_id, l_len, r_id, r_len
);
LockstepIterSize::Contradiction(msg)
Expand Down

0 comments on commit 3f2dd24

Please sign in to comment.