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: mir_build: no entry found for key #125676

Closed
matthiaskrgr opened this issue May 28, 2024 · 2 comments · Fixed by #125705
Closed

ICE: mir_build: no entry found for key #125676

matthiaskrgr opened this issue May 28, 2024 · 2 comments · Fixed by #125705
Assignees
Labels
C-bug Category: This is a bug. F-inline_const Inline constants (aka: const blocks, const expressions, anonymous constants) 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):

const fn test_me<T>(a: usize, b: usize) -> usize {
    const {
        if a < b {
            std::mem::size_of::<T>()
        } else {
            usize::MAX
        }
    }
}

original:

// run-pass
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

const fn test_me<T>(a: usize, b: usize) -> usize {
    const {if a < b {
        std::mem::size_of::<T>()
    } else {
        usize::MAX
    }}
}

fn test_simple<T>() -> [u8; std::mem::size_of::<T>()]
where
    [u8; std::mem::size_of::<T>()]: Sized,
{
    [0; std::mem::size_of::<T>()]
}

fn test_with_args<T, const N: usize>() -> [u8; test_me::<T>(N, N + 1) + N]
where
    [u8; test_me::<T>(N, N + 1) + N]: Sized,
{
    [0; test_me::<T>(N, N + 1) + N]
}

fn main() {
    assert_eq!([0; 8], test_simple::<u64>());
    assert_eq!([0; 12], test_with_args::<u64, 4>());
}

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[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.3Yltk13HQO49/rustc_testrunner_tmpdir_reporting.RrAAdGe4inOX/mvce.rs:9:2
  |
9 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.3Yltk13HQO49/rustc_testrunner_tmpdir_reporting.RrAAdGe4inOX/mvce.rs`

thread 'rustc' panicked at compiler/rustc_mir_build/src/build/mod.rs:241:25:
no entry found for key
stack backtrace:
   0:     0x7f7bf17b9ae5 - std::backtrace_rs::backtrace::libunwind::trace::h8e3ec5065424d28b
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7f7bf17b9ae5 - std::backtrace_rs::backtrace::trace_unsynchronized::h882cf49e59475dbc
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7bf17b9ae5 - std::sys_common::backtrace::_print_fmt::h2c337a2c4b83dc01
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f7bf17b9ae5 - <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:     0x7f7bf180a5db - core::fmt::rt::Argument::fmt::h9f1efa968e340ff7
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/fmt/rt.rs:165:63
   5:     0x7f7bf180a5db - core::fmt::write::hc4341e028d4aa04e
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/fmt/mod.rs:1168:21
   6:     0x7f7bf17ae86f - std::io::Write::write_fmt::hf3dd4197197b5730
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/io/mod.rs:1835:15
   7:     0x7f7bf17b98be - std::sys_common::backtrace::_print::hee589e8f95e333af
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f7bf17b98be - std::sys_common::backtrace::print::hc6a85e053c1c7334
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f7bf17bc2e9 - std::panicking::default_hook::{{closure}}::he62a1676f96fee54
  10:     0x7f7bf17bc08a - std::panicking::default_hook::h2ceb904f12dea8be
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/panicking.rs:298:9
  11:     0x7f7bedf8e6a0 - std[d6c1f98fb4e95ff7]::panicking::update_hook::<alloc[78b6f7e6bd40c475]::boxed::Box<rustc_driver_impl[c511ea10b869fcf7]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f7bf17bca1b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hc5b72f85a4688529
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/alloc/src/boxed.rs:2077:9
  13:     0x7f7bf17bca1b - std::panicking::rust_panic_with_hook::h0a690364d46daaac
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/panicking.rs:799:13
  14:     0x7f7bf17bc794 - std::panicking::begin_panic_handler::{{closure}}::h9c10c03249dd0030
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/panicking.rs:664:13
  15:     0x7f7bf17b9fa9 - std::sys_common::backtrace::__rust_end_short_backtrace::h599802efea5774a9
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f7bf17bc4c7 - rust_begin_unwind
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/panicking.rs:652:5
  17:     0x7f7bf1806b73 - core::panicking::panic_fmt::h16f8f3f4aae78ff5
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/panicking.rs:72:14
  18:     0x7f7bf180691b - core::panicking::panic_display::hd37bbef51df3a6ae
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/panicking.rs:262:5
  19:     0x7f7bf180691b - core::option::expect_failed::hded3cd93e8782a18
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/core/src/option.rs:1997:5
  20:     0x7f7bef69ce93 - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::expr_as_place
  21:     0x7f7bef69e59d - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::expr_into_dest
  22:     0x7f7bef6961ea - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::as_temp::{closure#0}
  23:     0x7f7bef692330 - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::as_operand
  24:     0x7f7bef692009 - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::as_operand
  25:     0x7f7bef6939ed - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::as_rvalue
  26:     0x7f7bef69d964 - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::expr_into_dest
  27:     0x7f7bef6961ea - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::as_temp::{closure#0}
  28:     0x7f7bf045225f - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::then_else_break_inner
  29:     0x7f7bf04525c4 - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::then_else_break_inner
  30:     0x7f7bf04525c4 - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::then_else_break_inner
  31:     0x7f7bef6a021e - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::expr_into_dest
  32:     0x7f7bef69f972 - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::expr_into_dest
  33:     0x7f7befef615c - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::ast_block_stmts
  34:     0x7f7befef507b - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::ast_block
  35:     0x7f7bef69e558 - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::expr_into_dest
  36:     0x7f7bef69f972 - <rustc_mir_build[9415bcb3f6b13a09]::build::Builder>::expr_into_dest
  37:     0x7f7bef67481e - rustc_mir_build[9415bcb3f6b13a09]::build::mir_build
  38:     0x7f7bef6712ce - rustc_query_impl[a43b8a3fae63a645]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a43b8a3fae63a645]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b8101328ceeb956a]::query::erase::Erased<[u8; 8usize]>>
  39:     0x7f7bef5c212e - 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>
  40:     0x7f7bef5c1c4d - rustc_query_impl[a43b8a3fae63a645]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7f7bef6657b0 - <rustc_mir_build[9415bcb3f6b13a09]::check_unsafety::UnsafetyVisitor>::visit_inner_body
  42:     0x7f7bec8a0d44 - <rustc_mir_build[9415bcb3f6b13a09]::check_unsafety::UnsafetyVisitor as rustc_middle[b8101328ceeb956a]::thir::visit::Visitor>::visit_expr
  43:     0x7f7bec8a2054 - <rustc_mir_build[9415bcb3f6b13a09]::check_unsafety::UnsafetyVisitor as rustc_middle[b8101328ceeb956a]::thir::visit::Visitor>::visit_expr
  44:     0x7f7bec8a0d44 - <rustc_mir_build[9415bcb3f6b13a09]::check_unsafety::UnsafetyVisitor as rustc_middle[b8101328ceeb956a]::thir::visit::Visitor>::visit_expr
  45:     0x7f7bef662a24 - rustc_mir_build[9415bcb3f6b13a09]::check_unsafety::check_unsafety
  46:     0x7f7bef6624c7 - rustc_query_impl[a43b8a3fae63a645]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a43b8a3fae63a645]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b8101328ceeb956a]::query::erase::Erased<[u8; 0usize]>>
  47:     0x7f7bef6615d4 - 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; 0usize]>>, false, false, false>, rustc_query_impl[a43b8a3fae63a645]::plumbing::QueryCtxt, false>
  48:     0x7f7bef661207 - rustc_query_impl[a43b8a3fae63a645]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  49:     0x7f7befd68e5b - rustc_interface[3320d9bec8b3433a]::passes::analysis
  50:     0x7f7befd67f5b - 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]>>
  51:     0x7f7bf019c225 - 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>
  52:     0x7f7bf019bf8f - rustc_query_impl[a43b8a3fae63a645]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  53:     0x7f7befff9f5c - rustc_interface[3320d9bec8b3433a]::interface::run_compiler::<core[5e8023d66ded8339]::result::Result<(), rustc_span[8ae10af61471f323]::ErrorGuaranteed>, rustc_driver_impl[c511ea10b869fcf7]::run_compiler::{closure#0}>::{closure#1}
  54:     0x7f7beffc0609 - 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>>
  55:     0x7f7beffc03b2 - <<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}
  56:     0x7f7bf17c69eb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha3f12f701ab217ba
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/alloc/src/boxed.rs:2063:9
  57:     0x7f7bf17c69eb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbabc732018734ba3
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/alloc/src/boxed.rs:2063:9
  58:     0x7f7bf17c69eb - std::sys::pal::unix::thread::Thread::new::thread_start::h25b845304e0b166b
                               at /rustc/7717a306b2678ba9ece19b723c76a6b3a89ba931/library/std/src/sys/pal/unix/thread.rs:108:17
  59:     0x7f7bf15621cf - <unknown>
  60:     0x7f7bf15e36ec - <unknown>
  61:                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.80.0-nightly (7717a306b 2024-05-28) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_built] building MIR for `test_me::{constant#0}`
#1 [check_unsafety] unsafety-checking `test_me`
end of query stack
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0601`.

@rustbot label +F-generic_const_exprs

@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 needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-generic_const_exprs `#![feature(generic_const_exprs)]` labels May 28, 2024
@lqd
Copy link
Member

lqd commented May 28, 2024

Huhu, the master artifacts -v is super confusing since the nightly date is incorrect 😅 I don't think cargo-bisect-rustc would work on that. Anyway it's #124650 ofc, nothing much else has landed since the nightly was cut.

@rustbot label -F-generic_const_exprs +F-inline_const

@rustbot rustbot added F-inline_const Inline constants (aka: const blocks, const expressions, anonymous constants) and removed F-generic_const_exprs `#![feature(generic_const_exprs)]` labels May 28, 2024
@matthiaskrgr
Copy link
Member Author

ah, I would just look at the commit hash given by rustc 😅

@oli-obk oli-obk self-assigned this May 28, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 29, 2024
…r-errors

Reintroduce name resolution check for trying to access locals from an inline const

fixes rust-lang#125676

I removed this without replacement in rust-lang#124650 without considering the consequences
@bors bors closed this as completed in c09b89e May 29, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 29, 2024
Rollup merge of rust-lang#125705 - oli-obk:const_block_ice, r=compiler-errors

Reintroduce name resolution check for trying to access locals from an inline const

fixes rust-lang#125676

I removed this without replacement in rust-lang#124650 without considering the consequences
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 30, 2024
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. F-inline_const Inline constants (aka: const blocks, const expressions, anonymous constants) 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