File tree 2 files changed +12
-4
lines changed
compiler/rustc_errors/src
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -1513,7 +1513,9 @@ impl HumanEmitter {
1513
1513
for line_idx in 0 ..annotated_file. lines . len ( ) {
1514
1514
let file = annotated_file. file . clone ( ) ;
1515
1515
let line = & annotated_file. lines [ line_idx] ;
1516
- if let Some ( source_string) = file. get_line ( line. line_index - 1 ) {
1516
+ if let Some ( source_string) =
1517
+ line. line_index . checked_sub ( 1 ) . and_then ( |l| file. get_line ( l) )
1518
+ {
1517
1519
let leading_whitespace = source_string
1518
1520
. chars ( )
1519
1521
. take_while ( |c| c. is_whitespace ( ) )
@@ -1553,7 +1555,10 @@ impl HumanEmitter {
1553
1555
for line in & annotated_file. lines {
1554
1556
max_line_len = max (
1555
1557
max_line_len,
1556
- annotated_file. file . get_line ( line. line_index - 1 ) . map_or ( 0 , |s| s. len ( ) ) ,
1558
+ line. line_index
1559
+ . checked_sub ( 1 )
1560
+ . and_then ( |l| annotated_file. file . get_line ( l) )
1561
+ . map_or ( 0 , |s| s. len ( ) ) ,
1557
1562
) ;
1558
1563
for ann in & line. annotations {
1559
1564
span_right_margin = max ( span_right_margin, ann. start_col . display ) ;
Original file line number Diff line number Diff line change 1
1
error[E0308]: mismatched types
2
- --> $DIR/mismatched-types.rs:2:20
2
+ --> $DIR/file.txt:0:1
3
+ |
4
+ |
5
+ ::: $DIR/mismatched-types.rs:2:12
3
6
|
4
7
LL | let b: &[u8] = include_str!("file.txt");
5
- | ----- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[u8]`, found `&str`
8
+ | ----- ------------------------ in this macro invocation
6
9
| |
7
10
| expected due to this
8
11
|
You can’t perform that action at this time.
0 commit comments