Skip to content

Commit 4ae50db

Browse files
committed
Distinguish which direction the mismatch occurs
1 parent cb94081 commit 4ae50db

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/wrapper.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,15 +427,17 @@ impl Span {
427427
match (self, other) {
428428
(Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.resolved_at(b)),
429429
(Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.resolved_at(b)),
430-
_ => mismatch(line!()),
430+
(Span::Compiler(_), Span::Fallback(_)) => mismatch(line!()),
431+
(Span::Fallback(_), Span::Compiler(_)) => mismatch(line!()),
431432
}
432433
}
433434

434435
pub fn located_at(&self, other: Span) -> Span {
435436
match (self, other) {
436437
(Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.located_at(b)),
437438
(Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.located_at(b)),
438-
_ => mismatch(line!()),
439+
(Span::Compiler(_), Span::Fallback(_)) => mismatch(line!()),
440+
(Span::Fallback(_), Span::Compiler(_)) => mismatch(line!()),
439441
}
440442
}
441443

@@ -605,7 +607,8 @@ impl Group {
605607
match (self, span) {
606608
(Group::Compiler(g), Span::Compiler(s)) => g.set_span(s),
607609
(Group::Fallback(g), Span::Fallback(s)) => g.set_span(s),
608-
_ => mismatch(line!()),
610+
(Group::Compiler(_), Span::Fallback(_)) => mismatch(line!()),
611+
(Group::Fallback(_), Span::Compiler(_)) => mismatch(line!()),
609612
}
610613
}
611614

@@ -683,7 +686,8 @@ impl Ident {
683686
match (self, span) {
684687
(Ident::Compiler(t), Span::Compiler(s)) => t.set_span(s),
685688
(Ident::Fallback(t), Span::Fallback(s)) => t.set_span(s),
686-
_ => mismatch(line!()),
689+
(Ident::Compiler(_), Span::Fallback(_)) => mismatch(line!()),
690+
(Ident::Fallback(_), Span::Compiler(_)) => mismatch(line!()),
687691
}
688692
}
689693

@@ -700,7 +704,8 @@ impl PartialEq for Ident {
700704
match (self, other) {
701705
(Ident::Compiler(t), Ident::Compiler(o)) => t.to_string() == o.to_string(),
702706
(Ident::Fallback(t), Ident::Fallback(o)) => t == o,
703-
_ => mismatch(line!()),
707+
(Ident::Compiler(_), Ident::Fallback(_)) => mismatch(line!()),
708+
(Ident::Fallback(_), Ident::Compiler(_)) => mismatch(line!()),
704709
}
705710
}
706711
}
@@ -859,7 +864,8 @@ impl Literal {
859864
match (self, span) {
860865
(Literal::Compiler(lit), Span::Compiler(s)) => lit.set_span(s),
861866
(Literal::Fallback(lit), Span::Fallback(s)) => lit.set_span(s),
862-
_ => mismatch(line!()),
867+
(Literal::Compiler(_), Span::Fallback(_)) => mismatch(line!()),
868+
(Literal::Fallback(_), Span::Compiler(_)) => mismatch(line!()),
863869
}
864870
}
865871

0 commit comments

Comments
 (0)