Skip to content

Commit acac5c6

Browse files
committed
Add regression test
1 parent 95815c9 commit acac5c6

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/test/ui/issues/issue-75777.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Regression test for #75777.
2+
// Checks that a boxed future can be properly constructed.
3+
4+
#![feature(future_readiness_fns)]
5+
6+
use std::future::{self, Future};
7+
use std::pin::Pin;
8+
9+
type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + 'a + Send>>;
10+
11+
fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box<dyn FnOnce(&'a Env) -> BoxFuture<'a, A>> {
12+
let fut: BoxFuture<'a, A> = Box::pin(future::ready(v));
13+
Box::new(move |_| fut)
14+
//~^ ERROR: cannot infer an appropriate lifetime
15+
}
16+
17+
fn main() {}

src/test/ui/issues/issue-75777.stderr

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
2+
--> $DIR/issue-75777.rs:13:14
3+
|
4+
LL | Box::new(move |_| fut)
5+
| ^^^^^^^^^^^^
6+
|
7+
note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 11:11...
8+
--> $DIR/issue-75777.rs:11:11
9+
|
10+
LL | fn inject<'a, Env: 'a, A: 'a + Send>(v: A) -> Box<dyn FnOnce(&'a Env) -> BoxFuture<'a, A>> {
11+
| ^^
12+
note: ...so that the types are compatible
13+
--> $DIR/issue-75777.rs:13:14
14+
|
15+
LL | Box::new(move |_| fut)
16+
| ^^^^^^^^^^^^
17+
= note: expected `std::pin::Pin<std::boxed::Box<dyn std::future::Future<Output = A> + std::marker::Send>>`
18+
found `std::pin::Pin<std::boxed::Box<(dyn std::future::Future<Output = A> + std::marker::Send + 'a)>>`
19+
= note: but, the lifetime must be valid for the static lifetime...
20+
note: ...so that the expression is assignable
21+
--> $DIR/issue-75777.rs:13:5
22+
|
23+
LL | Box::new(move |_| fut)
24+
| ^^^^^^^^^^^^^^^^^^^^^^
25+
= 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)>`
26+
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)>>>`
27+
28+
error: aborting due to previous error
29+
30+
For more information about this error, try `rustc --explain E0495`.

0 commit comments

Comments
 (0)