Skip to content

Commit 1148346

Browse files
committed
Inline simple conversion from usize to u32
1 parent 5b5ec10 commit 1148346

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

src/convert.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/fallback.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,27 +1019,26 @@ impl Literal {
10191019

10201020
#[cfg(span_locations)]
10211021
{
1022-
use crate::convert::usize_to_u32;
10231022
use core::ops::Bound;
10241023

10251024
let lo = match range.start_bound() {
10261025
Bound::Included(start) => {
1027-
let start = usize_to_u32(*start)?;
1026+
let start = u32::try_from(*start).ok()?;
10281027
self.span.lo.checked_add(start)?
10291028
}
10301029
Bound::Excluded(start) => {
1031-
let start = usize_to_u32(*start)?;
1030+
let start = u32::try_from(*start).ok()?;
10321031
self.span.lo.checked_add(start)?.checked_add(1)?
10331032
}
10341033
Bound::Unbounded => self.span.lo,
10351034
};
10361035
let hi = match range.end_bound() {
10371036
Bound::Included(end) => {
1038-
let end = usize_to_u32(*end)?;
1037+
let end = u32::try_from(*end).ok()?;
10391038
self.span.lo.checked_add(end)?.checked_add(1)?
10401039
}
10411040
Bound::Excluded(end) => {
1042-
let end = usize_to_u32(*end)?;
1041+
let end = u32::try_from(*end).ok()?;
10431042
self.span.lo.checked_add(end)?
10441043
}
10451044
Bound::Unbounded => self.span.hi,

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ use crate::fallback as imp;
141141
#[cfg(wrap_proc_macro)]
142142
mod imp;
143143

144-
#[cfg(span_locations)]
145-
mod convert;
146144
#[cfg(span_locations)]
147145
mod location;
148146

0 commit comments

Comments
 (0)