Skip to content

Commit 49a22a4

Browse files
committed
Filter empty lines, comments and delimiters from previous to last multiline span rendering
1 parent 65a54a7 commit 49a22a4

File tree

103 files changed

+115
-401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+115
-401
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3064,7 +3064,11 @@ impl FileWithAnnotatedLines {
30643064
add_annotation_to_file(&mut output, Lrc::clone(&file), line, ann.as_line());
30653065
}
30663066
let line_end = ann.line_end - 1;
3067-
if middle < line_end {
3067+
let end_is_empty = file.get_line(line_end - 1).map_or(false, |s| {
3068+
let s = s.trim();
3069+
["", "{", "}", "(", ")", "[", "]"].contains(&s) || s.starts_with("//")
3070+
});
3071+
if middle < line_end && !end_is_empty {
30683072
add_annotation_to_file(&mut output, Lrc::clone(&file), line_end, ann.as_line());
30693073
}
30703074
} else {

src/tools/clippy/tests/ui-toml/arbitrary_source_item_ordering/ordering_mixed.default.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ LL | | fn clone_self(&self) -> Self {
2020
LL | | Self {
2121
LL | | a: true,
2222
... |
23-
LL | | }
2423
LL | | }
2524
| |_^
2625
|
@@ -32,7 +31,6 @@ LL | | fn default() -> Self {
3231
LL | | Self {
3332
LL | | a: true,
3433
... |
35-
LL | | }
3634
LL | | }
3735
| |_^
3836

src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ LL | | if unsafe { true } {
286286
LL | | todo!();
287287
LL | | } else {
288288
... |
289-
LL | | }
290289
LL | | };
291290
| |______^
292291
|

src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.disabled.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ LL | | if unsafe { true } {
294294
LL | | todo!();
295295
LL | | } else {
296296
... |
297-
LL | | }
298297
LL | | };
299298
| |______^
300299
|

src/tools/clippy/tests/ui/bind_instead_of_map_multipart.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ LL | | if {
4444
LL | | if s == "43" {
4545
LL | | return Some(43);
4646
... |
47-
LL | | }
4847
LL | | });
4948
| |______^
5049
|

src/tools/clippy/tests/ui/collapsible_else_if.stderr

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ LL | } else {
4444
LL | | if y == "world" {
4545
LL | | println!("world")
4646
... |
47-
LL | | }
4847
LL | | }
4948
| |_____^
5049
|
@@ -66,7 +65,6 @@ LL | } else {
6665
LL | | if let Some(42) = Some(42) {
6766
LL | | println!("world")
6867
... |
69-
LL | | }
7068
LL | | }
7169
| |_____^
7270
|
@@ -88,7 +86,6 @@ LL | } else {
8886
LL | | if let Some(42) = Some(42) {
8987
LL | | println!("world")
9088
... |
91-
LL | | }
9289
LL | | }
9390
| |_____^
9491
|
@@ -110,7 +107,6 @@ LL | } else {
110107
LL | | if x == "hello" {
111108
LL | | println!("world")
112109
... |
113-
LL | | }
114110
LL | | }
115111
| |_____^
116112
|
@@ -132,7 +128,6 @@ LL | } else {
132128
LL | | if let Some(42) = Some(42) {
133129
LL | | println!("world")
134130
... |
135-
LL | | }
136131
LL | | }
137132
| |_____^
138133
|

src/tools/clippy/tests/ui/copy_iterator.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | |
66
LL | |
77
LL | | type Item = u8;
88
... |
9-
LL | | }
109
LL | | }
1110
| |_^
1211
|

src/tools/clippy/tests/ui/crashes/ice-360.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ error: this loop never actually loops
33
|
44
LL | / loop {
55
... |
6-
LL | |
76
LL | | }
87
| |_____^
98
|
@@ -14,7 +13,6 @@ error: this loop could be written as a `while let` loop
1413
|
1514
LL | / loop {
1615
... |
17-
LL | |
1816
LL | | }
1917
| |_____^ help: try: `while let Some(ele) = iter.next() { .. }`
2018
|

src/tools/clippy/tests/ui/derivable_impls.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | | fn default() -> Self {
66
LL | | Self {
77
LL | | a: false,
88
... |
9-
LL | | }
109
LL | | }
1110
| |_^
1211
|

src/tools/clippy/tests/ui/empty_line_after/doc_comments.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ error: empty lines after doc comment
9797
|
9898
LL | / /// for OldA
9999
... |
100-
LL | | // struct OldB;
101100
LL | |
102101
| |_^
103102
...

0 commit comments

Comments
 (0)