diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2025-05-03 14:10:58 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2025-05-03 22:49:23 +0300 |
| commit | 879b12e2ce3dc14ca2bc40ac1311e8f2bac19048 (patch) | |
| tree | 8a5e9a79a163c834c85658b8b78f329f1b96f145 /src/tools/compiletest | |
| parent | 097cd98869cf07a2860bef16c0d4a2b3b019b23a (diff) | |
| download | rust-879b12e2ce3dc14ca2bc40ac1311e8f2bac19048.tar.gz rust-879b12e2ce3dc14ca2bc40ac1311e8f2bac19048.zip | |
compiletest: Do not require annotations on empty labels and suggestions
Diffstat (limited to 'src/tools/compiletest')
| -rw-r--r-- | src/tools/compiletest/src/json.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 960f5ba5888..151ac345125 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -181,8 +181,6 @@ fn push_actual_errors( .filter(|(_, span)| Path::new(&span.file_name) == Path::new(&file_name)) .collect(); - let spans_in_this_file: Vec<_> = spans_info_in_this_file.iter().map(|(_, span)| span).collect(); - let primary_spans: Vec<_> = spans_info_in_this_file .iter() .filter(|(is_primary, _)| *is_primary) @@ -280,7 +278,9 @@ fn push_actual_errors( line_num: Some(span.line_start + index), kind: ErrorKind::Suggestion, msg: line.to_string(), - require_annotation: true, + // Empty suggestions (suggestions to remove something) are common + // and annotating them in source is not useful. + require_annotation: !line.is_empty(), }); } } @@ -294,13 +294,16 @@ fn push_actual_errors( } // Add notes for any labels that appear in the message. - for span in spans_in_this_file.iter().filter(|span| span.label.is_some()) { - errors.push(Error { - line_num: Some(span.line_start), - kind: ErrorKind::Note, - msg: span.label.clone().unwrap(), - require_annotation: true, - }); + for (_, span) in spans_info_in_this_file { + if let Some(label) = &span.label { + errors.push(Error { + line_num: Some(span.line_start), + kind: ErrorKind::Note, + msg: label.clone(), + // Empty labels (only underlining spans) are common and do not need annotations. + require_annotation: !label.is_empty(), + }); + } } // Flatten out the children. |
