From a7e8208074877d7056821c0548fc22bdde54350f Mon Sep 17 00:00:00 2001 From: kadmin Date: Wed, 2 Sep 2020 19:19:43 +0000 Subject: [PATCH] Add regression test --- src/test/ui/issues/issue-75777.nll.stderr | 13 ++++++++++ src/test/ui/issues/issue-75777.rs | 17 +++++++++++++ src/test/ui/issues/issue-75777.stderr | 30 +++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/test/ui/issues/issue-75777.nll.stderr create mode 100644 src/test/ui/issues/issue-75777.rs create mode 100644 src/test/ui/issues/issue-75777.stderr diff --git a/src/test/ui/issues/issue-75777.nll.stderr b/src/test/ui/issues/issue-75777.nll.stderr new file mode 100644 index 00000000000..98aacb17119 --- /dev/null +++ b/src/test/ui/issues/issue-75777.nll.stderr @@ -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 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 + diff --git a/src/test/ui/issues/issue-75777.rs b/src/test/ui/issues/issue-75777.rs new file mode 100644 index 00000000000..291a3db0936 --- /dev/null +++ b/src/test/ui/issues/issue-75777.rs @@ -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 + 'a + Send>>; + +fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box 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() {} diff --git a/src/test/ui/issues/issue-75777.stderr b/src/test/ui/issues/issue-75777.stderr new file mode 100644 index 00000000000..16249a33c2f --- /dev/null +++ b/src/test/ui/issues/issue-75777.stderr @@ -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 BoxFuture<'a, A>> { + | ^^ +note: ...so that the types are compatible + --> $DIR/issue-75777.rs:13:14 + | +LL | Box::new(move |_| fut) + | ^^^^^^^^^^^^ + = note: expected `(Pin + Send>>,)` + found `(Pin + 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 + Send + 'a)>> + 'static)>` + found `Box Pin + Send + 'a)>>>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`.