From 1c2460bf6ba944d970c6bb6d47863d0244621887 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 11 Nov 2019 13:55:51 +0000 Subject: Ensure spans are compatible in Span::union --- dhall_syntax/src/core/span.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'dhall_syntax') diff --git a/dhall_syntax/src/core/span.rs b/dhall_syntax/src/core/span.rs index d63a619..f9c7008 100644 --- a/dhall_syntax/src/core/span.rs +++ b/dhall_syntax/src/core/span.rs @@ -40,11 +40,13 @@ impl Span { use std::cmp::{max, min}; use Span::*; match (self, other) { - (Parsed(x), Parsed(y)) => Parsed(ParsedSpan { - input: x.input.clone(), - start: min(x.start, y.start), - end: max(x.end, y.end), - }), + (Parsed(x), Parsed(y)) if Rc::ptr_eq(&x.input, &y.input) => { + Parsed(ParsedSpan { + input: x.input.clone(), + start: min(x.start, y.start), + end: max(x.end, y.end), + }) + } _ => panic!( "Tried to union incompatible spans: {:?} and {:?}", self, other -- cgit v1.2.3