-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse and suggest moving where clauses after equals for type aliases
- Loading branch information
Showing
4 changed files
with
158 additions
and
28 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,37 @@ | ||
// check-fail | ||
|
||
#![feature(generic_associated_types)] | ||
|
||
// Fine, but lints as unused | ||
type Foo where u32: Copy = (); | ||
// Not fine. | ||
type Bar = () where u32: Copy; | ||
//~^ ERROR where clause not allowed here | ||
type Baz = () where; | ||
//~^ ERROR where clause not allowed here | ||
|
||
trait Trait { | ||
// Fine. | ||
type Assoc where u32: Copy; | ||
// Fine. | ||
type Assoc2 where u32: Copy, i32: Copy; | ||
} | ||
|
||
impl Trait for u32 { | ||
// Fine. | ||
type Assoc where u32: Copy = (); | ||
// Not fine, suggests moving `i32: Copy` | ||
type Assoc2 where u32: Copy = () where i32: Copy; | ||
//~^ ERROR where clause not allowed here | ||
} | ||
|
||
impl Trait for i32 { | ||
// Not fine, suggests moving `u32: Copy` | ||
type Assoc = () where u32: Copy; | ||
//~^ ERROR where clause not allowed here | ||
// Not fine, suggests moving both. | ||
type Assoc2 = () where u32: Copy, i32: Copy; | ||
//~^ ERROR where clause not allowed here | ||
} | ||
|
||
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,40 @@ | ||
error: where clause not allowed here | ||
--> $DIR/type-alias-where.rs:8:15 | ||
| | ||
LL | type Bar = () where u32: Copy; | ||
| - ^^^^^^^^^^^^^^^ | ||
| | | ||
| help: move it here: `where u32: Copy` | ||
|
||
error: where clause not allowed here | ||
--> $DIR/type-alias-where.rs:10:15 | ||
| | ||
LL | type Baz = () where; | ||
| ^^^^^ | ||
|
||
error: where clause not allowed here | ||
--> $DIR/type-alias-where.rs:24:38 | ||
| | ||
LL | type Assoc2 where u32: Copy = () where i32: Copy; | ||
| - ^^^^^^^^^^^^^^^ | ||
| | | ||
| help: move it here: `, i32: Copy` | ||
|
||
error: where clause not allowed here | ||
--> $DIR/type-alias-where.rs:30:21 | ||
| | ||
LL | type Assoc = () where u32: Copy; | ||
| - ^^^^^^^^^^^^^^^ | ||
| | | ||
| help: move it here: `where u32: Copy` | ||
|
||
error: where clause not allowed here | ||
--> $DIR/type-alias-where.rs:33:22 | ||
| | ||
LL | type Assoc2 = () where u32: Copy, i32: Copy; | ||
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| help: move it here: `where u32: Copy, i32: Copy` | ||
|
||
error: aborting due to 5 previous errors | ||
|