-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
existential type
complains about '_
in concrete type of self-borrowing generators
#60655
Comments
Am I correct in assuming that this should not compile, but report an error about returning a reference to the local variable I'll try pretty printing to the expanded HIR, since I'm not sure what's going on there |
Expanded version: #![feature(gen_future)]
#![feature(generators)]
#![feature(async_await, await_macro, existential_type)]
use std::future::{self, Future};
async fn foo(__arg0: &u8) {
}
pub existential type ServeFut: Future<Output = ()>;
fn bar() -> ServeFut {
::std::future::from_generator(move || {
let x = 5;
{
let mut pinned = foo(&x);
loop {
match future::poll_with_tls_context(unsafe {
std::pin::Pin::new_unchecked(&mut pinned)
}) {
std::task::Poll::Ready(x) => {
break x;
}
_ => (),
}
yield ()
}
}
})
}
fn main() {} |
No, this should definitely compile.
|
Hmm, so because the generator contains references, it has lifetimes, but these lifetimes actually refer to the generator again? Do we have a special kind of lifetime that we use for this? We should just ignore those generator lifetimes for existential types. |
We should ignore all bound regions. Function pointers have the same issue: existential type A: Sized;
fn foo() -> A {
(|x| ()) as for<'a> fn(&'a i32)
}
fn main() {} |
…n-existential-types, r=oli-obk Allow late-bound regions in existential types closes rust-lang#60655 r? @oli-obk
Playground
cc @oli-obk
The text was updated successfully, but these errors were encountered: