@@ -36,9 +36,7 @@ struct UnusedExternNotification {
36
36
struct DiagnosticSpan {
37
37
file_name : String ,
38
38
line_start : usize ,
39
- line_end : usize ,
40
39
column_start : usize ,
41
- column_end : usize ,
42
40
is_primary : bool ,
43
41
label : Option < String > ,
44
42
suggested_replacement : Option < String > ,
@@ -148,6 +146,7 @@ pub fn parse_output(file_name: &str, output: &str) -> Vec<Error> {
148
146
Ok ( diagnostic) => push_actual_errors ( & mut errors, & diagnostic, & [ ] , file_name) ,
149
147
Err ( _) => errors. push ( Error {
150
148
line_num : None ,
149
+ column_num : None ,
151
150
kind : ErrorKind :: Raw ,
152
151
msg : line. to_string ( ) ,
153
152
require_annotation : false ,
@@ -193,25 +192,9 @@ fn push_actual_errors(
193
192
// also ensure that `//~ ERROR E123` *always* works. The
194
193
// assumption is that these multi-line error messages are on their
195
194
// way out anyhow.
196
- let with_code = |span : Option < & DiagnosticSpan > , text : & str | {
197
- // FIXME(#33000) -- it'd be better to use a dedicated
198
- // UI harness than to include the line/col number like
199
- // this, but some current tests rely on it.
200
- //
201
- // Note: Do NOT include the filename. These can easily
202
- // cause false matches where the expected message
203
- // appears in the filename, and hence the message
204
- // changes but the test still passes.
205
- let span_str = match span {
206
- Some ( DiagnosticSpan { line_start, column_start, line_end, column_end, .. } ) => {
207
- format ! ( "{line_start}:{column_start}: {line_end}:{column_end}" )
208
- }
209
- None => format ! ( "?:?: ?:?" ) ,
210
- } ;
211
- match & diagnostic. code {
212
- Some ( code) => format ! ( "{span_str}: {text} [{}]" , code. code) ,
213
- None => format ! ( "{span_str}: {text}" ) ,
214
- }
195
+ let with_code = |text| match & diagnostic. code {
196
+ Some ( code) => format ! ( "{text} [{}]" , code. code) ,
197
+ None => format ! ( "{text}" ) ,
215
198
} ;
216
199
217
200
// Convert multi-line messages into multiple errors.
@@ -225,17 +208,19 @@ fn push_actual_errors(
225
208
|| Regex :: new ( r"aborting due to \d+ previous errors?|\d+ warnings? emitted" ) . unwrap ( ) ;
226
209
errors. push ( Error {
227
210
line_num : None ,
211
+ column_num : None ,
228
212
kind,
229
- msg : with_code ( None , first_line) ,
213
+ msg : with_code ( first_line) ,
230
214
require_annotation : diagnostic. level != "failure-note"
231
215
&& !RE . get_or_init ( re_init) . is_match ( first_line) ,
232
216
} ) ;
233
217
} else {
234
218
for span in primary_spans {
235
219
errors. push ( Error {
236
220
line_num : Some ( span. line_start ) ,
221
+ column_num : Some ( span. column_start ) ,
237
222
kind,
238
- msg : with_code ( Some ( span ) , first_line) ,
223
+ msg : with_code ( first_line) ,
239
224
require_annotation : true ,
240
225
} ) ;
241
226
}
@@ -244,16 +229,18 @@ fn push_actual_errors(
244
229
if primary_spans. is_empty ( ) {
245
230
errors. push ( Error {
246
231
line_num : None ,
232
+ column_num : None ,
247
233
kind,
248
- msg : with_code ( None , next_line) ,
234
+ msg : with_code ( next_line) ,
249
235
require_annotation : false ,
250
236
} ) ;
251
237
} else {
252
238
for span in primary_spans {
253
239
errors. push ( Error {
254
240
line_num : Some ( span. line_start ) ,
241
+ column_num : Some ( span. column_start ) ,
255
242
kind,
256
- msg : with_code ( Some ( span ) , next_line) ,
243
+ msg : with_code ( next_line) ,
257
244
require_annotation : false ,
258
245
} ) ;
259
246
}
@@ -266,6 +253,7 @@ fn push_actual_errors(
266
253
for ( index, line) in suggested_replacement. lines ( ) . enumerate ( ) {
267
254
errors. push ( Error {
268
255
line_num : Some ( span. line_start + index) ,
256
+ column_num : Some ( span. column_start ) ,
269
257
kind : ErrorKind :: Suggestion ,
270
258
msg : line. to_string ( ) ,
271
259
// Empty suggestions (suggestions to remove something) are common
@@ -288,6 +276,7 @@ fn push_actual_errors(
288
276
if let Some ( label) = & span. label {
289
277
errors. push ( Error {
290
278
line_num : Some ( span. line_start ) ,
279
+ column_num : Some ( span. column_start ) ,
291
280
kind : ErrorKind :: Note ,
292
281
msg : label. clone ( ) ,
293
282
// Empty labels (only underlining spans) are common and do not need annotations.
@@ -310,6 +299,7 @@ fn push_backtrace(
310
299
if Path :: new ( & expansion. span . file_name ) == Path :: new ( & file_name) {
311
300
errors. push ( Error {
312
301
line_num : Some ( expansion. span . line_start ) ,
302
+ column_num : Some ( expansion. span . column_start ) ,
313
303
kind : ErrorKind :: Note ,
314
304
msg : format ! ( "in this expansion of {}" , expansion. macro_decl_name) ,
315
305
require_annotation : true ,
0 commit comments