Skip to content

ICE: layout_of: unexpected type #139152

Closed
Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(non_lifetime_binders)]

fn foo()
where
    for<V> V: std::mem::TransmuteFrom<()>,
{
}

original:

#![feature(non_lifetime_binders)]

pub fn foo()
where
    for<V> V: std::mem::TransmuteFrom<()>,
{
}

fn main() {
    foo();
}

Version information

rustc 1.88.0-nightly (fedf10752 2025-03-30)
binary: rustc
commit-hash: fedf10752b973d83f3f7c0f819b2659c21a634de
commit-date: 2025-03-30
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.1

Possibly related line of code:

};
return Err(error(cx, err));
}
ty::Bound(..) | ty::CoroutineWitness(..) | ty::Infer(_) | ty::Error(_) => {
// `ty::Error` is handled at the top of this function.
bug!("layout_of: unexpected type `{ty}`")
}
})
}
fn record_layout_for_printing<'tcx>(cx: &LayoutCx<'tcx>, layout: TyAndLayout<'tcx>) {
// Ignore layouts that are done with non-empty environments or

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

Program output

warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.DmSZgJbVRSAt/rustc_testrunner_tmpdir_reporting.59tIQJjLPwq7/mvce.rs:1:12
  |
1 | #![feature(non_lifetime_binders)]
  |            ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.DmSZgJbVRSAt/rustc_testrunner_tmpdir_reporting.59tIQJjLPwq7/mvce.rs:7:2
  |
7 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.DmSZgJbVRSAt/rustc_testrunner_tmpdir_reporting.59tIQJjLPwq7/mvce.rs`

error[E0658]: use of unstable library feature `transmutability`
 --> /tmp/icemaker_global_tempdir.DmSZgJbVRSAt/rustc_testrunner_tmpdir_reporting.59tIQJjLPwq7/mvce.rs:5:15
  |
5 |     for<V> V: std::mem::TransmuteFrom<()>,
  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information
  = help: add `#![feature(transmutability)]` to the crate attributes to enable
  = note: this compiler was built on 2025-03-30; consider upgrading it if it is out of date

error: internal compiler error: compiler/rustc_ty_utils/src/layout.rs:633:13: layout_of: unexpected type `V`


