forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#76257 - JulianKnodt:i75777, r=Dylan-DPC
Add regression test This adds a regression test for rust-lang#75777, effectively closing it since it is solved on nightly and beta.
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Regression test for #75777. | ||
// Checks that a boxed future can be properly constructed. | ||
|
||
#![feature(future_readiness_fns)] | ||
|
||
use std::future::{self, Future}; | ||
use std::pin::Pin; | ||
|
||
type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a + Send>>; | ||
|
||
fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box<dyn FnOnce(&'a Env) -> BoxFuture<'a, A>> { | ||
let fut: BoxFuture<'a, A> = Box::pin(future::ready(v)); | ||
Box::new(move |_| fut) | ||
//~^ ERROR: cannot infer an appropriate lifetime | ||
} | ||
|
||
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,30 @@ | ||
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements | ||
--> $DIR/issue-75777.rs:13:14 | ||
| | ||
LL | Box::new(move |_| fut) | ||
| ^^^^^^^^^^^^ | ||
| | ||
note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 11:11... | ||
--> $DIR/issue-75777.rs:11:11 | ||
| | ||
LL | fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box<dyn FnOnce(&'a Env) -> BoxFuture<'a, A>> { | ||
| ^^ | ||
note: ...so that the types are compatible | ||
--> $DIR/issue-75777.rs:13:14 | ||
| | ||
LL | Box::new(move |_| fut) | ||
| ^^^^^^^^^^^^ | ||
= note: expected `std::pin::Pin<std::boxed::Box<dyn std::future::Future<Output = A> + std::marker::Send>>` | ||
found `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = A> + std::marker::Send + 'a)>>` | ||
= note: but, the lifetime must be valid for the static lifetime... | ||
note: ...so that the expression is assignable | ||
--> $DIR/issue-75777.rs:13:5 | ||
| | ||
LL | Box::new(move |_| fut) | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: expected `std::boxed::Box<(dyn std::ops::FnOnce(&'a Env) -> std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = A> + std::marker::Send + 'a)>> + 'static)>` | ||
found `std::boxed::Box<dyn std::ops::FnOnce(&'a Env) -> std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = A> + std::marker::Send + 'a)>>>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0495`. |