mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-10 14:57:14 +00:00
Moved overflow check into end_point function.
This commit is contained in:
parent
f6fee2a479
commit
c6e6428d1a
@ -699,12 +699,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
let region_scope_span = region_scope.span(self.hir.tcx(),
|
let region_scope_span = region_scope.span(self.hir.tcx(),
|
||||||
&self.hir.region_scope_tree);
|
&self.hir.region_scope_tree);
|
||||||
// Attribute scope exit drops to scope's closing brace.
|
// Attribute scope exit drops to scope's closing brace.
|
||||||
// Without this check when finding the endpoint, we'll run into an ICE.
|
let scope_end = region_scope_span.end_point();
|
||||||
let scope_end = if region_scope_span.hi().0 == 0 {
|
|
||||||
region_scope_span
|
|
||||||
} else {
|
|
||||||
region_scope_span.end_point()
|
|
||||||
};
|
|
||||||
|
|
||||||
scope.drops.push(DropData {
|
scope.drops.push(DropData {
|
||||||
span: scope_end,
|
span: scope_end,
|
||||||
|
@ -219,7 +219,9 @@ impl Span {
|
|||||||
/// Returns a new span representing just the end-point of this span
|
/// Returns a new span representing just the end-point of this span
|
||||||
pub fn end_point(self) -> Span {
|
pub fn end_point(self) -> Span {
|
||||||
let span = self.data();
|
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))
|
span.with_lo(BytePos(lo))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user