Giter VIP home page Giter VIP logo

Comments (4)

facundo-villa avatar facundo-villa commented on August 16, 2024

It can also be triggered like this.

#![feature(async_closure)]

use futures::future::join_all;

async fn fun<'a>(param: &'a u32) {
	let _ = join_all((0..3).map(async |_| {
		format!("{}", param)
	})).await;
}

fn main() {
	futures::executor::block_on(fun(&1));
}

from rust.

theemathas avatar theemathas commented on August 16, 2024

Minimized:

#![feature(async_closure)]

// Only Fn and FnMut cause an ICE. FnOnce doesn't.
fn call<T>(mut f: impl FnMut() -> T) {
    f();  // Discard the returned future. No await needed for ICE.
}

fn main() {
    let x = 1_i32;
    call(async || x);
}
Error output
   Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at compiler/rustc_mir_transform/src/shim.rs:1036:9:
assertion `left == right` failed
  left: (&'{erased} i32,)
 right: ()
stack backtrace:
   0:     0x7f8dd091b515 - std::backtrace_rs::backtrace::libunwind::trace::h3e6ef95ba444c071
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7f8dd091b515 - std::backtrace_rs::backtrace::trace_unsynchronized::hf308e5cf23ddb1f2
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8dd091b515 - std::sys::backtrace::_print_fmt::h875f055a8443612e
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/sys/backtrace.rs:68:5
   3:     0x7f8dd091b515 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf048241184006193
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/sys/backtrace.rs:44:22
   4:     0x7f8dd096ae7b - core::fmt::rt::Argument::fmt::hbfa8b610cdf08154
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/core/src/fmt/rt.rs:165:63
   5:     0x7f8dd096ae7b - core::fmt::write::h38ac925a86684a19
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/core/src/fmt/mod.rs:1168:21
   6:     0x7f8dd09100bf - std::io::Write::write_fmt::h8e14b1bbba4ad770
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/io/mod.rs:1835:15
   7:     0x7f8dd091b2ee - std::sys::backtrace::_print::heb4ac079ec90a68e
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/sys/backtrace.rs:47:5
   8:     0x7f8dd091b2ee - std::sys::backtrace::print::ha33f33bac52a4063
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/sys/backtrace.rs:34:9
   9:     0x7f8dd091dc39 - std::panicking::default_hook::{{closure}}::h2144f34920a14974
  10:     0x7f8dd091d9dc - std::panicking::default_hook::h18933871d80cdc21
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/panicking.rs:292:9
  11:     0x7f8dd3d6f4a0 - std[20db51b4dc66b481]::panicking::update_hook::<alloc[7a9d83151868560e]::boxed::Box<rustc_driver_impl[42aec5b3602e6800]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f8dd091e50f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1cfdd0f28ef5545b
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/alloc/src/boxed.rs:2078:9
  13:     0x7f8dd091e50f - std::panicking::rust_panic_with_hook::h4ad51c0c6b25b444
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/panicking.rs:804:13
  14:     0x7f8dd091e137 - std::panicking::begin_panic_handler::{{closure}}::h3425c28d75ee8072
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/panicking.rs:670:13
  15:     0x7f8dd091b9d9 - std::sys::backtrace::__rust_end_short_backtrace::h1e8092621577272d
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/sys/backtrace.rs:171:18
  16:     0x7f8dd091de14 - rust_begin_unwind
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/panicking.rs:661:5
  17:     0x7f8dd0967433 - core::panicking::panic_fmt::hee696384dfa25c0c
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/core/src/panicking.rs:74:14
  18:     0x7f8dd096793e - core::panicking::assert_failed_inner::hbe69f7ee81ff4d1a
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/core/src/panicking.rs:410:17
  19:     0x7f8dd44b0a03 - core[fd5e850c33eb6236]::panicking::assert_failed::<rustc_middle[b588a4788bcf8236]::ty::Ty, rustc_middle[b588a4788bcf8236]::ty::Ty>
  20:     0x7f8dd5ea2aab - rustc_mir_transform[fdf71a3a69b9138a]::shim::make_shim
  21:     0x7f8dd5e9f8ef - rustc_query_impl[33da1f1d673ac58e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[33da1f1d673ac58e]::query_impl::mir_shims::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b588a4788bcf8236]::query::erase::Erased<[u8; 8usize]>>
  22:     0x7f8dd5e9f8b9 - <rustc_query_impl[33da1f1d673ac58e]::query_impl::mir_shims::dynamic_query::{closure#2} as core[fd5e850c33eb6236]::ops::function::FnOnce<(rustc_middle[b588a4788bcf8236]::ty::context::TyCtxt, rustc_middle[b588a4788bcf8236]::ty::instance::InstanceKind)>>::call_once
  23:     0x7f8dd56d4e4f - rustc_query_system[32abc7d9028ee329]::query::plumbing::try_execute_query::<rustc_query_impl[33da1f1d673ac58e]::DynamicConfig<rustc_query_system[32abc7d9028ee329]::query::caches::DefaultCache<rustc_middle[b588a4788bcf8236]::ty::instance::InstanceKind, rustc_middle[b588a4788bcf8236]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[33da1f1d673ac58e]::plumbing::QueryCtxt, false>
  24:     0x7f8dd56d4bb9 - rustc_query_impl[33da1f1d673ac58e]::query_impl::mir_shims::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7f8dd5b9780d - <rustc_middle[b588a4788bcf8236]::ty::context::TyCtxt>::instance_mir
  26:     0x7f8dd6210e9a - rustc_monomorphize[12e0af1616a24b7e]::collector::collect_items_rec::{closure#0}
  27:     0x7f8dd546d9af - rustc_monomorphize[12e0af1616a24b7e]::collector::collect_items_rec
  28:     0x7f8dd546e12c - rustc_monomorphize[12e0af1616a24b7e]::collector::collect_items_rec
  29:     0x7f8dd546e12c - rustc_monomorphize[12e0af1616a24b7e]::collector::collect_items_rec
  30:     0x7f8dd56530ad - rustc_monomorphize[12e0af1616a24b7e]::partitioning::collect_and_partition_mono_items
  31:     0x7f8dd61fa664 - rustc_query_impl[33da1f1d673ac58e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[33da1f1d673ac58e]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b588a4788bcf8236]::query::erase::Erased<[u8; 24usize]>>
  32:     0x7f8dd61fa649 - <rustc_query_impl[33da1f1d673ac58e]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[fd5e850c33eb6236]::ops::function::FnOnce<(rustc_middle[b588a4788bcf8236]::ty::context::TyCtxt, ())>>::call_once
  33:     0x7f8dd61fa208 - rustc_query_system[32abc7d9028ee329]::query::plumbing::try_execute_query::<rustc_query_impl[33da1f1d673ac58e]::DynamicConfig<rustc_query_system[32abc7d9028ee329]::query::caches::SingleCache<rustc_middle[b588a4788bcf8236]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[33da1f1d673ac58e]::plumbing::QueryCtxt, false>
  34:     0x7f8dd61f9f21 - rustc_query_impl[33da1f1d673ac58e]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f8dd631172f - <rustc_codegen_llvm[f77607e41541149f]::LlvmCodegenBackend as rustc_codegen_ssa[a768f5e0bba2f7a]::traits::backend::CodegenBackend>::codegen_crate
  36:     0x7f8dd6297a45 - rustc_interface[d19dc351f3fbc095]::passes::start_codegen
  37:     0x7f8dd62970da - <rustc_interface[d19dc351f3fbc095]::queries::Queries>::codegen_and_build_linker
  38:     0x7f8dd61269c2 - rustc_interface[d19dc351f3fbc095]::interface::run_compiler::<core[fd5e850c33eb6236]::result::Result<(), rustc_span[f8da6251a5b957ab]::ErrorGuaranteed>, rustc_driver_impl[42aec5b3602e6800]::run_compiler::{closure#0}>::{closure#1}
  39:     0x7f8dd6074d89 - std[20db51b4dc66b481]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d19dc351f3fbc095]::util::run_in_thread_with_globals<rustc_interface[d19dc351f3fbc095]::util::run_in_thread_pool_with_globals<rustc_interface[d19dc351f3fbc095]::interface::run_compiler<core[fd5e850c33eb6236]::result::Result<(), rustc_span[f8da6251a5b957ab]::ErrorGuaranteed>, rustc_driver_impl[42aec5b3602e6800]::run_compiler::{closure#0}>::{closure#1}, core[fd5e850c33eb6236]::result::Result<(), rustc_span[f8da6251a5b957ab]::ErrorGuaranteed>>::{closure#0}, core[fd5e850c33eb6236]::result::Result<(), rustc_span[f8da6251a5b957ab]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[fd5e850c33eb6236]::result::Result<(), rustc_span[f8da6251a5b957ab]::ErrorGuaranteed>>
  40:     0x7f8dd6074b3a - <<std[20db51b4dc66b481]::thread::Builder>::spawn_unchecked_<rustc_interface[d19dc351f3fbc095]::util::run_in_thread_with_globals<rustc_interface[d19dc351f3fbc095]::util::run_in_thread_pool_with_globals<rustc_interface[d19dc351f3fbc095]::interface::run_compiler<core[fd5e850c33eb6236]::result::Result<(), rustc_span[f8da6251a5b957ab]::ErrorGuaranteed>, rustc_driver_impl[42aec5b3602e6800]::run_compiler::{closure#0}>::{closure#1}, core[fd5e850c33eb6236]::result::Result<(), rustc_span[f8da6251a5b957ab]::ErrorGuaranteed>>::{closure#0}, core[fd5e850c33eb6236]::result::Result<(), rustc_span[f8da6251a5b957ab]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[fd5e850c33eb6236]::result::Result<(), rustc_span[f8da6251a5b957ab]::ErrorGuaranteed>>::{closure#2} as core[fd5e850c33eb6236]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7f8dd092839b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h94ad910a99affeba
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/alloc/src/boxed.rs:2064:9
  42:     0x7f8dd092839b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he514aef6ea70403a
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/alloc/src/boxed.rs:2064:9
  43:     0x7f8dd092839b - std::sys::pal::unix::thread::Thread::new::thread_start::hf130b2754bc7a5a1
                               at /rustc/6b0f4b5ec3aa707ecaa78230722117324a4ce23c/library/std/src/sys/pal/unix/thread.rs:108:17
  44:     0x7f8dd0832609 - start_thread
  45:     0x7f8dd0755353 - clone
  46:                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: please attach the file at `/playground/rustc-ice-2024-06-27T04_35_35-936.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_shims] generating MIR shim for `main::{closure#0}`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `playground` (bin "playground")

from rust.

theemathas avatar theemathas commented on August 16, 2024

Note: In the original code, changing async |v: &u32| { to |v: &u32| async move { causes the code to compile.

from rust.

GrigorenkoPV avatar GrigorenkoPV commented on August 16, 2024

Minimized:

#![feature(async_closure)]

// Only Fn and FnMut cause an ICE. FnOnce doesn't.
fn call<T>(mut f: impl FnMut() -> T) {
    f();  // Discard the returned future. No await needed for ICE.
}

fn main() {
    let x = 1_i32;
    call(async || x);
}

Regression in #125259

from rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.