Stream: general

Topic: Closure and higher ranked lifetime


marmeladema (Apr 06 2020 at 09:20, on Zulip):

So I made it work using GAT and adding a higher ranked lifetime to the ExecCtx associated type: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=29a19937604b78a9136fff0c3fae5e97

marmeladema (Apr 06 2020 at 09:20, on Zulip):

But i would really like to have it working on stable. Is there a way around? Or maybe another way to look at the problem?

marmeladema (Apr 06 2020 at 10:26, on Zulip):

I reduced it here: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=243dea1e7c1493bedd6e376ed12a2b21

It really seems like a problem with higher ranked lifetime and closure composition.
I think i would like to tell the compiler that in the compose function the higher ranked lifetime is the same for both the inner and the outer closure

marmeladema (Apr 06 2020 at 10:26, on Zulip):

(and its not about GAT anymore)

Paul Faria (Apr 06 2020 at 14:55, on Zulip):

I was able to get it to compile without GAT: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=db7a1e9d9bdaf990f1ba78974ce9db38

Paul Faria (Apr 06 2020 at 14:55, on Zulip):

Not sure if this still applies in your actual context

Paul Faria (Apr 06 2020 at 14:56, on Zulip):

I removed the nll feature and it made no difference, so now it works on stable: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=db7a1e9d9bdaf990f1ba78974ce9db38

Paul Faria (Apr 06 2020 at 14:58, on Zulip):

The originating change was converting:

pub trait Compiler: Sized {
    type ExecCtx<'e>;
    ...
}

to

pub trait Compiler<'a>: Sized {
    type ExecCtx: 'a;
    ...
}
marmeladema (Apr 06 2020 at 16:38, on Zulip):

Ill look into it!!! Thank you for the help

Last update: Jun 05 2020 at 23:05UTC