forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix suggestions given mulitple bad lifetimes
When given multiple lifetimes prior to type parameters in generic parameters, do not ICE and print the correct suggestion.
- Loading branch information
1 parent
e2f221c
commit e3ba6ed
Showing
5 changed files
with
69 additions
and
21 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,9 @@ | ||
#![allow(unused)] | ||
fn first<T, 'a, 'b>() {} | ||
//~^ ERROR lifetime parameters must be declared prior to type parameters | ||
fn second<'a, T, 'b>() {} | ||
//~^ ERROR lifetime parameters must be declared prior to type parameters | ||
fn third<T, U, 'a>() {} | ||
//~^ ERROR lifetime parameters must be declared prior to type parameters | ||
fn fourth<'a, T, 'b, U, 'c, V>() {} | ||
//~^ ERROR lifetime parameters must be declared prior to type parameters |
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,47 @@ | ||
error: lifetime parameters must be declared prior to type parameters | ||
--> $DIR/lifetime-before-type-params.rs:2:13 | ||
| | ||
LL | fn first<T, 'a, 'b>() {} | ||
| ^^ ^^ | ||
help: move the lifetime parameter prior to the first type parameter | ||
| | ||
LL | fn first<'a, 'b, T>() {} | ||
| ^^^ ^^^ -- | ||
|
||
error: lifetime parameters must be declared prior to type parameters | ||
--> $DIR/lifetime-before-type-params.rs:4:18 | ||
| | ||
LL | fn second<'a, T, 'b>() {} | ||
| ^^ | ||
help: move the lifetime parameter prior to the first type parameter | ||
| | ||
LL | fn second<'a, 'b, T>() {} | ||
| ^^^ -- | ||
|
||
error: lifetime parameters must be declared prior to type parameters | ||
--> $DIR/lifetime-before-type-params.rs:6:16 | ||
| | ||
LL | fn third<T, U, 'a>() {} | ||
| ^^ | ||
help: move the lifetime parameter prior to the first type parameter | ||
| | ||
LL | fn third<'a, T, U>() {} | ||
| ^^^ -- | ||
|
||
error: lifetime parameters must be declared prior to type parameters | ||
--> $DIR/lifetime-before-type-params.rs:8:18 | ||
| | ||
LL | fn fourth<'a, T, 'b, U, 'c, V>() {} | ||
| ^^ ^^ | ||
help: move the lifetime parameter prior to the first type parameter | ||
| | ||
LL | fn fourth<'a, 'b, 'c, T, U, V>() {} | ||
| ^^^ ^^^ -- -- | ||
|
||
error[E0601]: `main` function not found in crate `lifetime_before_type_params` | ||
| | ||
= note: consider adding a `main` function to `$DIR/lifetime-before-type-params.rs` | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0601`. |
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