-
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.
Suggest correct location for lifetime parameters in use
- Loading branch information
Showing
7 changed files
with
82 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
fn main() { | ||
(0..4) | ||
.map(|x| x * 2) | ||
.collect::<Vec<'a, usize, 'b>>() | ||
//~^ ERROR lifetime parameters must be declared prior to type parameters | ||
//~| ERROR use of undeclared lifetime name | ||
//~| ERROR use of undeclared lifetime name | ||
// can't run rustfix because it doesn't handle multipart suggestions correctly | ||
// compile-flags: -Zborrowck=mir | ||
// we need the above to avoid ast borrowck failure in recovered code | ||
|
||
struct S<'a, T> { | ||
a: &'a T, | ||
b: &'a T, | ||
} | ||
|
||
fn foo<'a, 'b>(start: &'a usize, end: &'a usize) { | ||
let _x = (*start..*end) | ||
.map(|x| S { a: start, b: end }) | ||
.collect::<Vec<S<_, 'a>>>(); | ||
//~^ ERROR lifetime parameters must be declared prior to type parameters | ||
} | ||
|
||
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 |
---|---|---|
@@ -1,21 +1,12 @@ | ||
error: lifetime parameters must be declared prior to type parameters | ||
--> $DIR/issue-14303-fncall.rs:4:31 | ||
--> $DIR/issue-14303-fncall.rs:13:29 | ||
| | ||
LL | .collect::<Vec<'a, usize, 'b>>() | ||
| ^^ must be declared prior to type parameters | ||
|
||
error[E0261]: use of undeclared lifetime name `'a` | ||
--> $DIR/issue-14303-fncall.rs:4:20 | ||
| | ||
LL | .collect::<Vec<'a, usize, 'b>>() | ||
| ^^ undeclared lifetime | ||
|
||
error[E0261]: use of undeclared lifetime name `'b` | ||
--> $DIR/issue-14303-fncall.rs:4:31 | ||
LL | .collect::<Vec<S<_, 'a>>>(); | ||
| ^^ must be declared prior to type parameters | ||
help: move the lifetime parameter prior to the first type parameter | ||
| | ||
LL | .collect::<Vec<'a, usize, 'b>>() | ||
| ^^ undeclared lifetime | ||
LL | .collect::<Vec<S<'a, _>>>(); | ||
| ^^^ -- | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0261`. |
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
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