Skip to content

Commit 17a9523

Browse files
committed
Reduce the visual clutter
Using a single label for constraints and generic arguments.
1 parent c9f55ea commit 17a9523

File tree

2 files changed

+27
-56
lines changed

2 files changed

+27
-56
lines changed

src/librustc_ast_passes/ast_validation.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,13 @@ impl<'a> AstValidator<'a> {
688688
arg_spans.clone(),
689689
"generic arguments must come before the first constraint",
690690
)
691-
.span_labels(constraint_spans, "constraint")
692-
.span_labels(arg_spans, "generic argument")
691+
.span_label(constraint_spans[0], &format!("constraint{}", pluralize!(constraint_len)))
692+
.span_label(
693+
*arg_spans.iter().last().unwrap(),
694+
&format!("generic argument{}", pluralize!(args_len)),
695+
)
696+
.span_labels(constraint_spans, "")
697+
.span_labels(arg_spans, "")
693698
.span_suggestion_verbose(
694699
data.span,
695700
&format!(

src/test/ui/suggestions/suggest-move-types.stderr

+20-54
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ error: generic arguments must come before the first constraint
1515
--> $DIR/suggest-move-types.rs:33:43
1616
|
1717
LL | struct Al<'a, T, M: OneWithLifetime<A=(), T, 'a>> {
18-
| ---- ^ ^^ generic argument
19-
| | |
20-
| | generic argument
18+
| ---- ^ ^^ generic arguments
19+
| |
2120
| constraint
2221
|
2322
help: move the constraint after the generic arguments
@@ -29,13 +28,9 @@ error: generic arguments must come before the first constraint
2928
--> $DIR/suggest-move-types.rs:40:46
3029
|
3130
LL | struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> {
32-
| ---- ---- ---- ^ ^ ^ generic argument
33-
| | | | | |
34-
| | | | | generic argument
35-
| | | | generic argument
36-
| | | constraint
37-
| | constraint
38-
| constraint
31+
| ---- ---- ---- ^ ^ ^ generic arguments
32+
| |
33+
| constraints
3934
|
4035
help: move the constraints after the generic arguments
4136
|
@@ -46,16 +41,9 @@ error: generic arguments must come before the first constraint
4641
--> $DIR/suggest-move-types.rs:48:71
4742
|
4843
LL | struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), C=(), T, U, V, 'a, 'b, 'c>> {
49-
| ---- ---- ---- ^ ^ ^ ^^ ^^ ^^ generic argument
50-
| | | | | | | | |
51-
| | | | | | | | generic argument
52-
| | | | | | | generic argument
53-
| | | | | | generic argument
54-
| | | | | generic argument
55-
| | | | generic argument
56-
| | | constraint
57-
| | constraint
58-
| constraint
44+
| ---- ---- ---- ^ ^ ^ ^^ ^^ ^^ generic arguments
45+
| |
46+
| constraints
5947
|
6048
help: move the constraints after the generic arguments
6149
|
@@ -66,13 +54,9 @@ error: generic arguments must come before the first constraint
6654
--> $DIR/suggest-move-types.rs:57:28
6755
|
6856
LL | struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> {
69-
| ^ ---- ---- ---- ^ ^ generic argument
70-
| | | | | |
71-
| | | | | generic argument
72-
| | | | constraint
73-
| | | constraint
74-
| | constraint
75-
| generic argument
57+
| ^ ---- ---- ---- ^ ^ generic arguments
58+
| |
59+
| constraints
7660
|
7761
help: move the constraints after the generic arguments
7862
|
@@ -83,16 +67,9 @@ error: generic arguments must come before the first constraint
8367
--> $DIR/suggest-move-types.rs:65:53
8468
|
8569
LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), C=(), U, 'b, V, 'c>> {
86-
| ^ ^^ ---- ---- ---- ^ ^^ ^ ^^ generic argument
87-
| | | | | | | | |
88-
| | | | | | | | generic argument
89-
| | | | | | | generic argument
90-
| | | | | | generic argument
91-
| | | | | constraint
92-
| | | | constraint
93-
| | | constraint
94-
| | generic argument
95-
| generic argument
70+
| ^ ^^ ---- ---- ---- ^ ^^ ^ ^^ generic arguments
71+
| |
72+
| constraints
9673
|
9774
help: move the constraints after the generic arguments
9875
|
@@ -103,13 +80,9 @@ error: generic arguments must come before the first constraint
10380
--> $DIR/suggest-move-types.rs:74:28
10481
|
10582
LL | struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> {
106-
| ^ ---- ---- ^ ---- ^ generic argument
107-
| | | | | |
108-
| | | | | constraint
109-
| | | | generic argument
110-
| | | constraint
111-
| | constraint
112-
| generic argument
83+
| ^ ---- ---- ^ ---- ^ generic arguments
84+
| |
85+
| constraints
11386
|
11487
help: move the constraints after the generic arguments
11588
|
@@ -120,16 +93,9 @@ error: generic arguments must come before the first constraint
12093
--> $DIR/suggest-move-types.rs:82:53
12194
|
12295
LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, 'b, C=(), V, 'c>> {
123-
| ^ ^^ ---- ---- ^ ^^ ---- ^ ^^ generic argument
124-
| | | | | | | | |
125-
| | | | | | | | generic argument
126-
| | | | | | | constraint
127-
| | | | | | generic argument
128-
| | | | | generic argument
129-
| | | | constraint
130-
| | | constraint
131-
| | generic argument
132-
| generic argument
96+
| ^ ^^ ---- ---- ^ ^^ ---- ^ ^^ generic arguments
97+
| |
98+
| constraints
13399
|
134100
help: move the constraints after the generic arguments
135101
|

0 commit comments

Comments
 (0)