thread 'rustc' panicked at compiler/rustc_ty_utils/src/layout.rs:633:13:
Box<dyn Any>
stack backtrace:
   0:     0x72c7aa67c793 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h2497ecf60619df83
   1:     0x72c7aae05dd1 - core::fmt::write::hf5a66c3f8faccda1
   2:     0x72c7ac299291 - std::io::Write::write_fmt::h36dd80397df4cb14
   3:     0x72c7aa67c5f2 - std::sys::backtrace::BacktraceLock::print::h0825bf07c4aff9b1
   4:     0x72c7aa6800da - std::panicking::default_hook::{{closure}}::he12fe84d83680e45
   5:     0x72c7aa67fc5f - std::panicking::default_hook::haaa620bc6350c8d2
   6:     0x72c7a96e89b0 - std[bdc4cefc0c032e43]::panicking::update_hook::<alloc[a4260201fb21f0fa]::boxed::Box<rustc_driver_impl[a82370bbe3079b02]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x72c7aa680953 - std::panicking::rust_panic_with_hook::hfdc1820ccce7abc1
   8:     0x72c7a97276c1 - std[bdc4cefc0c032e43]::panicking::begin_panic::<rustc_errors[cfdee618df6c88ef]::ExplicitBug>::{closure#0}
   9:     0x72c7a971b386 - std[bdc4cefc0c032e43]::sys::backtrace::__rust_end_short_backtrace::<std[bdc4cefc0c032e43]::panicking::begin_panic<rustc_errors[cfdee618df6c88ef]::ExplicitBug>::{closure#0}, !>
  10:     0x72c7a9717edb - std[bdc4cefc0c032e43]::panicking::begin_panic::<rustc_errors[cfdee618df6c88ef]::ExplicitBug>
  11:     0x72c7a9730f61 - <rustc_errors[cfdee618df6c88ef]::diagnostic::BugAbort as rustc_errors[cfdee618df6c88ef]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x72c7a9d6a3ea - rustc_middle[8c2abaea4e51ae95]::util::bug::opt_span_bug_fmt::<rustc_span[45ddaf2096a5a8e9]::span_encoding::Span>::{closure#0}
  13:     0x72c7a9d45e3a - rustc_middle[8c2abaea4e51ae95]::ty::context::tls::with_opt::<rustc_middle[8c2abaea4e51ae95]::util::bug::opt_span_bug_fmt<rustc_span[45ddaf2096a5a8e9]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x72c7a9d45cab - rustc_middle[8c2abaea4e51ae95]::ty::context::tls::with_context_opt::<rustc_middle[8c2abaea4e51ae95]::ty::context::tls::with_opt<rustc_middle[8c2abaea4e51ae95]::util::bug::opt_span_bug_fmt<rustc_span[45ddaf2096a5a8e9]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x72c7a77ac7f0 - rustc_middle[8c2abaea4e51ae95]::util::bug::bug_fmt
  16:     0x72c7ab41e1ef - rustc_ty_utils[f05c1afdcf01e29b]::layout::layout_of
  17:     0x72c7ab41212a - rustc_query_impl[77fbfc8efa1d0dfd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[77fbfc8efa1d0dfd]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8c2abaea4e51ae95]::query::erase::Erased<[u8; 16usize]>>
  18:     0x72c7ab411060 - rustc_query_system[73d5636c4135c7e]::query::plumbing::try_execute_query::<rustc_query_impl[77fbfc8efa1d0dfd]::DynamicConfig<rustc_query_system[73d5636c4135c7e]::query::caches::DefaultCache<rustc_middle[8c2abaea4e51ae95]::ty::PseudoCanonicalInput<rustc_middle[8c2abaea4e51ae95]::ty::Ty>, rustc_middle[8c2abaea4e51ae95]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[77fbfc8efa1d0dfd]::plumbing::QueryCtxt, false>
  19:     0x72c7ab410c9e - rustc_query_impl[77fbfc8efa1d0dfd]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  20:     0x72c7aa5bb5a7 - rustc_transmute[a389da957d26f46d]::layout::rustc::layout_of
  21:     0x72c7aa5b6393 - <rustc_transmute[a389da957d26f46d]::layout::tree::Tree<rustc_transmute[a389da957d26f46d]::layout::rustc::Def, rustc_transmute[a389da957d26f46d]::layout::rustc::Ref>>::from_ty
  22:     0x72c7aa5bc097 - <rustc_transmute[a389da957d26f46d]::rustc::TransmuteTypeEnv>::is_transmutable
  23:     0x72c7aafa74d6 - <rustc_trait_selection[83d42188d813cc61]::traits::select::SelectionContext>::confirm_candidate
  24:     0x72c7aaf45901 - <rustc_trait_selection[83d42188d813cc61]::traits::select::SelectionContext>::evaluate_candidate::{closure#0}::{closure#0}
  25:     0x72c7aaf47773 - <rustc_trait_selection[83d42188d813cc61]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  26:     0x72c7aaf52487 - <rustc_trait_selection[83d42188d813cc61]::traits::select::SelectionContext>::evaluate_root_obligation
  27:     0x72c7aaf502bf - rustc_traits[280141601caf260c]::evaluate_obligation::evaluate_obligation
  28:     0x72c7aaf4fda9 - rustc_query_impl[77fbfc8efa1d0dfd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[77fbfc8efa1d0dfd]::query_impl::evaluate_obligation::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8c2abaea4e51ae95]::query::erase::Erased<[u8; 2usize]>>
  29:     0x72c7aaf4efb3 - rustc_query_system[73d5636c4135c7e]::query::plumbing::try_execute_query::<rustc_query_impl[77fbfc8efa1d0dfd]::DynamicConfig<rustc_query_system[73d5636c4135c7e]::query::caches::DefaultCache<rustc_type_ir[81db0f49f321e35d]::canonical::CanonicalQueryInput<rustc_middle[8c2abaea4e51ae95]::ty::context::TyCtxt, rustc_middle[8c2abaea4e51ae95]::ty::ParamEnvAnd<rustc_middle[8c2abaea4e51ae95]::ty::predicate::Predicate>>, rustc_middle[8c2abaea4e51ae95]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[77fbfc8efa1d0dfd]::plumbing::QueryCtxt, false>
  30:     0x72c7aaf4ec1e - rustc_query_impl[77fbfc8efa1d0dfd]::query_impl::evaluate_obligation::get_query_non_incr::__rust_end_short_backtrace
  31:     0x72c7ac0a4d16 - <rustc_trait_selection[83d42188d813cc61]::traits::fulfill::FulfillProcessor>::process_trait_obligation
  32:     0x72c7ab79bdaf - <rustc_trait_selection[83d42188d813cc61]::traits::fulfill::FulfillProcessor as rustc_data_structures[cfad269df1308ded]::obligation_forest::ObligationProcessor>::process_obligation
  33:     0x72c7aae079e9 - <rustc_data_structures[cfad269df1308ded]::obligation_forest::ObligationForest<rustc_trait_selection[83d42188d813cc61]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[83d42188d813cc61]::traits::fulfill::FulfillProcessor>
  34:     0x72c7ab5c078e - rustc_trait_selection[83d42188d813cc61]::traits::impossible_predicates
  35:     0x72c7ab5bf785 - <rustc_mir_transform[31f24db7fba23339]::impossible_predicates::ImpossiblePredicates as rustc_mir_transform[31f24db7fba23339]::pass_manager::MirPass>::run_pass
  36:     0x72c7aae0bc66 - rustc_mir_transform[31f24db7fba23339]::run_analysis_to_runtime_passes
  37:     0x72c7ab0ab024 - rustc_mir_transform[31f24db7fba23339]::mir_drops_elaborated_and_const_checked
  38:     0x72c7ab0aaa25 - rustc_query_impl[77fbfc8efa1d0dfd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[77fbfc8efa1d0dfd]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8c2abaea4e51ae95]::query::erase::Erased<[u8; 8usize]>>
  39:     0x72c7ab0d452c - rustc_query_system[73d5636c4135c7e]::query::plumbing::try_execute_query::<rustc_query_impl[77fbfc8efa1d0dfd]::DynamicConfig<rustc_data_structures[cfad269df1308ded]::vec_cache::VecCache<rustc_span[45ddaf2096a5a8e9]::def_id::LocalDefId, rustc_middle[8c2abaea4e51ae95]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[73d5636c4135c7e]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[77fbfc8efa1d0dfd]::plumbing::QueryCtxt, false>
  40:     0x72c7ab0d3e0b - rustc_query_impl[77fbfc8efa1d0dfd]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  41:     0x72c7ab6f6a6b - rustc_interface[4b6516d07ac6860f]::passes::run_required_analyses
  42:     0x72c7ab837c5e - rustc_interface[4b6516d07ac6860f]::passes::analysis
  43:     0x72c7ab837c2d - rustc_query_impl[77fbfc8efa1d0dfd]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[77fbfc8efa1d0dfd]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8c2abaea4e51ae95]::query::erase::Erased<[u8; 0usize]>>
  44:     0x72c7abdcbcbd - rustc_query_system[73d5636c4135c7e]::query::plumbing::try_execute_query::<rustc_query_impl[77fbfc8efa1d0dfd]::DynamicConfig<rustc_query_system[73d5636c4135c7e]::query::caches::SingleCache<rustc_middle[8c2abaea4e51ae95]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[77fbfc8efa1d0dfd]::plumbing::QueryCtxt, false>
  45:     0x72c7abdcb9b8 - rustc_query_impl[77fbfc8efa1d0dfd]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  46:     0x72c7ac00ee4d - rustc_interface[4b6516d07ac6860f]::passes::create_and_enter_global_ctxt::<core[e80f784d23167c2e]::option::Option<rustc_interface[4b6516d07ac6860f]::queries::Linker>, rustc_driver_impl[a82370bbe3079b02]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  47:     0x72c7abf2faaa - rustc_interface[4b6516d07ac6860f]::interface::run_compiler::<(), rustc_driver_impl[a82370bbe3079b02]::run_compiler::{closure#0}>::{closure#1}
  48:     0x72c7abd87c48 - std[bdc4cefc0c032e43]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4b6516d07ac6860f]::util::run_in_thread_with_globals<rustc_interface[4b6516d07ac6860f]::util::run_in_thread_pool_with_globals<rustc_interface[4b6516d07ac6860f]::interface::run_compiler<(), rustc_driver_impl[a82370bbe3079b02]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  49:     0x72c7abd88534 - <<std[bdc4cefc0c032e43]::thread::Builder>::spawn_unchecked_<rustc_interface[4b6516d07ac6860f]::util::run_in_thread_with_globals<rustc_interface[4b6516d07ac6860f]::util::run_in_thread_pool_with_globals<rustc_interface[4b6516d07ac6860f]::interface::run_compiler<(), rustc_driver_impl[a82370bbe3079b02]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[e80f784d23167c2e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:     0x72c7abd89937 - std::sys::pal::unix::thread::Thread::new::thread_start::h36ad1309f224e2da
  51:     0x72c7a5ca370a - <unknown>
  52:     0x72c7a5d27aac - <unknown>
  53:                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.88.0-nightly (fedf10752 2025-03-30) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [layout_of] computing layout of `V`
#1 [evaluate_obligation] evaluating trait selection obligation `V: core::mem::transmutability::TransmuteFrom<(), core::mem::transmutability::Assume { alignment: false, lifetimes: false, safety: false, validity: false }>`
#2 [mir_drops_elaborated_and_const_checked] elaborating drops for `foo`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

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

@rustbot label +F-non_lifetime_binders

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-non_lifetime_binders`#![feature(non_lifetime_binders)]`F-transmutability`#![feature(transmutability)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-bisectionStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-featuresThis issue requires the use of incomplete features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions