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: const: body_owned_by expr const .. has no associated body #125677

Closed
matthiaskrgr opened this issue May 28, 2024 · 0 comments · Fixed by #125711
Closed

ICE: const: body_owned_by expr const .. has no associated body #125677

matthiaskrgr opened this issue May 28, 2024 · 0 comments · Fixed by #125711
Assignees
Labels
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

auto-reduced (treereduce-rust):

fn main() {
    let _my_usize = const {
        let x: bool;
        while x {}
    };
}

original:

//@ check-pass

fn main() {
    let _my_usize = const {
    let x: bool;
    while x { } //~ ERROR E0381
};
}

Version information

rustc 1.80.0-nightly (7717a306b 2024-05-28)
binary: rustc
commit-hash: 7717a306b2678ba9ece19b723c76a6b3a89ba931
commit-date: 2024-05-28
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: internal compiler error: compiler/rustc_middle/src/hir/map/mod.rs:266:13: body_owned_by: HirId(DefId(0:3 ~ mvce[78f0]::main).2) (expr `const {
                                        let x: bool;
                                        while x {}
                                    }`) has no associated body
 --> /tmp/icemaker_global_tempdir.CEQyF9kduY4P/rustc_testrunner_tmpdir_reporting.Lxx11hj4irT2/mvce.rs:2:21
  |
2 |       let _my_usize = const {
  |  _____________________^
3 | |         let x: bool;
4 | |         while x {}
5 | |     };
  | |_____^

