Skip to content

[ICE]: Zextra-const-ub-checks: non-normalized type in is_opsem_uninhabited: {type error} #159560

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Zextra-const-ub-checks
struct A {
    f: _,
}

static B: &A = B;

original:

struct A {
  f: _,
}

static B : &A = B;

fn main() {}

Version information

rustc 1.99.0-nightly (c7d7da342 2026-07-19)
binary: rustc
commit-hash: c7d7da3428c0e8b261e1ce1687e7228cf053cc62
commit-date: 2026-07-19
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8

Possibly related line of code:

| ty::Infer(..)
| ty::Placeholder(..)
| ty::Bound(..)
| ty::Param(..)
| ty::Alias(..)
| ty::CoroutineWitness(..) => {
bug!("non-normalized type in `is_opsem_uninhabited`: `{ty}`")
}
}
}
fn is_opsem_inhabited_raw<'tcx>(
tcx: TyCtxt<'tcx>,

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zextra-const-ub-checks

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.ndbc5s2LXCIu/rustc_testrunner_tmpdir_reporting.kHsj2Cp6F9w7/mvce.rs:5:18
  |
5 | static B: &A = B;
  |                  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.ndbc5s2LXCIu/rustc_testrunner_tmpdir_reporting.kHsj2Cp6F9w7/mvce.rs`

error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs
 --> /tmp/icemaker_global_tempdir.ndbc5s2LXCIu/rustc_testrunner_tmpdir_reporting.kHsj2Cp6F9w7/mvce.rs:2:8
  |
2 |     f: _,
  |        ^ not allowed in type signatures

error: internal compiler error: /rustc-dev/c7d7da3428c0e8b261e1ce1687e7228cf053cc62/compiler/rustc_middle/src/ty/inhabitedness/mod.rs:349:13: non-normalized type in `is_opsem_uninhabited`: `{type error}`


thread 'rustc' (1344960) panicked at /rustc-dev/c7d7da3428c0e8b261e1ce1687e7228cf053cc62/compiler/rustc_middle/src/ty/inhabitedness/mod.rs:349:13:
Box<dyn Any>
stack backtrace:
   0:     0x7f4793ae2346 - <<std[bb656dee0c1a7164]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[cf8fb3d9e41ef217]::fmt::Display>::fmt
   1:     0x7f479420a310 - core[cf8fb3d9e41ef217]::fmt::write
   2:     0x7f4793af75ac - <std[bb656dee0c1a7164]::sys::stdio::unix::Stderr as core[cf8fb3d9e41ef217]::io::write::Write>::write_fmt
   3:     0x7f4793ab3fda - std[bb656dee0c1a7164]::panicking::default_hook::{closure#0}
   4:     0x7f4793ad4a73 - std[bb656dee0c1a7164]::panicking::default_hook
   5:     0x7f4792a8947b - std[bb656dee0c1a7164]::panicking::update_hook::<alloc[3446759d461fd26]::boxed::Box<rustc_driver_impl[a9408d480ad75656]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f4793ad4f12 - std[bb656dee0c1a7164]::panicking::panic_with_hook
   7:     0x7f4792ab6f31 - std[bb656dee0c1a7164]::panicking::begin_panic::<rustc_errors[d99abff1ac5e4022]::ExplicitBug>::{closure#0}
   8:     0x7f4792aafca6 - std[bb656dee0c1a7164]::sys::backtrace::__rust_end_short_backtrace::<std[bb656dee0c1a7164]::panicking::begin_panic<rustc_errors[d99abff1ac5e4022]::ExplicitBug>::{closure#0}, !>
   9:     0x7f4792aadce7 - std[bb656dee0c1a7164]::panicking::begin_panic::<rustc_errors[d99abff1ac5e4022]::ExplicitBug>
  10:     0x7f4792ac20c1 - <rustc_errors[d99abff1ac5e4022]::diagnostic::BugAbort as rustc_errors[d99abff1ac5e4022]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f479304bf09 - rustc_middle[1b51c4dae9648f9a]::util::bug::opt_span_bug_fmt::<rustc_span[3e8afa6d2baecbb6]::span_encoding::Span>::{closure#0}
  12:     0x7f479304c072 - rustc_middle[1b51c4dae9648f9a]::ty::context::tls::with_opt::<rustc_middle[1b51c4dae9648f9a]::util::bug::opt_span_bug_fmt<rustc_span[3e8afa6d2baecbb6]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7f479303744b - rustc_middle[1b51c4dae9648f9a]::ty::context::tls::with_context_opt::<rustc_middle[1b51c4dae9648f9a]::ty::context::tls::with_opt<rustc_middle[1b51c4dae9648f9a]::util::bug::opt_span_bug_fmt<rustc_span[3e8afa6d2baecbb6]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7f47905f84d4 - rustc_middle[1b51c4dae9648f9a]::util::bug::bug_fmt
  15:     0x7f47953557be - rustc_middle[1b51c4dae9648f9a]::ty::inhabitedness::is_opsem_inhabited_recursor::<std[bb656dee0c1a7164]::collections::hash::set::HashSet<rustc_span[3e8afa6d2baecbb6]::def_id::DefId, rustc_hash[ed0ff835019358b]::FxBuildHasher>, rustc_middle[1b51c4dae9648f9a]::ty::inhabitedness::is_opsem_inhabited_raw::{closure#0}>
  16:     0x7f47953552bc - rustc_middle[1b51c4dae9648f9a]::ty::inhabitedness::is_opsem_inhabited_recursor::<std[bb656dee0c1a7164]::collections::hash::set::HashSet<rustc_span[3e8afa6d2baecbb6]::def_id::DefId, rustc_hash[ed0ff835019358b]::FxBuildHasher>, rustc_middle[1b51c4dae9648f9a]::ty::inhabitedness::is_opsem_inhabited_raw::{closure#0}>
  17:     0x7f47953550f0 - rustc_middle[1b51c4dae9648f9a]::ty::inhabitedness::is_opsem_inhabited_raw
  18:     0x7f4795355087 - rustc_query_impl[91105c57d45a8e7d]::query_impl::is_opsem_inhabited_raw::invoke_provider_fn::__rust_begin_short_backtrace
  19:     0x7f479470685c - rustc_query_impl[91105c57d45a8e7d]::execution::try_execute_query::<rustc_middle[1b51c4dae9648f9a]::query::caches::DefaultCache<rustc_middle[1b51c4dae9648f9a]::ty::PseudoCanonicalInput<rustc_middle[1b51c4dae9648f9a]::ty::Ty>, rustc_middle[1b51c4dae9648f9a]::query::erase::ErasedData<[u8; 1usize]>>, false>
  20:     0x7f4794706034 - rustc_query_impl[91105c57d45a8e7d]::query_impl::is_opsem_inhabited_raw::execute_query_non_incr::__rust_end_short_backtrace
  21:     0x7f47947684b0 - rustc_middle[1b51c4dae9648f9a]::ty::inhabitedness::is_opsem_inhabited_recursor::<(), <rustc_middle[1b51c4dae9648f9a]::ty::Ty>::is_opsem_inhabited::{closure#0}>
  22:     0x7f47947605a0 - <rustc_const_eval[b6356d02baa5442e]::interpret::validity::ValidityVisitor<rustc_const_eval[b6356d02baa5442e]::const_eval::machine::CompileTimeMachine>>::check_safe_pointer
  23:     0x7f4794769368 - <rustc_const_eval[b6356d02baa5442e]::interpret::validity::ValidityVisitor<rustc_const_eval[b6356d02baa5442e]::const_eval::machine::CompileTimeMachine>>::try_visit_primitive
  24:     0x7f479476ad30 - <rustc_const_eval[b6356d02baa5442e]::interpret::validity::ValidityVisitor<rustc_const_eval[b6356d02baa5442e]::const_eval::machine::CompileTimeMachine> as rustc_const_eval[b6356d02baa5442e]::interpret::visitor::ValueVisitor<rustc_const_eval[b6356d02baa5442e]::const_eval::machine::CompileTimeMachine>>::visit_value
  25:     0x7f4794744264 - <rustc_const_eval[b6356d02baa5442e]::interpret::eval_context::InterpCx<rustc_const_eval[b6356d02baa5442e]::const_eval::machine::CompileTimeMachine>>::validate_operand_internal
  26:     0x7f4795828a5e - rustc_const_eval[b6356d02baa5442e]::const_eval::eval_queries::eval_in_interpreter::<rustc_middle[1b51c4dae9648f9a]::mir::interpret::allocation::ConstAllocation>
  27:     0x7f47957ab0e2 - rustc_const_eval[b6356d02baa5442e]::const_eval::eval_queries::eval_static_initializer_provider
  28:     0x7f47957aafd9 - rustc_query_impl[91105c57d45a8e7d]::query_impl::eval_static_initializer::invoke_provider_fn::__rust_begin_short_backtrace
  29:     0x7f47942f0185 - rustc_query_impl[91105c57d45a8e7d]::execution::try_execute_query::<rustc_middle[1b51c4dae9648f9a]::query::caches::DefIdCache<rustc_middle[1b51c4dae9648f9a]::query::erase::ErasedData<[u8; 16usize]>>, false>
  30:     0x7f4794641ee1 - rustc_query_impl[91105c57d45a8e7d]::query_impl::eval_static_initializer::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7f4794654b89 - <rustc_middle[1b51c4dae9648f9a]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[da5de8c042b7d03e]::check_crate::{closure#1}>::{closure#0}
  32:     0x7f4794653f5e - rustc_hir_analysis[da5de8c042b7d03e]::check_crate
  33:     0x7f479464df75 - rustc_interface[bd87170b5770ef6e]::passes::analysis
  34:     0x7f47953ad3c7 - rustc_query_impl[91105c57d45a8e7d]::execution::try_execute_query::<rustc_middle[1b51c4dae9648f9a]::query::caches::SingleCache<rustc_middle[1b51c4dae9648f9a]::query::erase::ErasedData<[u8; 0usize]>>, false>
  35:     0x7f47953ad0a9 - rustc_query_impl[91105c57d45a8e7d]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  36:     0x7f47953d0b8d - rustc_interface[bd87170b5770ef6e]::interface::run_compiler::<(), rustc_driver_impl[a9408d480ad75656]::run_compiler::{closure#0}>::{closure#2}
  37:     0x7f47953764a4 - std[bb656dee0c1a7164]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[bd87170b5770ef6e]::util::run_in_thread_with_globals<rustc_interface[bd87170b5770ef6e]::util::run_in_thread_pool_with_globals<rustc_interface[bd87170b5770ef6e]::interface::run_compiler<(), rustc_driver_impl[a9408d480ad75656]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  38:     0x7f4795376273 - <std[bb656dee0c1a7164]::thread::lifecycle::spawn_unchecked<rustc_interface[bd87170b5770ef6e]::util::run_in_thread_with_globals<rustc_interface[bd87170b5770ef6e]::util::run_in_thread_pool_with_globals<rustc_interface[bd87170b5770ef6e]::interface::run_compiler<(), rustc_driver_impl[a9408d480ad75656]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[cf8fb3d9e41ef217]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7f4795381048 - <std[bb656dee0c1a7164]::sys::thread::unix::Thread>::new::thread_start
  40:     0x7f478ea97739 - <unknown>
  41:     0x7f478eb1bedc - <unknown>
  42:                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.99.0-nightly (c7d7da342 2026-07-19) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z extra-const-ub-checks -Z dump-mir-dir=dir

query stack during panic:
#0 [is_opsem_inhabited_raw] computing whether `A` is inhabited on the opsem level
#1 [eval_static_initializer] evaluating initializer of static `B`
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.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.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Fields

    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