Detect overflow in proc_macro_server subspan

This commit is contained in:
Tomasz Miąsko 2020-08-04 00:00:00 +00:00
parent d2454643e1
commit b54386ab7a

View File

@ -584,12 +584,12 @@ impl server::Literal for Rustc<'_> {
let start = match start { let start = match start {
Bound::Included(lo) => lo, Bound::Included(lo) => lo,
Bound::Excluded(lo) => lo + 1, Bound::Excluded(lo) => lo.checked_add(1)?,
Bound::Unbounded => 0, Bound::Unbounded => 0,
}; };
let end = match end { let end = match end {
Bound::Included(hi) => hi + 1, Bound::Included(hi) => hi.checked_add(1)?,
Bound::Excluded(hi) => hi, Bound::Excluded(hi) => hi,
Bound::Unbounded => length, Bound::Unbounded => length,
}; };