@@ -1687,7 +1687,7 @@ impl SourceFile {
1687
1687
}
1688
1688
1689
1689
assert ! ( self . start_pos. to_u32( ) + total_extra_bytes <= bpos. to_u32( ) ) ;
1690
- CharPos ( bpos. to_usize ( ) - self . start_pos . to_usize ( ) - total_extra_bytes as usize )
1690
+ CharPos ( bpos. to_u32 ( ) - self . start_pos . to_u32 ( ) - total_extra_bytes)
1691
1691
}
1692
1692
1693
1693
/// Looks up the file's (1-based) line number and (0-based `CharPos`) column offset, for a
@@ -1712,7 +1712,7 @@ impl SourceFile {
1712
1712
1713
1713
/// Looks up the file's (1-based) line number, (0-based `CharPos`) column offset, and (0-based)
1714
1714
/// column offset when displayed, for a given `BytePos`.
1715
- pub fn lookup_file_pos_with_col_display ( & self , pos : BytePos ) -> ( LineNum , CharPos , usize ) {
1715
+ pub fn lookup_file_pos_with_col_display ( & self , pos : BytePos ) -> ( LineNum , CharPos , u32 ) {
1716
1716
let ( line, col_or_chpos) = self . lookup_file_pos ( pos) ;
1717
1717
if line. to_usize ( ) > 0 {
1718
1718
let col = col_or_chpos;
@@ -1731,7 +1731,8 @@ impl SourceFile {
1731
1731
. iter ( )
1732
1732
. map ( |x| x. width ( ) )
1733
1733
. sum ( ) ;
1734
- col. 0 - special_chars + non_narrow
1734
+ col. to_u32 ( ) - u32:: try_from ( special_chars) . unwrap ( )
1735
+ + u32:: try_from ( non_narrow) . unwrap ( )
1735
1736
} ;
1736
1737
( line, col, col_display)
1737
1738
} else {
@@ -1743,7 +1744,8 @@ impl SourceFile {
1743
1744
. unwrap_or_else ( |x| x) ;
1744
1745
let non_narrow: usize =
1745
1746
self . non_narrow_chars [ 0 ..end_width_idx] . iter ( ) . map ( |x| x. width ( ) ) . sum ( ) ;
1746
- chpos. 0 - end_width_idx + non_narrow
1747
+ chpos. to_u32 ( ) - u32:: try_from ( end_width_idx) . unwrap ( )
1748
+ + u32:: try_from ( non_narrow) . unwrap ( )
1747
1749
} ;
1748
1750
( LineNum ( 0 ) , chpos, col_display)
1749
1751
}
@@ -1911,7 +1913,7 @@ impl_pos! {
1911
1913
/// is not equivalent to a character offset. The [`SourceMap`] will convert [`BytePos`]
1912
1914
/// values to `CharPos` values as necessary.
1913
1915
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Debug ) ]
1914
- pub struct CharPos ( pub usize ) ;
1916
+ pub struct CharPos ( u32 ) ;
1915
1917
1916
1918
/// A Line number
1917
1919
///
0 commit comments