File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,21 @@ pub(crate) struct SourceMap<'a> {
1111
1212impl < ' a >  SourceMap < ' a >  { 
1313    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+                 source, 
26+             } ; 
27+         } 
28+ 
1429        let  mut  current_index = 0 ; 
1530
1631        let  mut  mapping = vec ! [ ] ; 
Original file line number Diff line number Diff line change @@ -303,6 +303,7 @@ fn test_only_source() {
303303error:  
304304 --> file.rs 
305305  | 
306+ 1 | 
306307"# ] ] ; 
307308    let  renderer = Renderer :: plain ( ) ; 
308309    assert_data_eq ! ( renderer. render( input) ,  expected) ; 
Original file line number Diff line number Diff line change @@ -2682,7 +2682,6 @@ LL | | */
26822682} 
26832683
26842684#[ test]  
2685- #[ should_panic( expected = "called `Option::unwrap()` on a `None` value" ) ]  
26862685fn  mismatched_types1 ( )  { 
26872686    // tests/ui/include-macros/mismatched-types.rs 
26882687
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments