Skip to content
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

ICE Unsize coercion, but Box<{async block@file.rs}> isn't coercible to Box<dyn Send> #137916

Open
matthiaskrgr opened this issue Mar 3, 2025 · 2 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

similar to #131886 but does neither requires nightly features nor unstable flags so it repros on stable

auto-reduced (treereduce-rust):

async fn make_boxed_object() -> Box<dyn Send> {
    Box::new(async {
        use std::ptr::null;
        use std::task::{Context, RawWaker, RawWakerVTable, Waker};
        let waker = unsafe {
            Waker::from_raw(RawWaker::new(
                null(),
                &RawWakerVTable::new(|_| todo!(), |_| todo!(), |_| todo!(), |_| todo!()),
            ))
        };
        let mut cx = Context::from_waker(&waker);
        let cx_ref = &mut cx;

        async {}.await;
    }) as _
}

fn main() {}

original:

//@ check-pass
//@ edition:2018

async fn make_boxed_object() -> Box<dyn Send> {
    Box::new(async {
        //~^ ERROR the type `&mut Context<'_>` may not be safely transferred across an unwind boundary
        use std::ptr::null;
        use std::task::{Context, RawWaker, RawWakerVTable, Waker};
        let waker = unsafe {
            Waker::from_raw(RawWaker::new(
                null(),
                &RawWakerVTable::new(|_| todo!(), |_| todo!(), |_| todo!(), |_| todo!()),
            ))
        };
        let mut cx = Context::from_waker(&waker);
        let cx_ref = &mut cx;

        async {}.await; // this needs an inner await point

        // in this case, `&mut Context<'_>` is *truly* alive across an await point
        drop(cx_ref);
    }) as _
}

async fn await_object() {
    let _ = make_boxed_object().await;
}

fn main() {}

Version information

rustc 1.87.0-nightly (daf59857d 2025-03-02)
binary: rustc
commit-hash: daf59857d6d2b87af4b846316bf1561a6083ed51
commit-date: 2025-03-02
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

};
cfg_checker.visit_body(body);
cfg_checker.check_cleanup_control_flow();
// Also run the TypeChecker.
for (location, msg) in validate_types(tcx, typing_env, body, body) {
cfg_checker.fail(location, msg);
}
if let MirPhase::Runtime(_) = body.phase {
if let ty::InstanceKind::Item(_) = body.source.instance {
if body.has_free_regions() {
cfg_checker.fail(

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2021

Program output

warning: unused variable: `cx_ref`
  --> /tmp/icemaker_global_tempdir.kJPdp5n7Kc00/rustc_testrunner_tmpdir_reporting.icgqtdez9sgM/mvce.rs:12:13
   |
12 |         let cx_ref = &mut cx;
   |             ^^^^^^ help: if this is intentional, prefix it with an underscore: `_cx_ref`
   |
   = note: `#[warn(unused_variables)]` on by default


thread 'rustc' panicked at compiler/rustc_mir_transform/src/validate.rs:80:25:
broken MIR in Item(DefId(0:5 ~ mvce[3886]::make_boxed_object::{closure#0})) (after pass CheckForceInline) at bb1[0]:
Unsize coercion, but `Box<{async block@/tmp/icemaker_global_tempdir.kJPdp5n7Kc00/rustc_testrunner_tmpdir_reporting.icgqtdez9sgM/mvce.rs:2:14: 2:19}>` isn't coercible to `Box<dyn Send>`
stack backtrace:
   0:     0x77b8e55bf6c4 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6b1eafa1cb504ab9
   1:     0x77b8e5e05962 - core::fmt::write::hd2b5ae547d619578
   2:     0x77b8e6dfecd1 - std::io::Write::write_fmt::h64441ab3eb911d07
   3:     0x77b8e55bf522 - std::sys::backtrace::BacktraceLock::print::hd6c03e255788ee13
   4:     0x77b8e55c1e02 - std::panicking::default_hook::{{closure}}::hd6ed0ceea16b0de8
   5:     0x77b8e55c19f4 - std::panicking::default_hook::hef47b683be262852
   6:     0x77b8e4719237 - std[969d9c414e68e03]::panicking::update_hook::<alloc[6b1944e8889fcf9b]::boxed::Box<rustc_driver_impl[4f721a00788e3e3f]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x77b8e55c2673 - std::panicking::rust_panic_with_hook::h981e3034017b01a5
   8:     0x77b8e55c236a - std::panicking::begin_panic_handler::{{closure}}::hcf9ab7a92831e898
   9:     0x77b8e55bfb89 - std::sys::backtrace::__rust_end_short_backtrace::h0d9b6b7623c92776
  10:     0x77b8e55c202d - rust_begin_unwind
  11:     0x77b8e225bb40 - core::panicking::panic_fmt::hc5a7c8213b3d8ae4
  12:     0x77b8e32d8c22 - <rustc_mir_transform[eac3e55bb37b9c3b]::validate::CfgChecker>::fail::<alloc[6b1944e8889fcf9b]::string::String>
  13:     0x77b8e6841a1d - <rustc_mir_transform[eac3e55bb37b9c3b]::validate::Validator as rustc_mir_transform[eac3e55bb37b9c3b]::pass_manager::MirPass>::run_pass
  14:     0x77b8e3ffeb75 - rustc_mir_transform[eac3e55bb37b9c3b]::pass_manager::validate_body
  15:     0x77b8e5e09d96 - rustc_mir_transform[eac3e55bb37b9c3b]::mir_built
  16:     0x77b8e5e09887 - rustc_query_impl[617123c76a282bfb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[617123c76a282bfb]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>>
  17:     0x77b8e6338a45 - rustc_query_system[3a926c6520d9a1f8]::query::plumbing::try_execute_query::<rustc_query_impl[617123c76a282bfb]::DynamicConfig<rustc_data_structures[11a43b82be93f2a1]::vec_cache::VecCache<rustc_span[62f958c79fb27cc8]::def_id::LocalDefId, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[3a926c6520d9a1f8]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[617123c76a282bfb]::plumbing::QueryCtxt, true>
  18:     0x77b8e62cbd09 - rustc_query_impl[617123c76a282bfb]::query_impl::mir_built::get_query_incr::__rust_end_short_backtrace
  19:     0x77b8e5e9fd73 - rustc_mir_transform[eac3e55bb37b9c3b]::ffi_unwind_calls::has_ffi_unwind_calls
  20:     0x77b8e5e9f759 - rustc_query_impl[617123c76a282bfb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[617123c76a282bfb]::query_impl::has_ffi_unwind_calls::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 1usize]>>
  21:     0x77b8e62c772a - rustc_query_system[3a926c6520d9a1f8]::query::plumbing::try_execute_query::<rustc_query_impl[617123c76a282bfb]::DynamicConfig<rustc_data_structures[11a43b82be93f2a1]::vec_cache::VecCache<rustc_span[62f958c79fb27cc8]::def_id::LocalDefId, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[3a926c6520d9a1f8]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[617123c76a282bfb]::plumbing::QueryCtxt, true>
  22:     0x77b8e62cc074 - rustc_query_impl[617123c76a282bfb]::query_impl::has_ffi_unwind_calls::get_query_incr::__rust_end_short_backtrace
  23:     0x77b8e33c9b00 - rustc_mir_transform[eac3e55bb37b9c3b]::mir_promoted
  24:     0x77b8e645c1d2 - rustc_query_impl[617123c76a282bfb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[617123c76a282bfb]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 16usize]>>
  25:     0x77b8e5f2a724 - rustc_query_system[3a926c6520d9a1f8]::query::plumbing::try_execute_query::<rustc_query_impl[617123c76a282bfb]::DynamicConfig<rustc_data_structures[11a43b82be93f2a1]::vec_cache::VecCache<rustc_span[62f958c79fb27cc8]::def_id::LocalDefId, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 16usize]>, rustc_query_system[3a926c6520d9a1f8]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[617123c76a282bfb]::plumbing::QueryCtxt, true>
  26:     0x77b8e5f29d78 - rustc_query_impl[617123c76a282bfb]::query_impl::mir_promoted::get_query_incr::__rust_end_short_backtrace
  27:     0x77b8e6f5c86c - rustc_query_impl[617123c76a282bfb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[617123c76a282bfb]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>>
  28:     0x77b8e6338a45 - rustc_query_system[3a926c6520d9a1f8]::query::plumbing::try_execute_query::<rustc_query_impl[617123c76a282bfb]::DynamicConfig<rustc_data_structures[11a43b82be93f2a1]::vec_cache::VecCache<rustc_span[62f958c79fb27cc8]::def_id::LocalDefId, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[3a926c6520d9a1f8]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[617123c76a282bfb]::plumbing::QueryCtxt, true>
  29:     0x77b8e63300f6 - rustc_query_impl[617123c76a282bfb]::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
  30:     0x77b8e6979a4a - rustc_middle[1a629eb863abba3a]::query::plumbing::query_get_at::<rustc_data_structures[11a43b82be93f2a1]::vec_cache::VecCache<rustc_span[62f958c79fb27cc8]::def_id::LocalDefId, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[3a926c6520d9a1f8]::dep_graph::graph::DepNodeIndex>>
  31:     0x77b8e6979aac - <rustc_borrowck[7c4fa524092d0c26]::type_check::TypeChecker>::prove_closure_bounds
  32:     0x77b8e623a1f4 - <rustc_borrowck[7c4fa524092d0c26]::type_check::TypeChecker>::typeck_mir
  33:     0x77b8e2d89d63 - rustc_borrowck[7c4fa524092d0c26]::type_check::type_check
  34:     0x77b8e2d9e894 - rustc_borrowck[7c4fa524092d0c26]::nll::compute_regions
  35:     0x77b8e6f69147 - rustc_borrowck[7c4fa524092d0c26]::do_mir_borrowck
  36:     0x77b8e6f5c76c - rustc_query_impl[617123c76a282bfb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[617123c76a282bfb]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>>
  37:     0x77b8e6338a45 - rustc_query_system[3a926c6520d9a1f8]::query::plumbing::try_execute_query::<rustc_query_impl[617123c76a282bfb]::DynamicConfig<rustc_data_structures[11a43b82be93f2a1]::vec_cache::VecCache<rustc_span[62f958c79fb27cc8]::def_id::LocalDefId, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[3a926c6520d9a1f8]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[617123c76a282bfb]::plumbing::QueryCtxt, true>
  38:     0x77b8e63300f6 - rustc_query_impl[617123c76a282bfb]::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
  39:     0x77b8e665d214 - rustc_middle[1a629eb863abba3a]::query::plumbing::query_get_at::<rustc_data_structures[11a43b82be93f2a1]::vec_cache::VecCache<rustc_span[62f958c79fb27cc8]::def_id::LocalDefId, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[3a926c6520d9a1f8]::dep_graph::graph::DepNodeIndex>>
  40:     0x77b8e6e4310f - rustc_hir_analysis[f376d447bc4b2c49]::collect::type_of::type_of_opaque
  41:     0x77b8e6e42f69 - rustc_query_impl[617123c76a282bfb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[617123c76a282bfb]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>>
  42:     0x77b8e62d0669 - rustc_query_system[3a926c6520d9a1f8]::query::plumbing::try_execute_query::<rustc_query_impl[617123c76a282bfb]::DynamicConfig<rustc_query_system[3a926c6520d9a1f8]::query::caches::DefIdCache<rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[617123c76a282bfb]::plumbing::QueryCtxt, true>
  43:     0x77b8e708c187 - rustc_query_impl[617123c76a282bfb]::query_impl::type_of_opaque::get_query_incr::__rust_end_short_backtrace
  44:     0x77b8e658c2d8 - rustc_middle[1a629eb863abba3a]::query::plumbing::query_get_at::<rustc_query_system[3a926c6520d9a1f8]::query::caches::DefIdCache<rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>>>
  45:     0x77b8e6657fac - rustc_hir_analysis[f376d447bc4b2c49]::collect::type_of::type_of
  46:     0x77b8e60f6caa - rustc_query_impl[617123c76a282bfb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[617123c76a282bfb]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>>
  47:     0x77b8e62d0669 - rustc_query_system[3a926c6520d9a1f8]::query::plumbing::try_execute_query::<rustc_query_impl[617123c76a282bfb]::DynamicConfig<rustc_query_system[3a926c6520d9a1f8]::query::caches::DefIdCache<rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[617123c76a282bfb]::plumbing::QueryCtxt, true>
  48:     0x77b8e62cdd20 - rustc_query_impl[617123c76a282bfb]::query_impl::type_of::get_query_incr::__rust_end_short_backtrace
  49:     0x77b8e658c2d8 - rustc_middle[1a629eb863abba3a]::query::plumbing::query_get_at::<rustc_query_system[3a926c6520d9a1f8]::query::caches::DefIdCache<rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 8usize]>>>
  50:     0x77b8e66d9aec - rustc_hir_analysis[f376d447bc4b2c49]::check::check::check_item_type
  51:     0x77b8e65aa4bf - rustc_hir_analysis[f376d447bc4b2c49]::check::wfcheck::check_well_formed
  52:     0x77b8e65a7acd - rustc_query_impl[617123c76a282bfb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[617123c76a282bfb]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 1usize]>>
  53:     0x77b8e62c7ae1 - rustc_query_system[3a926c6520d9a1f8]::query::plumbing::try_execute_query::<rustc_query_impl[617123c76a282bfb]::DynamicConfig<rustc_data_structures[11a43b82be93f2a1]::vec_cache::VecCache<rustc_span[62f958c79fb27cc8]::def_id::LocalDefId, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[3a926c6520d9a1f8]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[617123c76a282bfb]::plumbing::QueryCtxt, true>
  54:     0x77b8e62cc2fc - rustc_query_impl[617123c76a282bfb]::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
  55:     0x77b8e65a4bc7 - rustc_hir_analysis[f376d447bc4b2c49]::check::wfcheck::check_mod_type_wf
  56:     0x77b8e65a465f - rustc_query_impl[617123c76a282bfb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[617123c76a282bfb]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 1usize]>>
  57:     0x77b8e6d3ab60 - rustc_query_system[3a926c6520d9a1f8]::query::plumbing::try_execute_query::<rustc_query_impl[617123c76a282bfb]::DynamicConfig<rustc_query_system[3a926c6520d9a1f8]::query::caches::DefaultCache<rustc_span[62f958c79fb27cc8]::def_id::LocalModDefId, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[617123c76a282bfb]::plumbing::QueryCtxt, true>
  58:     0x77b8e6d3b5bb - rustc_query_impl[617123c76a282bfb]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
  59:     0x77b8e633404f - rustc_hir_analysis[f376d447bc4b2c49]::check_crate
  60:     0x77b8e632dd5c - rustc_interface[e45bfa9538a3ca98]::passes::run_required_analyses
  61:     0x77b8e6dfac7a - rustc_interface[e45bfa9538a3ca98]::passes::analysis
  62:     0x77b8e6dfac59 - rustc_query_impl[617123c76a282bfb]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[617123c76a282bfb]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 0usize]>>
  63:     0x77b8e6df652a - rustc_query_system[3a926c6520d9a1f8]::query::plumbing::try_execute_query::<rustc_query_impl[617123c76a282bfb]::DynamicConfig<rustc_query_system[3a926c6520d9a1f8]::query::caches::SingleCache<rustc_middle[1a629eb863abba3a]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[617123c76a282bfb]::plumbing::QueryCtxt, true>
  64:     0x77b8e6df5f22 - rustc_query_impl[617123c76a282bfb]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  65:     0x77b8e6f2be7d - rustc_interface[e45bfa9538a3ca98]::passes::create_and_enter_global_ctxt::<core[ba0aad2f8409bf78]::option::Option<rustc_interface[e45bfa9538a3ca98]::queries::Linker>, rustc_driver_impl[4f721a00788e3e3f]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  66:     0x77b8e6ea5820 - rustc_interface[e45bfa9538a3ca98]::interface::run_compiler::<(), rustc_driver_impl[4f721a00788e3e3f]::run_compiler::{closure#0}>::{closure#1}
  67:     0x77b8e6d0f888 - std[969d9c414e68e03]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e45bfa9538a3ca98]::util::run_in_thread_with_globals<rustc_interface[e45bfa9538a3ca98]::util::run_in_thread_pool_with_globals<rustc_interface[e45bfa9538a3ca98]::interface::run_compiler<(), rustc_driver_impl[4f721a00788e3e3f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  68:     0x77b8e6d10174 - <<std[969d9c414e68e03]::thread::Builder>::spawn_unchecked_<rustc_interface[e45bfa9538a3ca98]::util::run_in_thread_with_globals<rustc_interface[e45bfa9538a3ca98]::util::run_in_thread_pool_with_globals<rustc_interface[e45bfa9538a3ca98]::interface::run_compiler<(), rustc_driver_impl[4f721a00788e3e3f]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[ba0aad2f8409bf78]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  69:     0x77b8e6d11577 - std::sys::pal::unix::thread::Thread::new::thread_start::hac8dde90d17af74a
  70:     0x77b8e0ea370a - <unknown>
  71:     0x77b8e0f27aac - <unknown>
  72:                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.87.0-nightly (daf59857d 2025-03-02) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2 -C link-dead-code=true -Z validate-mir

query stack during panic:
#0 [mir_built] building MIR for `make_boxed_object::{closure#0}`
#1 [has_ffi_unwind_calls] checking if `make_boxed_object::{closure#0}` contains FFI-unwind calls
#2 [mir_promoted] promoting constants in MIR for `make_boxed_object::{closure#0}`
#3 [mir_borrowck] borrow-checking `make_boxed_object::{closure#0}`
#4 [mir_borrowck] borrow-checking `make_boxed_object`
#5 [type_of_opaque] computing type of opaque `make_boxed_object::{opaque#0}`
#6 [type_of] computing type of `make_boxed_object::{opaque#0}`
#7 [check_well_formed] checking that `make_boxed_object::{opaque#0}` is well-formed
#8 [check_mod_type_wf] checking that types are well-formed in top-level module
#9 [analysis] running analysis passes on this crate
end of query stack
warning: 1 warning emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: {OpaqueTypeKey { def_id: DefId(0:4 ~ mvce[3886]::make_boxed_object::{opaque#0}), args: [] }: OpaqueHiddenType { span: /tmp/icemaker_global_tempdir.kJPdp5n7Kc00/rustc_testrunner_tmpdir_reporting.icgqtdez9sgM/mvce.rs:1:47: 16:2 (#0), ty: Coroutine(DefId(0:5 ~ mvce[3886]::make_boxed_object::{closure#0}), [(), std::future::ResumeTy, (), std::boxed::Box<dyn [Binder { value: AutoTrait(DefId(2:37501 ~ core[ba0a]::marker::Send)), bound_vars: [] }] + '?2, std::alloc::Global>, CoroutineWitness(DefId(0:5 ~ mvce[3886]::make_boxed_object::{closure#0}), []), ()]) }}
  |
  = note: delayed at compiler/rustc_infer/src/infer/opaque_types/table.rs:48:43
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
             2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
             3: <rustc_errors::DiagCtxtHandle>::delayed_bug::<alloc::string::String>
             4: core::ptr::drop_in_place::<rustc_infer::infer::InferCtxt>
             5: core::ptr::drop_in_place::<rustc_borrowck::BorrowckInferCtxt>
             6: rustc_borrowck::do_mir_borrowck
             7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
             8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
             9: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
            10: rustc_middle::query::plumbing::query_get_at::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>>
            11: rustc_hir_analysis::collect::type_of::type_of_opaque
            12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            14: rustc_query_impl::query_impl::type_of_opaque::get_query_incr::__rust_end_short_backtrace
            15: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
            16: rustc_hir_analysis::collect::type_of::type_of
            17: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
            18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            19: rustc_query_impl::query_impl::type_of::get_query_incr::__rust_end_short_backtrace
            20: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>>
            21: rustc_hir_analysis::check::check::check_item_type
            22: rustc_hir_analysis::check::wfcheck::check_well_formed
            23: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            24: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            25: rustc_query_impl::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
            26: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
            27: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            28: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            29: rustc_query_impl::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
            30: rustc_hir_analysis::check_crate
            31: rustc_interface::passes::run_required_analyses
            32: rustc_interface::passes::analysis
            33: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
            34: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
            35: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
            36: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
            37: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
            38: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
            39: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            40: std::sys::pal::unix::thread::Thread::new::thread_start
            41: <unknown>
            42: <unknown>
          

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.87.0-nightly (daf59857d 2025-03-02) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2 -C link-dead-code=true -Z validate-mir

query stack during panic:
end of query stack

@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 Mar 3, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 3, 2025
@matthiaskrgr
Copy link
Member Author

use std::ptr::null;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};

async fn a() -> Box<dyn Send> {
    Box::new(async {
        let b = unsafe {
            Waker::from_raw(RawWaker::new(
                null(),
                &RawWakerVTable::new(|_| todo!(), |_| (), |_| (), |_| ()),
            ))
        };
        let cx = Context::from_waker(&b);
        &cx;
        async {}.await
    })
}
fn main() {}

@cyrgani
Copy link
Contributor

cyrgani commented Mar 3, 2025

use std::ptr::null;

async fn a() -> Box<dyn Send> {
    Box::new(async {
        let non_send = null::<()>();
        &non_send;
        async {}.await
    })
}

fn main() {}

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants