Skip to content

ICE: not yet implemented: FIXME(async_closures): Lower these to SMIR #134246

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
matthiaskrgr opened this issue Dec 13, 2024 · 7 comments · Fixed by #134295
Closed

ICE: not yet implemented: FIXME(async_closures): Lower these to SMIR #134246

matthiaskrgr opened this issue Dec 13, 2024 · 7 comments · Fixed by #134295
Assignees
Labels
A-async-closures `async || {}` A-stable-MIR Area: stable MIR C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

snippet:

//@compile-flags: -Zunpretty=stable-mir --edition=2018
use std::future::ready;
pub fn main() {
    let mut vec: Vec<String> = vec![];

    let closure = async || {
        vec.push(ready(String::from("")).await);
    };
}

Version information

rustc 1.85.0-nightly (f4f0fafd0 2024-12-13)
binary: rustc
commit-hash: f4f0fafd0c7849e162eddbc69fa5fe82dbec28c7
commit-date: 2024-12-13
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.5

Possibly related line of code:

tables.coroutine_def(*def_id),
generic_arg.stable(tables),
tables.tcx.coroutine_movability(*def_id).stable(tables),
)
}
mir::AggregateKind::CoroutineClosure(..) => {
todo!("FIXME(async_closures): Lower these to SMIR")
}
mir::AggregateKind::RawPtr(ty, mutability) => {
stable_mir::mir::AggregateKind::RawPtr(ty.stable(tables), mutability.stable(tables))
}
}
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zunpretty=stable-mir --edition=2018

Program output

warning: unused variable: `closure`
 --> /tmp/icemaker_global_tempdir.AGr5o5x8v81C/rustc_testrunner_tmpdir_reporting.LjFuOhg1b1UO/mvce.rs:5:9
  |
5 |     let closure = async || {
  |         ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_closure`
  |
  = note: `#[warn(unused_variables)]` on by default

thread 'rustc' panicked at compiler/rustc_smir/src/rustc_smir/convert/mir.rs:569:17:
not yet implemented: FIXME(async_closures): Lower these to SMIR
stack backtrace:
   0:     0x728a3016887a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::ha7f0c0a9782d7e72
   1:     0x728a30813ba6 - core::fmt::write::h349a90590cd44cc2
   2:     0x728a317c5e51 - std::io::Write::write_fmt::hb75740cea2350d81
   3:     0x728a301686d2 - std::sys::backtrace::BacktraceLock::print::hbaa671e034187daa
   4:     0x728a3016abea - std::panicking::default_hook::{{closure}}::he5b32cfe851d3684
   5:     0x728a3016aa33 - std::panicking::default_hook::hfb25fc6fe8d3f7df
   6:     0x728a2f2cb5c8 - std[4908e3f2635a52b0]::panicking::update_hook::<alloc[d0f40dee7a07bc41]::boxed::Box<rustc_driver_impl[da799d46c754177c]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x728a3016b3a8 - std::panicking::rust_panic_with_hook::had4ab0340b9595a9
   8:     0x728a3016b066 - std::panicking::begin_panic_handler::{{closure}}::hfe00e9533ed00ed0
   9:     0x728a30168d19 - std::sys::backtrace::__rust_end_short_backtrace::h15687a7da048e988
  10:     0x728a3016ad5d - rust_begin_unwind
  11:     0x728a2cdb9920 - core::panicking::panic_fmt::h67b4e51ad0c096d3
  12:     0x728a2fe2d8a6 - <rustc_middle[925dc401787dd4f]::mir::syntax::AggregateKind as rustc_smir[2e64afc0fcf6e61f]::rustc_smir::Stable>::stable
  13:     0x728a2fe2c737 - <rustc_middle[925dc401787dd4f]::mir::syntax::Rvalue as rustc_smir[2e64afc0fcf6e61f]::rustc_smir::Stable>::stable
  14:     0x728a2fe2c51e - <rustc_middle[925dc401787dd4f]::mir::syntax::StatementKind as rustc_smir[2e64afc0fcf6e61f]::rustc_smir::Stable>::stable
  15:     0x728a2fe2ba58 - <rustc_middle[925dc401787dd4f]::mir::Body as rustc_smir[2e64afc0fcf6e61f]::rustc_smir::Stable>::stable
  16:     0x728a2fe20d57 - <rustc_smir[2e64afc0fcf6e61f]::rustc_smir::context::TablesWrapper as stable_mir[6ff77d18324bc8e5]::compiler_interface::Context>::mir_body
  17:     0x728a3012846c - <stable_mir[6ff77d18324bc8e5]::CrateItem>::body
  18:     0x728a2f2e8ee9 - rustc_driver_impl[da799d46c754177c]::pretty::print
  19:     0x728a31832a38 - rustc_interface[56d312c05374fed]::interface::run_compiler::<(), rustc_driver_impl[da799d46c754177c]::run_compiler::{closure#0}>::{closure#1}
  20:     0x728a3171c387 - std[4908e3f2635a52b0]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[56d312c05374fed]::util::run_in_thread_with_globals<rustc_interface[56d312c05374fed]::util::run_in_thread_pool_with_globals<rustc_interface[56d312c05374fed]::interface::run_compiler<(), rustc_driver_impl[da799d46c754177c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  21:     0x728a3171c822 - <<std[4908e3f2635a52b0]::thread::Builder>::spawn_unchecked_<rustc_interface[56d312c05374fed]::util::run_in_thread_with_globals<rustc_interface[56d312c05374fed]::util::run_in_thread_pool_with_globals<rustc_interface[56d312c05374fed]::interface::run_compiler<(), rustc_driver_impl[da799d46c754177c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[94282094966b97bc]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  22:     0x728a3171ddef - std::sys::pal::unix::thread::Thread::new::thread_start::h138d3ae6a4291935
  23:     0x728a2baa339d - <unknown>
  24:     0x728a2bb2849c - <unknown>
  25:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.85.0-nightly (f4f0fafd0 2024-12-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unpretty=stable-mir -Z dump-mir-dir=dir

query stack during panic:
end of query stack
warning: 1 warning emitted


@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 13, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 13, 2024
@matthiaskrgr matthiaskrgr added A-async-closures `async || {}` A-stable-MIR Area: stable MIR and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 13, 2024
@lqd
Copy link
Member

lqd commented Dec 13, 2024

There's already a fixme, do we also need an issue 😂 ?

@matthiaskrgr
Copy link
Member Author

async closures have been stabilised now, I suspect that this should have been fixed before stabilisation?

@krtab
Copy link
Contributor

krtab commented Dec 13, 2024

$ rustc +nightly mre.rs --edition=2018  -Zunpretty=stable-mir
error[E0658]: async closures are unstable
 --> mre.rs:5:19
  |
5 |     let closure = async || {
  |                   ^^^^^
  |
  = note: see issue #62290 <https://github.com/rust-lang/rust/issues/62290> for more information
  = help: add `#![feature(async_closure)]` to the crate attributes to enable
  = note: this compiler was built on 2024-12-12; consider upgrading it if it is out of date
  = help: to use an async block, remove the `||`: `async {`

I don't think they are @matthiaskrgr

@matthiaskrgr
Copy link
Member Author

I think they are :) #132706 (comment)

@krtab
Copy link
Contributor

krtab commented Dec 13, 2024

Damn, I thought it could have been stabilized since last nightly but didn't find the PR. My bad. :)

@matthiaskrgr
Copy link
Member Author

afaik there are tools (such as kani) who use stable-mir to perform analysis on crates and these will probably just ICE on any kind of stable async closure code.

@lqd
Copy link
Member

lqd commented Dec 13, 2024

We can remove the todo if you want, but stable mir is, amusingly, not stable anyways.

@compiler-errors compiler-errors self-assigned this Dec 13, 2024
@bors bors closed this as completed in b0597b4 Dec 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 14, 2024
Rollup merge of rust-lang#134295 - compiler-errors:smir-async-closure, r=oli-obk

Encode coroutine-closures in SMIR

Fixes rust-lang#134246

r? oli-obk
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-async-closures `async || {}` A-stable-MIR Area: stable MIR C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants