-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggestion moving types before associated types.
This commit extends existing suggestions to move lifetimes before types in generic arguments to also suggest moving types behind associated type bindings.
- Loading branch information
Showing
4 changed files
with
147 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#![allow(warnings)] | ||
|
||
// This test verifies that the suggestion to move types before associated type bindings | ||
// is correct. | ||
|
||
trait One<T> { | ||
type A; | ||
} | ||
|
||
trait Three<T, U, V> { | ||
type A; | ||
type B; | ||
type C; | ||
} | ||
|
||
struct A<T, M: One<A=(), T>> { //~ ERROR type parameters must be declared | ||
m: M, | ||
t: T, | ||
} | ||
|
||
struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> { //~ ERROR type parameters must be declared | ||
m: M, | ||
t: T, | ||
u: U, | ||
v: V, | ||
} | ||
|
||
struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> { //~ ERROR type parameters must be declared | ||
m: M, | ||
t: T, | ||
u: U, | ||
v: V, | ||
} | ||
|
||
struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> { //~ ERROR type parameters must be declared | ||
m: M, | ||
t: T, | ||
u: U, | ||
v: V, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
error: type parameters must be declared prior to associated type bindings | ||
--> $DIR/suggest-move-types.rs:16:26 | ||
| | ||
LL | struct A<T, M: One<A=(), T>> { //~ ERROR type parameters must be declared | ||
| ^ must be declared prior to associated type bindings | ||
help: move the type parameter prior to the first associated type binding | ||
| | ||
LL | struct A<T, M: One<T, A=()>> { //~ ERROR type parameters must be declared | ||
| ^^ -- | ||
|
||
error: type parameters must be declared prior to associated type bindings | ||
--> $DIR/suggest-move-types.rs:21:46 | ||
| | ||
LL | struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> { //~ ERROR type parameters must be declared | ||
| ^ ^ ^ must be declared prior to associated type bindings | ||
| | | | ||
| | must be declared prior to associated type bindings | ||
| must be declared prior to associated type bindings | ||
help: move the type parameters prior to the first associated type binding | ||
| | ||
LL | struct B<T, U, V, M: Three<T, U, V, A=(), B=(), C=()>> { //~ ERROR type parameters must be declared | ||
| ^^ ^^ ^^ -- | ||
|
||
error: type parameters must be declared prior to associated type bindings | ||
--> $DIR/suggest-move-types.rs:28:49 | ||
| | ||
LL | struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> { //~ ERROR type parameters must be declared | ||
| ^ ^ must be declared prior to associated type bindings | ||
| | | ||
| must be declared prior to associated type bindings | ||
help: move the type parameters prior to the first associated type binding | ||
| | ||
LL | struct C<T, U, V, M: Three<T, U, V, A=(), B=(), C=()>> { //~ ERROR type parameters must be declared | ||
| ^^ ^^ -- | ||
|
||
error: type parameters must be declared prior to associated type bindings | ||
--> $DIR/suggest-move-types.rs:35:43 | ||
| | ||
LL | struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> { //~ ERROR type parameters must be declared | ||
| ^ ^ must be declared prior to associated type bindings | ||
| | | ||
| must be declared prior to associated type bindings | ||
help: move the type parameters prior to the first associated type binding | ||
| | ||
LL | struct D<T, U, V, M: Three<T, U, V, A=(), B=(), C=()>> { //~ ERROR type parameters must be declared | ||
| ^^ ^^ -- -- | ||
|
||
error: aborting due to 4 previous errors | ||
|