-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
non-defining existential type use in defining scope with empty lifetime name #53457
Comments
Minimized example (playground) #![feature(existential_type)]
trait Future {
fn poll(&self, cx: &mut ());
}
trait Write {
fn poll_close(&self, cx: &mut ());
}
existential type Close<'a, W: Write>: Future + 'a;
fn broken<'a, W: Write>(w: &'a W) -> Close<'a, W> {
PollFn(move |cx| w.poll_close(cx))
}
fn working<'a, W: Write>(w: &'a W) -> impl Future + 'a {
PollFn(move |cx| w.poll_close(cx))
}
pub struct PollFn<F: Fn(&mut ())>(F);
impl<F> Future for PollFn<F> where F: Fn(&mut ()) {
fn poll(&self, cx: &mut ()) {
(&self.0)(cx)
}
}
Removing the |
This might be because existential types skip ( rust/src/librustc/middle/resolve_lifetime.rs Line 637 in 6bf6d50
rust/src/librustc/middle/resolve_lifetime.rs Line 656 in 6bf6d50
impl Trait does
|
Even more minified: existential type X: Clone;
fn bar<F: Fn(&i32) + Clone>(f: F) -> F {
f
}
fn foo() -> X {
bar(|x| ())
} or using more stdlib stuff: existential type X: Iterator<Item = i32>;
fn temp() -> X {
vec![1].into_iter().filter(|x| *x > 1)
} |
Also seen in |
I've hit this as well, have reduced it further: #![feature(existential_type)]
existential type Foo<R>: Fn(&R) -> ();
fn bar<R>() -> Foo<R> {
|r| ()
} Changing from |
Has there been progress in fixing this? I'd be willing to see if I can start work on a PR myself since I've been having issues with this. |
I think it should be enough to add a rust/src/librustc_typeck/check/writeback.rs Line 508 in 0576ac1
|
This seems to have been fixed recently, as the example in #53457 (comment) didn't work on nightly 2019-04-11, but now works on the playpen (if you click the link in that comment). |
The fix was in #60799 |
Add regression test for existential type ICE rust-lang#53457 Closes rust-lang#53457.
Add regression test for existential type ICE rust-lang#53457 Closes rust-lang#53457.
Add regression test for existential type ICE rust-lang#53457 Closes rust-lang#53457.
Rollup of 13 pull requests Successful merges: - #61135 (Fix documentation of `Rc::make_mut` regarding `rc::Weak`.) - #61404 (miri unsizing: fix projecting into a field of an operand) - #61409 (Fix an ICE with a const argument in a trait) - #61413 (Re-implement async fn drop order lowering ) - #61419 (Add an unusual-conversion example to to_uppercase) - #61420 (Succinctify splice docs) - #61444 (Suggest using `as_ref` on `*const T`) - #61446 (On TerminatorKind::DropAndReplace still handle unused_mut correctly) - #61485 (azure: retry s3 upload if it fails) - #61489 (ci: Reenable step timings on AppVeyor) - #61496 (Do not panic in tidy on unbalanced parentheses in cfg's) - #61497 (Treat 0 as special value for codegen-units-std) - #61499 (Add regression test for existential type ICE #53457) Failed merges: r? @ghost
Really not sure where the error here is coming from, as far as I can tell there should only be a single relevant lifetime,
'a
. The same function written as a free function generic over aWrite
returningimpl Future<...> + 'a
works fine (included in the playground). I'll try and come up with a reduced example in the next couple of days (playground)(CC @oli-obk in case you have any hints on where to look)
The text was updated successfully, but these errors were encountered: