@@ -162,6 +162,14 @@ impl EmitterWriter {
162
162
Self { ui_testing, ..self }
163
163
}
164
164
165
+ fn maybe_anonymized ( & self , line_num : usize ) -> String {
166
+ if self . ui_testing {
167
+ ANONYMIZED_LINE_NUM . to_string ( )
168
+ } else {
169
+ line_num. to_string ( )
170
+ }
171
+ }
172
+
165
173
fn preprocess_annotations ( & mut self , msp : & MultiSpan ) -> Vec < FileWithAnnotatedLines > {
166
174
fn add_annotation_to_file ( file_vec : & mut Vec < FileWithAnnotatedLines > ,
167
175
file : Rc < FileMap > ,
@@ -313,14 +321,9 @@ impl EmitterWriter {
313
321
314
322
// First create the source line we will highlight.
315
323
buffer. puts ( line_offset, code_offset, & source_string, Style :: Quotation ) ;
316
- let line_index = if self . ui_testing {
317
- ANONYMIZED_LINE_NUM . to_string ( )
318
- } else {
319
- line. line_index . to_string ( )
320
- } ;
321
324
buffer. puts ( line_offset,
322
325
0 ,
323
- & line_index,
326
+ & self . maybe_anonymized ( line . line_index ) ,
324
327
Style :: LineNumber ) ;
325
328
326
329
draw_col_separator ( buffer, line_offset, width_offset - 2 ) ;
@@ -1141,8 +1144,8 @@ impl EmitterWriter {
1141
1144
1142
1145
buffer. puts ( last_buffer_line_num,
1143
1146
0 ,
1144
- & ( annotated_file. lines [ line_idx + 1 ] . line_index - 1 )
1145
- . to_string ( ) ,
1147
+ & self . maybe_anonymized ( annotated_file. lines [ line_idx + 1 ]
1148
+ . line_index - 1 ) ,
1146
1149
Style :: LineNumber ) ;
1147
1150
draw_col_separator ( & mut buffer,
1148
1151
last_buffer_line_num,
@@ -1216,7 +1219,7 @@ impl EmitterWriter {
1216
1219
// Print the span column to avoid confusion
1217
1220
buffer. puts ( row_num,
1218
1221
0 ,
1219
- & ( ( line_start + line_pos) . to_string ( ) ) ,
1222
+ & self . maybe_anonymized ( line_start + line_pos) ,
1220
1223
Style :: LineNumber ) ;
1221
1224
// print the suggestion
1222
1225
draw_col_separator ( & mut buffer, row_num, max_line_num_len + 1 ) ;
0 commit comments