10
10
use Destination :: * ;
11
11
12
12
use rustc_span:: source_map:: SourceMap ;
13
- use rustc_span:: { FileLines , SourceFile , Span } ;
13
+ use rustc_span:: { FileLines , Pos , SourceFile , Span } ;
14
14
15
15
use crate :: snippet:: { Annotation , AnnotationType , Line , MultilineAnnotation , Style , StyledString } ;
16
16
use crate :: styled_buffer:: StyledBuffer ;
@@ -1293,14 +1293,14 @@ impl EmitterWriter {
1293
1293
for primary_span in msp. primary_spans ( ) {
1294
1294
if will_be_emitted ( * primary_span) {
1295
1295
let hi = sm. lookup_char_pos ( primary_span. hi ( ) ) ;
1296
- max = ( hi. line ) . max ( max) ;
1296
+ max = ( hi. line . to_usize ( ) ) . max ( max) ;
1297
1297
}
1298
1298
}
1299
1299
if !self . short_message {
1300
1300
for span_label in msp. span_labels ( ) {
1301
1301
if will_be_emitted ( span_label. span ) {
1302
1302
let hi = sm. lookup_char_pos ( span_label. span . hi ( ) ) ;
1303
- max = ( hi. line ) . max ( max) ;
1303
+ max = ( hi. line . to_usize ( ) ) . max ( max) ;
1304
1304
}
1305
1305
}
1306
1306
}
@@ -1498,7 +1498,7 @@ impl EmitterWriter {
1498
1498
& format ! (
1499
1499
"{}:{}:{}" ,
1500
1500
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 ( ) ) ,
1502
1502
loc. col. 0 + 1 ,
1503
1503
) ,
1504
1504
Style :: LineAndColumn ,
@@ -1512,7 +1512,7 @@ impl EmitterWriter {
1512
1512
& format ! (
1513
1513
"{}:{}:{}: " ,
1514
1514
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 ( ) ) ,
1516
1516
loc. col. 0 + 1 ,
1517
1517
) ,
1518
1518
Style :: LineAndColumn ,
@@ -1795,7 +1795,7 @@ impl EmitterWriter {
1795
1795
& format ! (
1796
1796
"{}:{}:{}" ,
1797
1797
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 ( ) ) ,
1799
1799
loc. col. 0 + 1 ,
1800
1800
) ,
1801
1801
Style :: LineAndColumn ,
@@ -1832,27 +1832,27 @@ impl EmitterWriter {
1832
1832
if lines. clone ( ) . next ( ) . is_none ( ) {
1833
1833
// Account for a suggestion to completely remove a line(s) with whitespace (#94192).
1834
1834
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 ( ) {
1836
1836
buffer. puts (
1837
- row_num - 1 + line - line_start,
1837
+ row_num - 1 + line - line_start. to_usize ( ) ,
1838
1838
0 ,
1839
1839
& self . maybe_anonymized ( line) ,
1840
1840
Style :: LineNumber ,
1841
1841
) ;
1842
1842
buffer. puts (
1843
- row_num - 1 + line - line_start,
1843
+ row_num - 1 + line - line_start. to_usize ( ) ,
1844
1844
max_line_num_len + 1 ,
1845
1845
"- " ,
1846
1846
Style :: Removal ,
1847
1847
) ;
1848
1848
buffer. puts (
1849
- row_num - 1 + line - line_start,
1849
+ row_num - 1 + line - line_start. to_usize ( ) ,
1850
1850
max_line_num_len + 3 ,
1851
1851
& normalize_whitespace ( & * file_lines. file . get_line ( line - 1 ) . unwrap ( ) ) ,
1852
1852
Style :: Removal ,
1853
1853
) ;
1854
1854
}
1855
- row_num += line_end - line_start;
1855
+ row_num += line_end. to_usize ( ) - line_start. to_usize ( ) ;
1856
1856
}
1857
1857
let mut unhighlighted_lines = Vec :: new ( ) ;
1858
1858
for ( line_pos, ( line, highlight_parts) ) in lines. by_ref ( ) . zip ( highlights) . enumerate ( ) {
@@ -1877,7 +1877,7 @@ impl EmitterWriter {
1877
1877
& Vec :: new ( ) ,
1878
1878
p,
1879
1879
l,
1880
- line_start,
1880
+ line_start. to_usize ( ) ,
1881
1881
show_code_change,
1882
1882
max_line_num_len,
1883
1883
& file_lines,
@@ -1902,7 +1902,7 @@ impl EmitterWriter {
1902
1902
& Vec :: new ( ) ,
1903
1903
p,
1904
1904
l,
1905
- line_start,
1905
+ line_start. to_usize ( ) ,
1906
1906
show_code_change,
1907
1907
max_line_num_len,
1908
1908
& file_lines,
@@ -1920,7 +1920,7 @@ impl EmitterWriter {
1920
1920
& Vec :: new ( ) ,
1921
1921
p,
1922
1922
l,
1923
- line_start,
1923
+ line_start. to_usize ( ) ,
1924
1924
show_code_change,
1925
1925
max_line_num_len,
1926
1926
& file_lines,
@@ -1936,7 +1936,7 @@ impl EmitterWriter {
1936
1936
highlight_parts,
1937
1937
line_pos,
1938
1938
line,
1939
- line_start,
1939
+ line_start. to_usize ( ) ,
1940
1940
show_code_change,
1941
1941
max_line_num_len,
1942
1942
& file_lines,
@@ -2275,8 +2275,8 @@ impl FileWithAnnotatedLines {
2275
2275
if lo. line != hi. line {
2276
2276
let ml = MultilineAnnotation {
2277
2277
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 ( ) ,
2280
2280
start_col : lo. col_display ,
2281
2281
end_col : hi. col_display ,
2282
2282
is_primary : span_label. is_primary ,
@@ -2298,7 +2298,7 @@ impl FileWithAnnotatedLines {
2298
2298
. map ( |m| emitter. translate_message ( m, args) . to_string ( ) ) ,
2299
2299
annotation_type : AnnotationType :: Singleline ,
2300
2300
} ;
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) ;
2302
2302
} ;
2303
2303
}
2304
2304
}
0 commit comments