Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression test #76257

Merged
merged 1 commit into from
Oct 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/test/ui/issues/issue-75777.nll.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: lifetime may not live long enough
--> $DIR/issue-75777.rs:13:5
|
LL | fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box<dyn FnOnce(&'a Env) -> BoxFuture<'a, A>> {
| -- lifetime `'a` defined here
LL | let fut: BoxFuture<'a, A> = Box::pin(future::ready(v));
LL | Box::new(move |_| fut)
| ^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
|
= help: consider replacing `'a` with `'static`

error: aborting due to previous error

17 changes: 17 additions & 0 deletions src/test/ui/issues/issue-75777.rs
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() {}
30 changes: 30 additions & 0 deletions src/test/ui/issues/issue-75777.stderr
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 `(Pin<Box<dyn Future<Output = A> + Send>>,)`
found `(Pin<Box<(dyn Future<Output = A> + 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 `Box<(dyn FnOnce(&'a Env) -> Pin<Box<(dyn Future<Output = A> + Send + 'a)>> + 'static)>`
found `Box<dyn FnOnce(&'a Env) -> Pin<Box<(dyn Future<Output = A> + Send + 'a)>>>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0495`.