Closed chvck closed 1 week ago
this kind of looks like it should be an ICE instead? :thinking:
@chvck: I'll try to put up a fix.
We're having a bit of a hard time debugging this issue [...]
It's due to #128506 (not that you need to understand what that PR does), not your fault.
For now, though, you'll need to either stop using async || {}
closures (since you've got an impl Fn() -> Fut
bound, not impl async Fn()
; why are you using async || {}
closures over just || async {}
, since those don't really buy you anything in this case?) or pin your nightly compiler version until I can minimize this and fix it.
Minimized:
#![feature(async_closure)]
use std::future::Future;
async fn orchestrate_memd_routing<Fut: Future>(operation: impl Fn() -> Fut) {
operation().await;
}
pub async fn orchestrate_simple_crud() {
orchestrate_memd_routing(async || async {}.await).await;
}
To reproduce: cargo +nightly build
(Odd that the "optimization" also happens in debug builds.)
Of note: During the minimization process, rust-analyzer froze multiple times. And a few times, cargo +nightly build
also froze.
@theemathas you're awesome! thanks for the minimization.
It's due to https://github.com/rust-lang/rust/pull/128506 (not that you need to understand what that PR does), not your fault.
Thanks for confirming.
For now, though, you'll need to either stop using async || {} closures (since you've got an impl Fn() -> Fut bound, not impl async Fn(); why are you using async || {} closures over just || async {}, since those don't really buy you anything in this case?) or pin your nightly compiler version until I can minimize this and fix it.
We were having a lot of issues with lifetimes when using the async blocks which lead to us using async closures instead. Possibly we should just revisit that...
@chvck You might be interested in these two links for an explanation on how exactly async closures differ from a closure that returns an async block:
https://blog.rust-lang.org/inside-rust/2024/08/09/async-closures-call-for-testing.html
Thanks @theemathas I'll take a look at those.
Originally posted at https://users.rust-lang.org/t/cycle-detected-when-optimizing-mir-on-nightly/116849/1 and filing this upon request from @bjorn3 .
We're using nightly rust and as of nightly-2024-08-29 (prior to this it compiled fine) we see the following error:
Function being flagged can be viewed at couchbase-rs/sdk/couchbase-core/src/crudcomponent.rs at nativex · couchbaselabs/couchbase-rs · GitHub. We're having a bit of a hard time debugging this issue, it's not very clear what this actually means. I've tried looking at the HIR output but it didn't really help and I'm a bit lost on this one as I'm not familiar with MIR.
I expected to see this happen: Compilation succeed.
Instead, this happened: Compilation failed due to MIR cycle.
Meta
rustc --version --verbose
:Backtrace contained no extra information.