File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -104,14 +104,25 @@ impl AnnotateSnippetEmitterWriter {
104
104
if let Some ( source_map) = & self . source_map {
105
105
// Make sure our primary file comes first
106
106
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
+ }
108
114
} else {
109
115
// FIXME(#59346): Not sure when this is the case and what
110
116
// should be done if it happens
111
117
return ;
112
118
} ;
113
- let annotated_files =
119
+ let mut annotated_files =
114
120
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
+ }
115
126
// owned: line source, line index, annotations
116
127
type Owned = ( String , usize , Vec < crate :: snippet:: Annotation > ) ;
117
128
let origin = primary_lo. file . name . to_string ( ) ;
You can’t perform that action at this time.
0 commit comments