File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed
compiler/rustc_errors/src Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -763,13 +763,7 @@ impl HumanEmitter {
763
763
// | vertical divider between the column number and the code
764
764
// column number
765
765
766
- if line. line_index == 0 {
767
- return Vec :: new ( ) ;
768
- }
769
-
770
- let Some ( source_string) = file. get_line ( line. line_index - 1 ) else {
771
- return Vec :: new ( ) ;
772
- } ;
766
+ let source_string = file. get_line ( line. line_index - 1 ) . unwrap_or_default ( ) ;
773
767
trace ! ( ?source_string) ;
774
768
775
769
let line_offset = buffer. num_lines ( ) ;
@@ -1687,7 +1681,6 @@ impl HumanEmitter {
1687
1681
}
1688
1682
continue ;
1689
1683
}
1690
-
1691
1684
// print out the span location and spacer before we print the annotated source
1692
1685
// to do this, we need to know if this span will be primary
1693
1686
let is_primary = primary_lo. file . name == annotated_file. file . name ;
@@ -1697,13 +1690,17 @@ impl HumanEmitter {
1697
1690
// remember where we are in the output buffer for easy reference
1698
1691
let buffer_msg_line_offset = buffer. num_lines ( ) ;
1699
1692
1693
+ let mut line = sm. doctest_offset_line ( & loc. file . name , loc. line ) ;
1694
+ if line == 0 {
1695
+ line += 1 ;
1696
+ }
1700
1697
buffer. prepend ( buffer_msg_line_offset, self . file_start ( ) , Style :: LineNumber ) ;
1701
1698
buffer. append (
1702
1699
buffer_msg_line_offset,
1703
1700
& format ! (
1704
1701
"{}:{}:{}" ,
1705
1702
sm. filename_for_diagnostics( & loc. file. name) ,
1706
- sm . doctest_offset_line ( & loc . file . name , loc . line) ,
1703
+ line,
1707
1704
loc. col. 0 + 1 ,
1708
1705
) ,
1709
1706
Style :: LineAndColumn ,
Original file line number Diff line number Diff line change 1
1
error[E0308]: mismatched types
2
- --> $DIR/file.txt:0 :1
2
+ --> $DIR/file.txt:1 :1
3
3
|
4
+ LL |
5
+ | ^ expected `&[u8]`, found `&str`
4
6
|
5
7
::: $DIR/mismatched-types.rs:2:12
6
8
|
You can’t perform that action at this time.
0 commit comments