1
Fork 0

Reduce the visual clutter

Using a single label for constraints and generic arguments.
This commit is contained in:
Esteban Küber 2020-04-05 17:02:44 -07:00
parent c9f55ea689
commit 17a95232b3
2 changed files with 27 additions and 56 deletions

View file

@ -688,8 +688,13 @@ impl<'a> AstValidator<'a> {
arg_spans.clone(), arg_spans.clone(),
"generic arguments must come before the first constraint", "generic arguments must come before the first constraint",
) )
.span_labels(constraint_spans, "constraint") .span_label(constraint_spans[0], &format!("constraint{}", pluralize!(constraint_len)))
.span_labels(arg_spans, "generic argument") .span_label(
*arg_spans.iter().last().unwrap(),
&format!("generic argument{}", pluralize!(args_len)),
)
.span_labels(constraint_spans, "")
.span_labels(arg_spans, "")
.span_suggestion_verbose( .span_suggestion_verbose(
data.span, data.span,
&format!( &format!(

View file

@ -15,9 +15,8 @@ error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:33:43 --> $DIR/suggest-move-types.rs:33:43
| |
LL | struct Al<'a, T, M: OneWithLifetime<A=(), T, 'a>> { LL | struct Al<'a, T, M: OneWithLifetime<A=(), T, 'a>> {
| ---- ^ ^^ generic argument | ---- ^ ^^ generic arguments
| | | | |
| | generic argument
| constraint | constraint
| |
help: move the constraint after the generic arguments help: move the constraint after the generic arguments
@ -29,13 +28,9 @@ error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:40:46 --> $DIR/suggest-move-types.rs:40:46
| |
LL | struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> { LL | struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> {
| ---- ---- ---- ^ ^ ^ generic argument | ---- ---- ---- ^ ^ ^ generic arguments
| | | | | | | |
| | | | | generic argument | constraints
| | | | generic argument
| | | constraint
| | constraint
| constraint
| |
help: move the constraints after the generic arguments help: move the constraints after the generic arguments
| |
@ -46,16 +41,9 @@ error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:48:71 --> $DIR/suggest-move-types.rs:48:71
| |
LL | struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), C=(), T, U, V, 'a, 'b, 'c>> { LL | struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), C=(), T, U, V, 'a, 'b, 'c>> {
| ---- ---- ---- ^ ^ ^ ^^ ^^ ^^ generic argument | ---- ---- ---- ^ ^ ^ ^^ ^^ ^^ generic arguments
| | | | | | | | | | |
| | | | | | | | generic argument | constraints
| | | | | | | generic argument
| | | | | | generic argument
| | | | | generic argument
| | | | generic argument
| | | constraint
| | constraint
| constraint
| |
help: move the constraints after the generic arguments help: move the constraints after the generic arguments
| |
@ -66,13 +54,9 @@ error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:57:28 --> $DIR/suggest-move-types.rs:57:28
| |
LL | struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> { LL | struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> {
| ^ ---- ---- ---- ^ ^ generic argument | ^ ---- ---- ---- ^ ^ generic arguments
| | | | | | | |
| | | | | generic argument | constraints
| | | | constraint
| | | constraint
| | constraint
| generic argument
| |
help: move the constraints after the generic arguments help: move the constraints after the generic arguments
| |
@ -83,16 +67,9 @@ error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:65:53 --> $DIR/suggest-move-types.rs:65:53
| |
LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), C=(), U, 'b, V, 'c>> { LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), C=(), U, 'b, V, 'c>> {
| ^ ^^ ---- ---- ---- ^ ^^ ^ ^^ generic argument | ^ ^^ ---- ---- ---- ^ ^^ ^ ^^ generic arguments
| | | | | | | | | | |
| | | | | | | | generic argument | constraints
| | | | | | | generic argument
| | | | | | generic argument
| | | | | constraint
| | | | constraint
| | | constraint
| | generic argument
| generic argument
| |
help: move the constraints after the generic arguments help: move the constraints after the generic arguments
| |
@ -103,13 +80,9 @@ error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:74:28 --> $DIR/suggest-move-types.rs:74:28
| |
LL | struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> { LL | struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> {
| ^ ---- ---- ^ ---- ^ generic argument | ^ ---- ---- ^ ---- ^ generic arguments
| | | | | | | |
| | | | | constraint | constraints
| | | | generic argument
| | | constraint
| | constraint
| generic argument
| |
help: move the constraints after the generic arguments help: move the constraints after the generic arguments
| |
@ -120,16 +93,9 @@ error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:82:53 --> $DIR/suggest-move-types.rs:82:53
| |
LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, 'b, C=(), V, 'c>> { LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, 'b, C=(), V, 'c>> {
| ^ ^^ ---- ---- ^ ^^ ---- ^ ^^ generic argument | ^ ^^ ---- ---- ^ ^^ ---- ^ ^^ generic arguments
| | | | | | | | | | |
| | | | | | | | generic argument | constraints
| | | | | | | constraint
| | | | | | generic argument
| | | | | generic argument
| | | | constraint
| | | constraint
| | generic argument
| generic argument
| |
help: move the constraints after the generic arguments help: move the constraints after the generic arguments
| |