_ => None,
})
.collect::<Vec<_>>();
+ let snippet_span = match &constraint_spans[..] {
+ [single] => *single,
+ [first, .., last] => first.to(*last),
+ [] => unreachable!(),
+ };
+ let removal_span = match &arg_spans[..] {
+ [first, ..] => snippet_span.until(*first),
+ [] => unreachable!(),
+ };
+ let sugg_span = match &arg_spans[..] {
+ [.., last] => last.shrink_to_hi(),
+ [] => unreachable!(),
+ };
+ let snippet = self.session.source_map().span_to_snippet(snippet_span).unwrap();
let constraint_len = constraint_spans.len();
// ...and then error:
self.err_handler()
),
)
.span_labels(arg_spans, "generic argument")
+ .multipart_suggestion(
+ "move the constraints after the generic arguments",
+ vec![
+ (removal_span, String::new()),
+ (sugg_span.shrink_to_lo(), ", ".to_string()),
+ (sugg_span, snippet),
+ ],
+ Applicability::MachineApplicable,
+ )
.emit();
}
}
| ---- ^ generic argument
| |
| the constraint is provided here
+ |
+help: move the constraints after the generic arguments
+ |
+LL | struct A<T, M: One<T, A=()>> {
+ | --^^^^
error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:33:43
| | |
| | generic argument
| the constraint is provided here
+ |
+help: move the constraints after the generic arguments
+ |
+LL | struct Al<'a, T, M: OneWithLifetime<T, 'a, A=()>> {
+ | -- ^^^^
error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:40:46
| | | the constraints are provided here
| | the constraints are provided here
| the constraints are provided here
+ |
+help: move the constraints after the generic arguments
+ |
+LL | struct B<T, U, V, M: Three<T, U, V, A=(), B=(), C=()>> {
+ | -- ^^^^^^^^^^^^^^^^
error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:48:71
| | | the constraints are provided here
| | the constraints are provided here
| the constraints are provided here
+ |
+help: move the constraints after the generic arguments
+ |
+LL | struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, U, V, 'a, 'b, 'c, A=(), B=(), C=()>> {
+ | -- ^^^^^^^^^^^^^^^^
error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:57:28
| | | the constraints are provided here
| | the constraints are provided here
| generic argument
+ |
+help: move the constraints after the generic arguments
+ |
+LL | struct C<T, U, V, M: Three<A=(), B=(), C=(), U, V, A=(), B=(), C=()>> {
+ | -- ^^^^^^^^^^^^^^^^
error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:65:53
| | | the constraints are provided here
| | generic argument
| generic argument
+ |
+help: move the constraints after the generic arguments
+ |
+LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), C=(), U, 'b, V, 'c, A=(), B=(), C=()>> {
+ | -- ^^^^^^^^^^^^^^^^
error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:74:28
| | | the constraints are provided here
| | the constraints are provided here
| generic argument
+ |
+help: move the constraints after the generic arguments
+ |
+LL | struct D<T, U, V, M: Three<A=(), B=(), U, C=(), V, A=(), B=(), U, C=()>> {
+ | -- ^^^^^^^^^^^^^^^^^^^
error: generic arguments must come before the first constraint
--> $DIR/suggest-move-types.rs:82:53
| | | the constraints are provided here
| | generic argument
| generic argument
+ |
+help: move the constraints after the generic arguments
+ |
+LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), U, 'b, C=(), V, 'c, A=(), B=(), U, 'b, C=()>> {
+ | -- ^^^^^^^^^^^^^^^^^^^^^^^
error[E0747]: type provided when a lifetime was expected
--> $DIR/suggest-move-types.rs:33:43