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.
Rollup merge of rust-lang#65730 - csmoe:return-lifetime, r=nikomatsakis
Suggest to add lifetime constraint at explicit ouput of functions Closes rust-lang#62097
- Loading branch information
Showing
11 changed files
with
74 additions
and
29 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
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
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,19 @@ | ||
// edition:2018 | ||
async fn foo<F>(fun: F) | ||
where | ||
F: FnOnce() + 'static | ||
{ | ||
fun() | ||
} | ||
|
||
struct Struct; | ||
|
||
impl Struct { | ||
pub async fn run_dummy_fn(&self) { //~ ERROR cannot infer | ||
foo(|| self.bar()).await; | ||
} | ||
|
||
pub fn bar(&self) {} | ||
} | ||
|
||
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,16 @@ | ||
error: cannot infer an appropriate lifetime | ||
--> $DIR/issue-62097.rs:12:31 | ||
| | ||
LL | pub async fn run_dummy_fn(&self) { | ||
| ^^^^^ ...but this borrow... | ||
LL | foo(|| self.bar()).await; | ||
| --- this return type evaluates to the `'static` lifetime... | ||
| | ||
note: ...can't outlive the lifetime `'_` as defined on the method body at 12:31 | ||
--> $DIR/issue-62097.rs:12:31 | ||
| | ||
LL | pub async fn run_dummy_fn(&self) { | ||
| ^ | ||
|
||
error: aborting due to previous error | ||
|
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