diff options
| author | David Wood <david@davidtw.co> | 2018-01-14 00:23:35 +0000 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2018-01-27 11:46:26 +0000 |
| commit | c6e6428d1a13f61f5ffbe43697a21f3cd82cd01d (patch) | |
| tree | d5913be5df0ff9cc69b031321423035d246e80c1 /src/libsyntax_pos/lib.rs | |
| parent | f6fee2a479070526495b65b6b3e7959088a1dd62 (diff) | |
| download | rust-c6e6428d1a13f61f5ffbe43697a21f3cd82cd01d.tar.gz rust-c6e6428d1a13f61f5ffbe43697a21f3cd82cd01d.zip | |
Moved overflow check into end_point function.
Diffstat (limited to 'src/libsyntax_pos/lib.rs')
| -rw-r--r-- | src/libsyntax_pos/lib.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 85f0925b982..5866d8e4aa9 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -219,7 +219,9 @@ impl Span { /// Returns a new span representing just the end-point of this span pub fn end_point(self) -> Span { let span = self.data(); - let lo = cmp::max(span.hi.0 - 1, span.lo.0); + // We can avoid an ICE by checking if subtraction would cause an overflow. + let hi = if span.hi.0 == u32::min_value() { span.hi.0 } else { span.hi.0 - 1 }; + let lo = cmp::max(hi, span.lo.0); span.with_lo(BytePos(lo)) } |