thread 'rustc' panicked at compiler/rustc_middle/src/hir/map/mod.rs:266:13:
Box<dyn Any>
stack backtrace:
   0:     0x777d9b0e1ae5 - std::backtrace_rs::backtrace::libunwind::trace::h8e3ec5065424d28b
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x777d9b0e1ae5 - std::backtrace_rs::backtrace::trace_unsynchronized::h882cf49e59475dbc
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x777d9b0e1ae5 - std::sys_common::backtrace::_print_fmt::h2c337a2c4b83dc01
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x777d9b0e1ae5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5fad958b7140a660
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x777d9b1325db - core::fmt::rt::Argument::fmt::h9f1efa968e340ff7
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/fmt/rt.rs:165:63
   5:     0x777d9b1325db - core::fmt::write::hc4341e028d4aa04e
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/fmt/mod.rs:1168:21
   6:     0x777d9b0d686f - std::io::Write::write_fmt::hf3dd4197197b5730
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/io/mod.rs:1835:15
   7:     0x777d9b0e18be - std::sys_common::backtrace::_print::hee589e8f95e333af
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x777d9b0e18be - std::sys_common::backtrace::print::hc6a85e053c1c7334
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x777d9b0e42e9 - std::panicking::default_hook::{{closure}}::he62a1676f96fee54
  10:     0x777d9b0e408a - std::panicking::default_hook::h2ceb904f12dea8be
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/panicking.rs:298:9
  11:     0x777d9798e6a0 - std[d6c1f98fb4e95ff7]::panicking::update_hook::<alloc[78b6f7e6bd40c475]::boxed::Box<rustc_driver_impl[c511ea10b869fcf7]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x777d9b0e4a1b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hc5b72f85a4688529
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/alloc/src/boxed.rs:2077:9
  13:     0x777d9b0e4a1b - std::panicking::rust_panic_with_hook::h0a690364d46daaac
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/panicking.rs:799:13
  14:     0x777d979be5b4 - std[d6c1f98fb4e95ff7]::panicking::begin_panic::<rustc_errors[1333b2f02324d7a1]::ExplicitBug>::{closure#0}
  15:     0x777d979bb1b6 - std[d6c1f98fb4e95ff7]::sys_common::backtrace::__rust_end_short_backtrace::<std[d6c1f98fb4e95ff7]::panicking::begin_panic<rustc_errors[1333b2f02324d7a1]::ExplicitBug>::{closure#0}, !>
  16:     0x777d979bae96 - std[d6c1f98fb4e95ff7]::panicking::begin_panic::<rustc_errors[1333b2f02324d7a1]::ExplicitBug>
  17:     0x777d979c7a31 - <rustc_errors[1333b2f02324d7a1]::diagnostic::BugAbort as rustc_errors[1333b2f02324d7a1]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x777d97e03a98 - <rustc_errors[1333b2f02324d7a1]::DiagCtxt>::span_bug::<rustc_span[8ae10af61471f323]::span_encoding::Span, alloc[78b6f7e6bd40c475]::string::String>
  19:     0x777d97ea694d - rustc_middle[b8101328ceeb956a]::util::bug::opt_span_bug_fmt::<rustc_span[8ae10af61471f323]::span_encoding::Span>::{closure#0}
  20:     0x777d97e8984a - rustc_middle[b8101328ceeb956a]::ty::context::tls::with_opt::<rustc_middle[b8101328ceeb956a]::util::bug::opt_span_bug_fmt<rustc_span[8ae10af61471f323]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x777d97e896cb - rustc_middle[b8101328ceeb956a]::ty::context::tls::with_context_opt::<rustc_middle[b8101328ceeb956a]::ty::context::tls::with_opt<rustc_middle[b8101328ceeb956a]::util::bug::opt_span_bug_fmt<rustc_span[8ae10af61471f323]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x777d95ed2f47 - rustc_middle[b8101328ceeb956a]::util::bug::span_bug_fmt::<rustc_span[8ae10af61471f323]::span_encoding::Span>
  23:     0x777d98fb1808 - <rustc_middle[b8101328ceeb956a]::hir::map::Map>::body_owned_by
  24:     0x777d9777440d - <rustc_borrowck[1e395e63e7f90dd3]::MirBorrowckCtxt>::report_use_of_moved_or_uninitialized
  25:     0x777d95f96856 - <rustc_borrowck[1e395e63e7f90dd3]::MirBorrowckCtxt>::consume_operand
  26:     0x777d99cdf370 - rustc_borrowck[1e395e63e7f90dd3]::do_mir_borrowck
  27:     0x777d99c9f03e - rustc_query_impl[a43b8a3fae63a645]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a43b8a3fae63a645]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b8101328ceeb956a]::query::erase::Erased<[u8; 8usize]>>
  28:     0x777d98fc212e - rustc_query_system[ef4de90281b6d444]::query::plumbing::try_execute_query::<rustc_query_impl[a43b8a3fae63a645]::DynamicConfig<rustc_query_system[ef4de90281b6d444]::query::caches::VecCache<rustc_span[8ae10af61471f323]::def_id::LocalDefId, rustc_middle[b8101328ceeb956a]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a43b8a3fae63a645]::plumbing::QueryCtxt, false>
  29:     0x777d98fc1b8d - rustc_query_impl[a43b8a3fae63a645]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  30:     0x777d990afae0 - rustc_middle[b8101328ceeb956a]::query::plumbing::query_get_at::<rustc_query_system[ef4de90281b6d444]::query::caches::VecCache<rustc_span[8ae10af61471f323]::def_id::LocalDefId, rustc_middle[b8101328ceeb956a]::query::erase::Erased<[u8; 8usize]>>>
  31:     0x777d990afb4e - <rustc_borrowck[1e395e63e7f90dd3]::type_check::TypeChecker>::prove_closure_bounds
  32:     0x777d990eb4b0 - <rustc_borrowck[1e395e63e7f90dd3]::type_check::TypeChecker>::typeck_mir
  33:     0x777d96913887 - rustc_borrowck[1e395e63e7f90dd3]::type_check::type_check
  34:     0x777d962d08d2 - rustc_borrowck[1e395e63e7f90dd3]::nll::compute_regions
  35:     0x777d99caca95 - rustc_borrowck[1e395e63e7f90dd3]::do_mir_borrowck
  36:     0x777d99c9f03e - rustc_query_impl[a43b8a3fae63a645]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a43b8a3fae63a645]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b8101328ceeb956a]::query::erase::Erased<[u8; 8usize]>>
  37:     0x777d98fc212e - rustc_query_system[ef4de90281b6d444]::query::plumbing::try_execute_query::<rustc_query_impl[a43b8a3fae63a645]::DynamicConfig<rustc_query_system[ef4de90281b6d444]::query::caches::VecCache<rustc_span[8ae10af61471f323]::def_id::LocalDefId, rustc_middle[b8101328ceeb956a]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a43b8a3fae63a645]::plumbing::QueryCtxt, false>
  38:     0x777d98fc1b8d - rustc_query_impl[a43b8a3fae63a645]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  39:     0x777d99768dc4 - rustc_interface[3320d9bec8b3433a]::passes::analysis
  40:     0x777d99767f5b - rustc_query_impl[a43b8a3fae63a645]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a43b8a3fae63a645]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b8101328ceeb956a]::query::erase::Erased<[u8; 1usize]>>
  41:     0x777d99b9c225 - rustc_query_system[ef4de90281b6d444]::query::plumbing::try_execute_query::<rustc_query_impl[a43b8a3fae63a645]::DynamicConfig<rustc_query_system[ef4de90281b6d444]::query::caches::SingleCache<rustc_middle[b8101328ceeb956a]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a43b8a3fae63a645]::plumbing::QueryCtxt, false>
  42:     0x777d99b9bf8f - rustc_query_impl[a43b8a3fae63a645]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  43:     0x777d999f9f5c - rustc_interface[3320d9bec8b3433a]::interface::run_compiler::<core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>, rustc_driver_impl[c511ea10b869fcf7]::run_compiler::{closure#0}>::{closure#1}
  44:     0x777d999c0609 - std[d6c1f98fb4e95ff7]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3320d9bec8b3433a]::util::run_in_thread_with_globals<rustc_interface[3320d9bec8b3433a]::util::run_in_thread_pool_with_globals<rustc_interface[3320d9bec8b3433a]::interface::run_compiler<core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>, rustc_driver_impl[c511ea10b869fcf7]::run_compiler::{closure#0}>::{closure#1}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>>::{closure#0}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>>
  45:     0x777d999c03b2 - <<std[d6c1f98fb4e95ff7]::thread::Builder>::spawn_unchecked_<rustc_interface[3320d9bec8b3433a]::util::run_in_thread_with_globals<rustc_interface[3320d9bec8b3433a]::util::run_in_thread_pool_with_globals<rustc_interface[3320d9bec8b3433a]::interface::run_compiler<core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>, rustc_driver_impl[c511ea10b869fcf7]::run_compiler::{closure#0}>::{closure#1}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>>::{closure#0}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>>::{closure#2} as core[5e8023d66ded8339]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:     0x777d9b0ee9eb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha3f12f701ab217ba
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/alloc/src/boxed.rs:2063:9
  47:     0x777d9b0ee9eb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbabc732018734ba3
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/alloc/src/boxed.rs:2063:9
  48:     0x777d9b0ee9eb - std::sys::pal::unix::thread::Thread::new::thread_start::h25b845304e0b166b
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys/pal/unix/thread.rs:108:17
  49:     0x777d946aa1cf - <unknown>
  50:     0x777d9472b6ec - <unknown>
  51:                0x0 - <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.80.0-nightly (7717a306b 2024-05-28) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `main::{constant#0}`
#1 [mir_borrowck] borrow-checking `main`
end of query stack
error: aborting due to 1 previous error


@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels May 28, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 28, 2024
@oli-obk oli-obk self-assigned this May 29, 2024
fmease added a commit to fmease/rust that referenced this issue May 30, 2024
Make `body_owned_by` return the `Body` instead of just the `BodyId`

fixes rust-lang#125677

Almost all `body_owned_by` callers immediately called `body`, too, so just return `Body` directly.

This makes the inline-const query feeding more robust, as all calls to `body_owned_by` will now yield a body for inline consts, too.

I have not yet figured out a good way to make `tcx.hir().body()` return an inline-const body, but that can be done as a follow-up
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 30, 2024
Make `body_owned_by` return the `Body` instead of just the `BodyId`

fixes rust-lang#125677

Almost all `body_owned_by` callers immediately called `body`, too, so just return `Body` directly.

This makes the inline-const query feeding more robust, as all calls to `body_owned_by` will now yield a body for inline consts, too.

I have not yet figured out a good way to make `tcx.hir().body()` return an inline-const body, but that can be done as a follow-up
@bors bors closed this as completed in d43930d May 30, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 30, 2024
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 13, 2024
Make `body_owned_by` return the `Body` instead of just the `BodyId`

fixes rust-lang#125677

Almost all `body_owned_by` callers immediately called `body`, too, so just return `Body` directly.

This makes the inline-const query feeding more robust, as all calls to `body_owned_by` will now yield a body for inline consts, too.

I have not yet figured out a good way to make `tcx.hir().body()` return an inline-const body, but that can be done as a follow-up
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 13, 2024
Make `body_owned_by` return the `Body` instead of just the `BodyId`

fixes rust-lang#125677

Almost all `body_owned_by` callers immediately called `body`, too, so just return `Body` directly.

This makes the inline-const query feeding more robust, as all calls to `body_owned_by` will now yield a body for inline consts, too.

I have not yet figured out a good way to make `tcx.hir().body()` return an inline-const body, but that can be done as a follow-up
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) ❄️ 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.

4 participants