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: assertion failed: layout.is_sized() #137186

Open
matthiaskrgr opened this issue Feb 17, 2025 · 6 comments · May be fixed by #137298
Open

ICE: assertion failed: layout.is_sized() #137186

matthiaskrgr opened this issue Feb 17, 2025 · 6 comments · May be fixed by #137298
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. 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):

static no_mangle: str = {
    unimplemented!();
};

original:

#[track_caller]
static no_mangle: str = {
    unimplemented!();
};

Version information

rustc 1.87.0-nightly (ce36a966c 2025-02-17)
binary: rustc
commit-hash: ce36a966c79e109dabeef7a47fe68e5294c6d71e
commit-date: 2025-02-17
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

| DefKind::AssocConst
),
"Unexpected DefKind: {:?}",
ecx.tcx.def_kind(cid.instance.def_id())
);
let layout = ecx.layout_of(body.bound_return_ty().instantiate(tcx, cid.instance.args))?;
assert!(layout.is_sized());
let intern_kind = if cid.promoted.is_some() {
InternKind::Promoted
} else {
match tcx.static_mutability(cid.instance.def_id()) {
Some(m) => InternKind::Static(m),

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

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.pWi9wq9I3FhY/rustc_testrunner_tmpdir_reporting.LzJ1a0v253mW/mvce.rs:3:3
  |
3 | };
  |   ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.pWi9wq9I3FhY/rustc_testrunner_tmpdir_reporting.LzJ1a0v253mW/mvce.rs`

error[E0277]: the size for values of type `str` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.pWi9wq9I3FhY/rustc_testrunner_tmpdir_reporting.LzJ1a0v253mW/mvce.rs:1:19
  |
1 | static no_mangle: str = {
  |                   ^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `str`


thread 'rustc' panicked at compiler/rustc_const_eval/src/const_eval/eval_queries.rs:49:5:
assertion failed: layout.is_sized()
stack backtrace:
   0:     0x70741cd99e40 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h3841cd57ff2ecd73
   1:     0x70741d6148ac - core::fmt::write::h1e3520bf56740af3
   2:     0x70741e6318d1 - std::io::Write::write_fmt::hba9e4167b3001b26
   3:     0x70741cd99ca2 - std::sys::backtrace::BacktraceLock::print::h4cef63a231b9b903
   4:     0x70741cd9c4a6 - std::panicking::default_hook::{{closure}}::h42a071c1742d1486
   5:     0x70741cd9c084 - std::panicking::default_hook::hb623603f8ca8d5a9
   6:     0x70741bee571b - std[3b75b760e1909bee]::panicking::update_hook::<alloc[fee51eceb6acdb2a]::boxed::Box<rustc_driver_impl[345723d7f8fea549]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x70741cd9cd53 - std::panicking::rust_panic_with_hook::h4a78a56a08a0281e
   8:     0x70741cd9ca16 - std::panicking::begin_panic_handler::{{closure}}::h003b3348edc396e0
   9:     0x70741cd9a309 - std::sys::backtrace::__rust_end_short_backtrace::h40301e4d631caaec
  10:     0x70741cd9c70d - rust_begin_unwind
  11:     0x707419a459e0 - core::panicking::panic_fmt::hf9c35d88d19a7b20
  12:     0x70741a44a02c - core::panicking::panic::h816f8e94a2911cfd
  13:     0x70741d675c7e - rustc_const_eval[24ba1ca4ddcda3d4]::const_eval::eval_queries::eval_body_using_ecx::<rustc_middle[8f0bb18145f914db]::mir::interpret::allocation::ConstAllocation>
  14:     0x70741e2e9640 - rustc_const_eval[24ba1ca4ddcda3d4]::const_eval::eval_queries::eval_static_initializer_provider
  15:     0x70741e2e93d9 - rustc_query_impl[1dc7e25d3505b9db]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1dc7e25d3505b9db]::query_impl::eval_static_initializer::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8f0bb18145f914db]::query::erase::Erased<[u8; 16usize]>>
  16:     0x70741e2e93b1 - <rustc_query_impl[1dc7e25d3505b9db]::query_impl::eval_static_initializer::dynamic_query::{closure#2} as core[22e5dcc507c1ce60]::ops::function::FnOnce<(rustc_middle[8f0bb18145f914db]::ty::context::TyCtxt, rustc_span[75e5c439b5acee8]::def_id::DefId)>>::call_once
  17:     0x70741dbbaa9b - rustc_query_system[923c01520de53f9e]::query::plumbing::try_execute_query::<rustc_query_impl[1dc7e25d3505b9db]::DynamicConfig<rustc_query_system[923c01520de53f9e]::query::caches::DefIdCache<rustc_middle[8f0bb18145f914db]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[1dc7e25d3505b9db]::plumbing::QueryCtxt, false>
  18:     0x70741e69c73a - rustc_query_impl[1dc7e25d3505b9db]::query_impl::eval_static_initializer::get_query_non_incr::__rust_end_short_backtrace
  19:     0x70741d9ac458 - <rustc_middle[8f0bb18145f914db]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[6ca72d962790c728]::check_crate::{closure#2}>::{closure#0}
  20:     0x70741d9ab238 - rustc_hir_analysis[6ca72d962790c728]::check_crate
  21:     0x70741d95f8dc - rustc_interface[d53afbea1eb411d7]::passes::run_required_analyses
  22:     0x70741e62d95e - rustc_interface[d53afbea1eb411d7]::passes::analysis
  23:     0x70741e62d92f - rustc_query_impl[1dc7e25d3505b9db]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1dc7e25d3505b9db]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8f0bb18145f914db]::query::erase::Erased<[u8; 0usize]>>
  24:     0x70741e617495 - rustc_query_system[923c01520de53f9e]::query::plumbing::try_execute_query::<rustc_query_impl[1dc7e25d3505b9db]::DynamicConfig<rustc_query_system[923c01520de53f9e]::query::caches::SingleCache<rustc_middle[8f0bb18145f914db]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1dc7e25d3505b9db]::plumbing::QueryCtxt, false>
  25:     0x70741e6171ce - rustc_query_impl[1dc7e25d3505b9db]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  26:     0x70741e6daf3c - rustc_interface[d53afbea1eb411d7]::passes::create_and_enter_global_ctxt::<core[22e5dcc507c1ce60]::option::Option<rustc_interface[d53afbea1eb411d7]::queries::Linker>, rustc_driver_impl[345723d7f8fea549]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  27:     0x70741e6557e2 - rustc_interface[d53afbea1eb411d7]::interface::run_compiler::<(), rustc_driver_impl[345723d7f8fea549]::run_compiler::{closure#0}>::{closure#1}
  28:     0x70741e5d5898 - std[3b75b760e1909bee]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d53afbea1eb411d7]::util::run_in_thread_with_globals<rustc_interface[d53afbea1eb411d7]::util::run_in_thread_pool_with_globals<rustc_interface[d53afbea1eb411d7]::interface::run_compiler<(), rustc_driver_impl[345723d7f8fea549]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  29:     0x70741e5d5574 - <<std[3b75b760e1909bee]::thread::Builder>::spawn_unchecked_<rustc_interface[d53afbea1eb411d7]::util::run_in_thread_with_globals<rustc_interface[d53afbea1eb411d7]::util::run_in_thread_pool_with_globals<rustc_interface[d53afbea1eb411d7]::interface::run_compiler<(), rustc_driver_impl[345723d7f8fea549]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[22e5dcc507c1ce60]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x70741e5d4d2b - std::sys::pal::unix::thread::Thread::new::thread_start::h9b930113dc9df217
  31:     0x7074186a339d - <unknown>
  32:     0x70741872849c - <unknown>
  33:                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 (ce36a966c 2025-02-17) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_static_initializer] evaluating initializer of static `no_mangle`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0277, E0601.
For more information about an error, try `rustc --explain E0277`.

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

bisects to #136274

@matthiaskrgr
Copy link
Member Author

mvce I guess

static a: str = todo!();

@workingjubilee
Copy link
Member

workingjubilee commented Feb 17, 2025

This really shouldn't reach that code, so a fix would ideally try to find the error upstream and cut it off before it reaches there.

@workingjubilee
Copy link
Member

Oh, I see, this fails on stable but ICEs on nightly, because... checking the sizedness of the return type during wellformedness checks, because the return type is ! and the return type we'd be coercing it to is unsized, results in a correctly failed assertion?

cc @compiler-errors

@workingjubilee workingjubilee added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 17, 2025
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Feb 17, 2025
@workingjubilee
Copy link
Member

This will have reached beta, I expect.

@workingjubilee workingjubilee removed regression-from-stable-to-beta Performance or correctness regression from stable to beta. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 17, 2025
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added the P-medium Medium priority label Feb 18, 2025
@apiraino apiraino added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Feb 18, 2025
@compiler-errors compiler-errors self-assigned this Feb 18, 2025
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 19, 2025
Unconditionally check sizedness of body in typeck to taint typeck results

Puts the sized check back into typeck (duplicated -- we still have it in wfcheck) so that we properly taint bodies. These duplicated diagnostics will all be deduplicated with `-Zdeduplicate-diagnostics`, so it's just UI test fallout and not an actual regression in user-facing diagnostics.

We could perhaps do this without duplicating all the diagnostics if we put this check into something like mir build 🤔 Ideally CTFE would just be more fallible to non-WF code but 🤷

Fixes rust-lang#137186
@compiler-errors compiler-errors linked a pull request Feb 20, 2025 that will close this issue
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Feb 20, 2025
Check signature WF when lowering MIR body

Alternative to rust-lang#137233.

rust-lang#137233 (comment)

Fixes rust-lang#137186

We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily.

r? lcnr
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 20, 2025
Check signature WF when lowering MIR body

Alternative to rust-lang#137233.

rust-lang#137233 (comment)

Fixes rust-lang#137186

We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily.

r? lcnr

try-job: test-various
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 21, 2025
Check signature WF when lowering MIR body

Alternative to rust-lang#137233.

rust-lang#137233 (comment)

Fixes rust-lang#137186

We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily.

r? lcnr

try-job: test-various
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 21, 2025
Check signature WF when lowering MIR body

Alternative to rust-lang#137233.

rust-lang#137233 (comment)

Fixes rust-lang#137186

We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily.

r? lcnr

try-job: test-various
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 21, 2025
Check signature WF when lowering MIR body

Alternative to rust-lang#137233.

rust-lang#137233 (comment)

Fixes rust-lang#137186

We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily.

r? lcnr

try-job: test-various
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 22, 2025
Check signature WF when lowering MIR body

Alternative to rust-lang#137233.

rust-lang#137233 (comment)

Fixes rust-lang#137186

We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily.

r? lcnr

try-job: test-various
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 22, 2025
Check signature WF when lowering MIR body

Alternative to rust-lang#137233.

rust-lang#137233 (comment)

Fixes rust-lang#137186

We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily.

r? lcnr

try-job: test-various
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) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
5 participants