Skip to content

Commit 65a54a7

Browse files
committed
Tweak multispan rendering
Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments.
1 parent 21fe748 commit 65a54a7

File tree

111 files changed

+206
-653
lines changed

Some content is hidden

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

111 files changed

+206
-653
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3048,11 +3048,15 @@ impl FileWithAnnotatedLines {
30483048
// working correctly.
30493049
let middle = min(ann.line_start + 4, ann.line_end);
30503050
// We'll show up to 4 lines past the beginning of the multispan start.
3051-
// We will *not* include the tail of lines that are only whitespace.
3051+
// We will *not* include the tail of lines that are only whitespace, a comment or
3052+
// a bare delimiter.
30523053
let until = (ann.line_start..middle)
30533054
.rev()
30543055
.filter_map(|line| file.get_line(line - 1).map(|s| (line + 1, s)))
3055-
.find(|(_, s)| !s.trim().is_empty())
3056+
.find(|(_, s)| {
3057+
let s = s.trim();
3058+
!["", "{", "}", "(", ")", "[", "]"].contains(&s) && !s.starts_with("//")
3059+
})
30563060
.map(|(line, _)| line)
30573061
.unwrap_or(ann.line_start);
30583062
for line in ann.line_start + 1..until {

src/tools/clippy/tests/ui-toml/excessive_nesting/excessive_nesting.stderr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ error: this block is too nested
6666
LL | if true {
6767
| _________________________^
6868
LL | | if true {
69-
LL | |
70-
LL | | }
69+
... |
7170
LL | | }
7271
| |_________________^
7372
|

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ error: an async construct yields a type which is itself awaitable
8080
LL | let _m = async || {
8181
| _______________________-
8282
LL | | println!("I'm bored");
83-
LL | | // Some more stuff
8483
... |
8584
LL | | CustomFutureType
8685
| | ^^^^^^^^^^^^^^^^

src/tools/clippy/tests/ui/branches_sharing_code/shared_at_bottom.stderr

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ error: all if blocks contain the same code at the end
115115
--> tests/ui/branches_sharing_code/shared_at_bottom.rs:183:5
116116
|
117117
LL | / x << 2
118-
LL | |
119-
LL | |
118+
... |
120119
LL | | };
121120
| |_____^
122121
|
@@ -131,8 +130,7 @@ error: all if blocks contain the same code at the end
131130
--> tests/ui/branches_sharing_code/shared_at_bottom.rs:192:5
132131
|
133132
LL | / x * 4
134-
LL | |
135-
LL | |
133+
... |
136134
LL | | }
137135
| |_____^
138136
|

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ LL | } else {
4343
| ____________^
4444
LL | | if y == "world" {
4545
LL | | println!("world")
46-
LL | | }
4746
... |
4847
LL | | }
4948
LL | | }
@@ -66,7 +65,6 @@ LL | } else {
6665
| ____________^
6766
LL | | if let Some(42) = Some(42) {
6867
LL | | println!("world")
69-
LL | | }
7068
... |
7169
LL | | }
7270
LL | | }
@@ -89,7 +87,6 @@ LL | } else {
8987
| ____________^
9088
LL | | if let Some(42) = Some(42) {
9189
LL | | println!("world")
92-
LL | | }
9390
... |
9491
LL | | }
9592
LL | | }
@@ -112,7 +109,6 @@ LL | } else {
112109
| ____________^
113110
LL | | if x == "hello" {
114111
LL | | println!("world")
115-
LL | | }
116112
... |
117113
LL | | }
118114
LL | | }
@@ -135,7 +131,6 @@ LL | } else {
135131
| ____________^
136132
LL | | if let Some(42) = Some(42) {
137133
LL | | println!("world")
138-
LL | | }
139134
... |
140135
LL | | }
141136
LL | | }

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ error: this loop never actually loops
22
--> tests/ui/crashes/ice-360.rs:5:5
33
|
44
LL | / loop {
5-
LL | |
6-
LL | |
7-
LL | |
85
... |
96
LL | |
107
LL | | }
@@ -16,9 +13,6 @@ error: this loop could be written as a `while let` loop
1613
--> tests/ui/crashes/ice-360.rs:5:5
1714
|
1815
LL | / loop {
19-
LL | |
20-
LL | |
21-
LL | |
2216
... |
2317
LL | |
2418
LL | | }

src/tools/clippy/tests/ui/crate_level_checks/no_std_swap.stderr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ error: this looks like you are trying to swap `a` and `b`
22
--> tests/ui/crate_level_checks/no_std_swap.rs:12:5
33
|
44
LL | / a = b;
5-
LL | |
6-
LL | |
5+
... |
76
LL | | b = a;
87
| |_________^ help: try: `core::mem::swap(&mut a, &mut b)`
98
|

src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ error: backticks are unbalanced
33
|
44
LL | /// This is a doc comment with `unbalanced_tick marks and several words that
55
| _____^
6-
LL | |
7-
LL | | /// should be `encompassed_by` tick marks because they `contain_underscores`.
8-
LL | | /// Because of the initial `unbalanced_tick` pair, the error message is
6+
... |
97
LL | | /// very `confusing_and_misleading`.
108
| |____________________________________^
119
|

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ error: empty lines after doc comment
9696
--> tests/ui/empty_line_after/doc_comments.rs:63:5
9797
|
9898
LL | / /// for OldA
99-
LL | | // struct OldA;
100-
LL | |
101-
LL | | /// Docs
102-
LL | | /// for OldB
99+
... |
103100
LL | | // struct OldB;
104101
LL | |
105102
| |_^

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ error: empty lines after outer attribute
103103
--> tests/ui/empty_line_after/outer_attribute.rs:64:1
104104
|
105105
LL | / #[allow(unused)]
106-
LL | |
107-
LL | | // This comment is isolated
106+
... |
108107
LL | |
109108
| |_^
110109
LL | pub fn isolated_comment() {}

0 commit comments

Comments
 (0)