1010use Destination :: * ;
1111
1212use rustc_span:: source_map:: SourceMap ;
13- use rustc_span:: { FileLines , SourceFile , Span } ;
13+ use rustc_span:: { FileLines , Pos , SourceFile , Span } ;
1414
1515use crate :: snippet:: { Annotation , AnnotationType , Line , MultilineAnnotation , Style , StyledString } ;
1616use crate :: styled_buffer:: StyledBuffer ;
@@ -1293,14 +1293,14 @@ impl EmitterWriter {
12931293 for primary_span in msp. primary_spans ( ) {
12941294 if will_be_emitted ( * primary_span) {
12951295 let hi = sm. lookup_char_pos ( primary_span. hi ( ) ) ;
1296- max = ( hi. line ) . max ( max) ;
1296+ max = ( hi. line . to_usize ( ) ) . max ( max) ;
12971297 }
12981298 }
12991299 if !self . short_message {
13001300 for span_label in msp. span_labels ( ) {
13011301 if will_be_emitted ( span_label. span ) {
13021302 let hi = sm. lookup_char_pos ( span_label. span . hi ( ) ) ;
1303- max = ( hi. line ) . max ( max) ;
1303+ max = ( hi. line . to_usize ( ) ) . max ( max) ;
13041304 }
13051305 }
13061306 }
@@ -1498,7 +1498,7 @@ impl EmitterWriter {
14981498 & format ! (
14991499 "{}:{}:{}" ,
15001500 sm. filename_for_diagnostics( & loc. file. name) ,
1501- sm. doctest_offset_line( & loc. file. name, loc. line) ,
1501+ sm. doctest_offset_line( & loc. file. name, loc. line. to_usize ( ) ) ,
15021502 loc. col. 0 + 1 ,
15031503 ) ,
15041504 Style :: LineAndColumn ,
@@ -1512,7 +1512,7 @@ impl EmitterWriter {
15121512 & format ! (
15131513 "{}:{}:{}: " ,
15141514 sm. filename_for_diagnostics( & loc. file. name) ,
1515- sm. doctest_offset_line( & loc. file. name, loc. line) ,
1515+ sm. doctest_offset_line( & loc. file. name, loc. line. to_usize ( ) ) ,
15161516 loc. col. 0 + 1 ,
15171517 ) ,
15181518 Style :: LineAndColumn ,
@@ -1795,7 +1795,7 @@ impl EmitterWriter {
17951795 & format ! (
17961796 "{}:{}:{}" ,
17971797 sm. filename_for_diagnostics( & loc. file. name) ,
1798- sm. doctest_offset_line( & loc. file. name, loc. line) ,
1798+ sm. doctest_offset_line( & loc. file. name, loc. line. to_usize ( ) ) ,
17991799 loc. col. 0 + 1 ,
18001800 ) ,
18011801 Style :: LineAndColumn ,
@@ -1832,27 +1832,27 @@ impl EmitterWriter {
18321832 if lines. clone ( ) . next ( ) . is_none ( ) {
18331833 // Account for a suggestion to completely remove a line(s) with whitespace (#94192).
18341834 let line_end = sm. lookup_char_pos ( parts[ 0 ] . span . hi ( ) ) . line ;
1835- for line in line_start.. =line_end {
1835+ for line in line_start. to_usize ( ) .. =line_end. to_usize ( ) {
18361836 buffer. puts (
1837- row_num - 1 + line - line_start,
1837+ row_num - 1 + line - line_start. to_usize ( ) ,
18381838 0 ,
18391839 & self . maybe_anonymized ( line) ,
18401840 Style :: LineNumber ,
18411841 ) ;
18421842 buffer. puts (
1843- row_num - 1 + line - line_start,
1843+ row_num - 1 + line - line_start. to_usize ( ) ,
18441844 max_line_num_len + 1 ,
18451845 "- " ,
18461846 Style :: Removal ,
18471847 ) ;
18481848 buffer. puts (
1849- row_num - 1 + line - line_start,
1849+ row_num - 1 + line - line_start. to_usize ( ) ,
18501850 max_line_num_len + 3 ,
18511851 & normalize_whitespace ( & * file_lines. file . get_line ( line - 1 ) . unwrap ( ) ) ,
18521852 Style :: Removal ,
18531853 ) ;
18541854 }
1855- row_num += line_end - line_start;
1855+ row_num += line_end. to_usize ( ) - line_start. to_usize ( ) ;
18561856 }
18571857 let mut unhighlighted_lines = Vec :: new ( ) ;
18581858 for ( line_pos, ( line, highlight_parts) ) in lines. by_ref ( ) . zip ( highlights) . enumerate ( ) {
@@ -1877,7 +1877,7 @@ impl EmitterWriter {
18771877 & Vec :: new ( ) ,
18781878 p,
18791879 l,
1880- line_start,
1880+ line_start. to_usize ( ) ,
18811881 show_code_change,
18821882 max_line_num_len,
18831883 & file_lines,
@@ -1902,7 +1902,7 @@ impl EmitterWriter {
19021902 & Vec :: new ( ) ,
19031903 p,
19041904 l,
1905- line_start,
1905+ line_start. to_usize ( ) ,
19061906 show_code_change,
19071907 max_line_num_len,
19081908 & file_lines,
@@ -1920,7 +1920,7 @@ impl EmitterWriter {
19201920 & Vec :: new ( ) ,
19211921 p,
19221922 l,
1923- line_start,
1923+ line_start. to_usize ( ) ,
19241924 show_code_change,
19251925 max_line_num_len,
19261926 & file_lines,
@@ -1936,7 +1936,7 @@ impl EmitterWriter {
19361936 highlight_parts,
19371937 line_pos,
19381938 line,
1939- line_start,
1939+ line_start. to_usize ( ) ,
19401940 show_code_change,
19411941 max_line_num_len,
19421942 & file_lines,
@@ -2275,8 +2275,8 @@ impl FileWithAnnotatedLines {
22752275 if lo. line != hi. line {
22762276 let ml = MultilineAnnotation {
22772277 depth : 1 ,
2278- line_start : lo. line ,
2279- line_end : hi. line ,
2278+ line_start : lo. line . to_usize ( ) ,
2279+ line_end : hi. line . to_usize ( ) ,
22802280 start_col : lo. col_display ,
22812281 end_col : hi. col_display ,
22822282 is_primary : span_label. is_primary ,
@@ -2298,7 +2298,7 @@ impl FileWithAnnotatedLines {
22982298 . map ( |m| emitter. translate_message ( m, args) . to_string ( ) ) ,
22992299 annotation_type : AnnotationType :: Singleline ,
23002300 } ;
2301- add_annotation_to_file ( & mut output, lo. file , lo. line , ann) ;
2301+ add_annotation_to_file ( & mut output, lo. file , lo. line . to_usize ( ) , ann) ;
23022302 } ;
23032303 }
23042304 }
0 commit comments