File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -104,14 +104,25 @@ impl AnnotateSnippetEmitterWriter {
104104 if let Some ( source_map) = & self . source_map {
105105 // Make sure our primary file comes first
106106 let primary_lo = if let Some ( ref primary_span) = msp. primary_span ( ) . as_ref ( ) {
107- source_map. lookup_char_pos ( primary_span. lo ( ) )
107+ if primary_span. is_dummy ( ) {
108+ // FIXME(#59346): Not sure when this is the case and what
109+ // should be done if it happens
110+ return ;
111+ } else {
112+ source_map. lookup_char_pos ( primary_span. lo ( ) )
113+ }
108114 } else {
109115 // FIXME(#59346): Not sure when this is the case and what
110116 // should be done if it happens
111117 return ;
112118 } ;
113- let annotated_files =
119+ let mut annotated_files =
114120 FileWithAnnotatedLines :: collect_annotations ( msp, & self . source_map ) ;
121+ if let Ok ( pos) =
122+ annotated_files. binary_search_by ( |x| x. file . name . cmp ( & primary_lo. file . name ) )
123+ {
124+ annotated_files. swap ( 0 , pos) ;
125+ }
115126 // owned: line source, line index, annotations
116127 type Owned = ( String , usize , Vec < crate :: snippet:: Annotation > ) ;
117128 let origin = primary_lo. file . name . to_string ( ) ;
You can’t perform that action at this time.
0 commit comments