Skip to content

ICE: panicked compiler/rustc_abi/src/layout.rs #147756

@YuanchengJiang

Description

@YuanchengJiang

Code

fn array() {
    #[rustc_layout_scalar_valid_range_start(1)]
    struct NonZero<T>([T; 4]);
    let nums = [1, 2, 3, 4];
    let mut foo = unsafe { NonZero(nums) };
}

Meta

rustc --version --verbose:

rustc 1.90.0 (1159e78c4 2025-09-14)
binary: rustc
commit-hash: 1159e78c4747b02ef996e55082b704c09b970588
commit-date: 2025-09-14
host: x86_64-unknown-linux-gnu
release: 1.90.0
LLVM version: 20.1.8

Error output

thread 'rustc' panicked at /rustc-dev/1159e78c4747b02ef996e55082b704c09b970588/compiler/rustc_abi/src/layout.rs:576:18:
nonscalar layout for layout_scalar_valid_range type: Layout {
    size: Size(16 bytes),
    align: AbiAlign {
        abi: Align(4 bytes),
    },
    backend_repr: Memory {
        sized: true,
    },
    fields: Arbitrary {
        offsets: [
            Size(0 bytes),
        ],
        memory_index: [
            0,
        ],
    },
    largest_niche: None,
    uninhabited: false,
    variants: Single {
        index: 0,
    },
    max_repr_align: None,
    unadjusted_abi_align: Align(4 bytes),
    randomization_seed: 15166904011572807406,
}
stack backtrace:
   0:     0x785161e00f83 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hdcfcb6d4c8489523
   1:     0x785162602d77 - core::fmt::write::h8a494366950f23bb
   2:     0x7851639d14d1 - std::io::Write::write_fmt::h6556609fca33d0b1
   3:     0x785161e00de2 - std::sys::backtrace::BacktraceLock::print::hb2a626a81e06b2dc
   4:     0x785161e04887 - std::panicking::default_hook::{{closure}}::h4f78485264f12d10
   5:     0x785161e043eb - std::panicking::default_hook::h2c66fc99e962531d
   6:     0x785160e627e3 - std[9479b33d5e275715]::panicking::update_hook::<alloc[252dd2b3abdfe4a]::boxed::Box<rustc_driver_impl[773a1ede480c2143]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x785161e050ce - std::panicking::rust_panic_with_hook::h33ac55f64bbd807d
   8:     0x785161e04dca - std::panicking::begin_panic_handler::{{closure}}::h30e7cb89678a57fe
   9:     0x785161e01459 - std::sys::backtrace::__rust_end_short_backtrace::hed60f27456c16ced
  10:     0x785161e04aad - __rustc[de2ca18b4c54d5b8]::rust_begin_unwind
  11:     0x78515e4d01a0 - core::panicking::panic_fmt::h62f63d096dd276af
  12:     0x785162dbb539 - rustc_ty_utils[327c3462a5d70139]::layout::layout_of_uncached
  13:     0x785162da80c6 - rustc_ty_utils[327c3462a5d70139]::layout::layout_of
  14:     0x785162da8030 - rustc_query_impl[4e8a788e737bdb2b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4e8a788e737bdb2b]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[581473cc959b0df7]::query::erase::Erased<[u8; 16usize]>>
  15:     0x785162da6f4e - rustc_query_system[5711f675e4c02644]::query::plumbing::try_execute_query::<rustc_query_impl[4e8a788e737bdb2b]::DynamicConfig<rustc_query_system[5711f675e4c02644]::query::caches::DefaultCache<rustc_middle[581473cc959b0df7]::ty::PseudoCanonicalInput<rustc_middle[581473cc959b0df7]::ty::Ty>, rustc_middle[581473cc959b0df7]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[4e8a788e737bdb2b]::plumbing::QueryCtxt, false>
  16:     0x785162da6b76 - rustc_query_impl[4e8a788e737bdb2b]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  17:     0x7851635af4fa - <rustc_mir_transform[134cdb5752387f32]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[134cdb5752387f32]::pass_manager::MirLint>::run_lint
  18:     0x78516260be9b - rustc_mir_transform[134cdb5752387f32]::run_analysis_to_runtime_passes
  19:     0x7851627d796b - rustc_mir_transform[134cdb5752387f32]::mir_drops_elaborated_and_const_checked
  20:     0x7851627d71d9 - rustc_query_impl[4e8a788e737bdb2b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4e8a788e737bdb2b]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[581473cc959b0df7]::query::erase::Erased<[u8; 8usize]>>
  21:     0x7851627dd3ae - rustc_query_system[5711f675e4c02644]::query::plumbing::try_execute_query::<rustc_query_impl[4e8a788e737bdb2b]::DynamicConfig<rustc_data_structures[32e9e1243901af9b]::vec_cache::VecCache<rustc_span[dd7040bcb6abea74]::def_id::LocalDefId, rustc_middle[581473cc959b0df7]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[5711f675e4c02644]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[4e8a788e737bdb2b]::plumbing::QueryCtxt, false>
  22:     0x7851627dcb09 - rustc_query_impl[4e8a788e737bdb2b]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  23:     0x7851627dc207 - <rustc_middle[581473cc959b0df7]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[c9c4c8df4db17049]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
  24:     0x7851627d980d - rustc_interface[c9c4c8df4db17049]::passes::analysis
  25:     0x7851627d8cc7 - rustc_query_impl[4e8a788e737bdb2b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4e8a788e737bdb2b]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[581473cc959b0df7]::query::erase::Erased<[u8; 0usize]>>
  26:     0x7851636d2b08 - rustc_query_system[5711f675e4c02644]::query::plumbing::try_execute_query::<rustc_query_impl[4e8a788e737bdb2b]::DynamicConfig<rustc_query_system[5711f675e4c02644]::query::caches::SingleCache<rustc_middle[581473cc959b0df7]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[4e8a788e737bdb2b]::plumbing::QueryCtxt, false>
  27:     0x7851636d2776 - rustc_query_impl[4e8a788e737bdb2b]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  28:     0x785163a17e0b - rustc_interface[c9c4c8df4db17049]::passes::create_and_enter_global_ctxt::<core[42326c15e70145c1]::option::Option<rustc_interface[c9c4c8df4db17049]::queries::Linker>, rustc_driver_impl[773a1ede480c2143]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  29:     0x7851638c11f1 - rustc_interface[c9c4c8df4db17049]::interface::run_compiler::<(), rustc_driver_impl[773a1ede480c2143]::run_compiler::{closure#0}>::{closure#1}
  30:     0x7851637751c1 - std[9479b33d5e275715]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c9c4c8df4db17049]::util::run_in_thread_with_globals<rustc_interface[c9c4c8df4db17049]::util::run_in_thread_pool_with_globals<rustc_interface[c9c4c8df4db17049]::interface::run_compiler<(), rustc_driver_impl[773a1ede480c2143]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  31:     0x785163774ea2 - <<std[9479b33d5e275715]::thread::Builder>::spawn_unchecked_<rustc_interface[c9c4c8df4db17049]::util::run_in_thread_with_globals<rustc_interface[c9c4c8df4db17049]::util::run_in_thread_pool_with_globals<rustc_interface[c9c4c8df4db17049]::interface::run_compiler<(), rustc_driver_impl[773a1ede480c2143]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[42326c15e70145c1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x78516377a7c5 - std::sys::pal::unix::thread::Thread::new::thread_start::hb6e99e73da4d28f8
  33:     0x78515d09cb7b - <unknown>
  34:     0x78515d11a5f0 - __clone
  35:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions