File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +1
8000
6
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,21 @@ pub(crate) struct SourceMap<'a> {
11
11
12
12
impl < ' a > SourceMap < ' a > {
13
13
pub ( crate ) fn new ( source : & ' a str , line_start : usize ) -> Self {
14
+ // Empty sources do have a "line", but it is empty, so we need to add
15
+ // a line with an empty string to the source map.
16
+ if source. is_empty ( ) {
17
+ return Self {
18
+ lines : vec ! [ LineInfo {
19
+ line: "" ,
20
+ line_index: line_start,
21
+ start_byte: 0 ,
22
+ end_byte: 0 ,
23
+ end_line_size: 0 ,
24
+ } ] ,
25
+
8000
span> source,
26
+ } ;
27
+ }
28
+
14
29
let mut current_index = 0 ;
15
30
16
31
let mut mapping = vec ! [ ] ;
Original file line number Diff line number Diff line change @@ -303,6 +303,7 @@ fn test_only_source() {
303
303
error:
304
304
--> file.rs
305
305
|
306
+ 1 |
306
307
"# ] ] ;
307
308
let renderer = Renderer :: plain ( ) ;
308
309
assert_data_eq ! ( renderer. render( input) , expected) ;
Original file line number Diff line number Diff line change @@ -2682,7 +2682,6 @@ LL | | */
2682
2682
}
2683
2683
2684
2684
#[ test]
2685
- #[ should_panic( expected = "called `Option::unwrap()` on a `None` value" ) ]
2686
2685
fn mismatched_types1 ( ) {
2687
2686
// tests/ui/include-macros/mismatched-types.rs
2688
2687
You can’t perform that action at this time.
0 commit comments