@@ -1687,7 +1687,7 @@ impl SourceFile {
16871687 }
16881688
16891689 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)
16911691 }
16921692
16931693 /// Looks up the file's (1-based) line number and (0-based `CharPos`) column offset, for a
@@ -1712,7 +1712,7 @@ impl SourceFile {
17121712
17131713 /// Looks up the file's (1-based) line number, (0-based `CharPos`) column offset, and (0-based)
17141714 /// 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 ) {
17161716 let ( line, col_or_chpos) = self . lookup_file_pos ( pos) ;
17171717 if line. to_usize ( ) > 0 {
17181718 let col = col_or_chpos;
@@ -1731,7 +1731,8 @@ impl SourceFile {
17311731 . iter ( )
17321732 . map ( |x| x. width ( ) )
17331733 . 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 ( )
17351736 } ;
17361737 ( line, col, col_display)
17371738 } else {
@@ -1743,7 +1744,8 @@ impl SourceFile {
17431744 . unwrap_or_else ( |x| x) ;
17441745 let non_narrow: usize =
17451746 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 ( )
17471749 } ;
17481750 ( LineNum ( 0 ) , chpos, col_display)
17491751 }
@@ -1911,7 +1913,7 @@ impl_pos! {
19111913 /// is not equivalent to a character offset. The [`SourceMap`] will convert [`BytePos`]
19121914 /// values to `CharPos` values as necessary.
19131915 #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Debug ) ]
1914- pub struct CharPos ( pub usize ) ;
1916+ pub struct CharPos ( u32 ) ;
19151917
19161918 /// A Line number
19171919 ///
0 commit comments