@@ -109,22 +109,26 @@ impl EmitterWriter {
109109        fn  add_annotation_to_file ( file_vec :  & mut  Vec < FileWithAnnotatedLines > , 
110110                                    file :  Rc < FileMap > , 
111111                                    line_index :  usize , 
112-                                     ann :   Annotation )  { 
112+                                     annotation :   Option < Annotation > )  { 
113113
114+             let  ann = match  annotation { 
115+                 Some ( ref  ann)  => vec ! [ ann. clone( ) ] , 
116+                 None  => vec ! [ ] 
117+             } ; 
114118            for  slot in  file_vec. iter_mut ( )  { 
115119                // Look through each of our files for the one we're adding to 
116120                if  slot. file . name  == file. name  { 
117121                    // See if we already have a line for it 
118122                    for  line_slot in  & mut  slot. lines  { 
119-                         if  line_slot. line_index  == line_index { 
120-                             line_slot. annotations . push ( ann ) ; 
123+                         if  line_slot. line_index  == line_index && annotation . is_some ( )   { 
124+                             line_slot. annotations . push ( annotation . unwrap ( ) ) ; 
121125                            return ; 
122126                        } 
123127                    } 
124128                    // We don't have a line yet, create one 
125129                    slot. lines . push ( Line  { 
126130                        line_index :  line_index, 
127-                         annotations :  vec ! [ ann] , 
131+                         annotations :  ann, 
128132                    } ) ; 
129133                    slot. lines . sort ( ) ; 
130134                    return ; 
@@ -135,7 +139,7 @@ impl EmitterWriter {
135139                file :  file, 
136140                lines :  vec ! [ Line  { 
137141                                line_index:  line_index, 
138-                                 annotations:  vec! [ ann] , 
142+                                 annotations:  ann, 
139143                            } ] , 
140144            } ) ; 
141145        } 
@@ -169,17 +173,24 @@ impl EmitterWriter {
169173                    hi. col  = CharPos ( lo. col . 0  + 1 ) ; 
170174                } 
171175
172-                 for  line in  start..end { 
173-                     add_annotation_to_file ( & mut  output, 
174-                                             lo. file . clone ( ) , 
175-                                             line, 
176-                                             Annotation  { 
177-                                                 start_col :  lo. col . 0 , 
178-                                                 end_col :  hi. col . 0 , 
179-                                                 is_primary :  span_label. is_primary , 
180-                                                 is_minimized :  is_minimized, 
181-                                                 label :  span_label. label . clone ( ) , 
182-                                             } ) ; 
176+                 add_annotation_to_file ( & mut  output, 
177+                                         lo. file . clone ( ) , 
178+                                         lo. line , 
179+                                         Some ( Annotation  { 
180+                                             start_col :  lo. col . 0 , 
181+                                             end_col :  hi. col . 0 , 
182+                                             is_primary :  span_label. is_primary , 
183+                                             is_minimized :  is_minimized, 
184+                                             label :  span_label. label . clone ( ) , 
185+                                         } ) ) ; 
186+                 if  start != end { 
187+                     // Add the rest of the lines, without any annotation 
188+                     for  line in  start+1 ..end { 
189+                         add_annotation_to_file ( & mut  output, 
190+                                                 lo. file . clone ( ) , 
191+                                                 line, 
192+                                                 None ) ; 
193+                     } 
183194                } 
184195            } 
185196        } 
0 commit comments