-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add suggestion for moving type declaration before associated type bindings in generic arguments. #57886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add suggestion for moving type declaration before associated type bindings in generic arguments. #57886
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,85 @@ | ||
// ignore-tidy-linelength | ||
|
||
#![allow(warnings)] | ||
|
||
// This test verifies that the suggestion to move types before associated type bindings | ||
// is correct. | ||
|
||
trait One<T> { | ||
type A; | ||
} | ||
|
||
trait OneWithLifetime<'a, T> { | ||
type A; | ||
} | ||
|
||
trait Three<T, U, V> { | ||
type A; | ||
type B; | ||
type C; | ||
} | ||
|
||
trait ThreeWithLifetime<'a, 'b, 'c, 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 Al<'a, T, M: OneWithLifetime<A=(), T, 'a>> { | ||
//~^ ERROR generic arguments must declare lifetimes, types and associated type bindings in that order | ||
m: M, | ||
t: &'a 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 Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), C=(), T, U, V, 'a, 'b, 'c>> { | ||
//~^ ERROR generic arguments must declare lifetimes, types and associated type bindings in that order | ||
m: M, | ||
t: &'a T, | ||
u: &'b U, | ||
v: &'c 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 Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), C=(), U, 'b, V, 'c>> { | ||
//~^ ERROR generic arguments must declare lifetimes, types and associated type bindings in that order | ||
m: M, | ||
t: &'a T, | ||
u: &'b U, | ||
v: &'c 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, | ||
} | ||
|
||
struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, 'b, C=(), V, 'c>> { | ||
//~^ ERROR generic arguments must declare lifetimes, types and associated type bindings in that order | ||
m: M, | ||
t: &'a T, | ||
u: &'b U, | ||
v: &'c V, | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,107 @@ | ||
error: type parameters must be declared prior to associated type bindings | ||
--> $DIR/suggest-move-types.rs:28: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: generic arguments must declare lifetimes, types and associated type bindings in that order | ||
--> $DIR/suggest-move-types.rs:34:46 | ||
| | ||
LL | struct Al<'a, T, M: OneWithLifetime<A=(), T, 'a>> { | ||
| ^ ^^ must be declared prior to type parameters | ||
| | | ||
| must be declared prior to associated type bindings | ||
help: move the parameters | ||
| | ||
LL | struct Al<'a, T, M: OneWithLifetime<'a, T, A=()>> { | ||
| ^^^ ^^ -- | ||
|
||
error: type parameters must be declared prior to associated type bindings | ||
--> $DIR/suggest-move-types.rs:40: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: generic arguments must declare lifetimes, types and associated type bindings in that order | ||
--> $DIR/suggest-move-types.rs:47:80 | ||
| | ||
LL | struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), C=(), T, U, V, 'a, 'b, 'c>> { | ||
| ^ ^ ^ ^^ ^^ ^^ must be declared prior to type parameters | ||
| | | | | | | ||
| | | | | must be declared prior to type parameters | ||
| | | | must be declared prior to type parameters | ||
| | | 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 parameters | ||
| | ||
LL | struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<'a, 'b, 'c, T, U, V, A=(), B=(), C=()>> { | ||
| ^^^ ^^^ ^^^ ^^ ^^ ^^ -- | ||
|
||
error: type parameters must be declared prior to associated type bindings | ||
--> $DIR/suggest-move-types.rs:55: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: generic arguments must declare lifetimes, types and associated type bindings in that order | ||
--> $DIR/suggest-move-types.rs:62:56 | ||
| | ||
LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), C=(), U, 'b, V, 'c>> { | ||
| ^^ ^ ^^ ^ ^^ must be declared prior to type parameters | ||
| | | | | | ||
| | | | must be declared prior to associated type bindings | ||
| | | must be declared prior to type parameters | ||
| | must be declared prior to associated type bindings | ||
| must be declared prior to type parameters | ||
help: move the parameters | ||
| | ||
LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<'a, 'b, 'c, T, U, V, A=(), B=(), C=()>> { | ||
| ^^^ ^^^ ^^^ -- ^^ ^^ -- | ||
|
||
error: type parameters must be declared prior to associated type bindings | ||
--> $DIR/suggest-move-types.rs:70: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 | ||
| ^^ ^^ -- -- | ||
davidtwco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
error: generic arguments must declare lifetimes, types and associated type bindings in that order | ||
--> $DIR/suggest-move-types.rs:77:56 | ||
| | ||
LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, 'b, C=(), V, 'c>> { | ||
| ^^ ^ ^^ ^ ^^ must be declared prior to type parameters | ||
| | | | | | ||
| | | | must be declared prior to associated type bindings | ||
| | | must be declared prior to type parameters | ||
| | must be declared prior to associated type bindings | ||
| must be declared prior to type parameters | ||
help: move the parameters | ||
| | ||
LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<'a, 'b, 'c, T, U, V, A=(), B=(), C=()>> { | ||
| ^^^ ^^^ ^^^ -- ^^ ^^ -- -- | ||
|
||
error: aborting due to 8 previous errors | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.