@@ -193,6 +193,14 @@ impl EmitterWriter {
193
193
Self { ui_testing, ..self }
194
194
}
195
195
196
+ fn maybe_anonymized ( & self , line_num : usize ) -> String {
197
+ if self . ui_testing {
198
+ ANONYMIZED_LINE_NUM . to_string ( )
199
+ } else {
200
+ line_num. to_string ( )
201
+ }
202
+ }
203
+
196
204
fn preprocess_annotations ( & mut self , msp : & MultiSpan ) -> Vec < FileWithAnnotatedLines > {
197
205
fn add_annotation_to_file ( file_vec : & mut Vec < FileWithAnnotatedLines > ,
198
206
file : Rc < FileMap > ,
@@ -344,14 +352,9 @@ impl EmitterWriter {
344
352
345
353
// First create the source line we will highlight.
346
354
buffer. puts ( line_offset, code_offset, & source_string, Style :: Quotation ) ;
347
- let line_index = if self . ui_testing {
348
- ANONYMIZED_LINE_NUM . to_string ( )
349
- } else {
350
- line. line_index . to_string ( )
351
- } ;
352
355
buffer. puts ( line_offset,
353
356
0 ,
354
- & line_index,
357
+ & self . maybe_anonymized ( line . line_index ) ,
355
358
Style :: LineNumber ) ;
356
359
357
360
draw_col_separator ( buffer, line_offset, width_offset - 2 ) ;
@@ -1174,8 +1177,8 @@ impl EmitterWriter {
1174
1177
1175
1178
buffer. puts ( last_buffer_line_num,
1176
1179
0 ,
1177
- & ( annotated_file. lines [ line_idx + 1 ] . line_index - 1 )
1178
- . to_string ( ) ,
1180
+ & self . maybe_anonymized ( annotated_file. lines [ line_idx + 1 ]
1181
+ . line_index - 1 ) ,
1179
1182
Style :: LineNumber ) ;
1180
1183
draw_col_separator ( & mut buffer,
1181
1184
last_buffer_line_num,
@@ -1250,7 +1253,7 @@ impl EmitterWriter {
1250
1253
// Print the span column to avoid confusion
1251
1254
buffer. puts ( row_num,
1252
1255
0 ,
1253
- & ( ( line_start + line_pos) . to_string ( ) ) ,
1256
+ & self . maybe_anonymized ( line_start + line_pos) ,
1254
1257
Style :: LineNumber ) ;
1255
1258
// print the suggestion
1256
1259
draw_col_separator ( & mut buffer, row_num, max_line_num_len + 1 ) ;
0 commit comments