Skip to content

ICE: Failed to normalize std::option::Option<Alias(Projection, AliasTy #148192

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait WhereTrait {
    type Type;
}
#[derive(Debug)]
enum Enum<B, C> {
    Map {
        b2: B,
        c2: C,
        c4: C,
    },
    Map {
        b2: Option<bool>,
        c2: Option<bool>,
        c4: Option<<B as WhereTrait>::Type>,
    },
}

original:

trait WhereTrait {
    type Type;
}
#[derive(Debug)]
enum Enum<B, C> {
    Map {
        b2: B,
        c2: C,
        c4: C,
    },
    Map {
        b2: Option<bool>,
        c2: Option<bool>,
        c4: Option<<B as WhereTrait>::Type>,
    },
}

pub fn main() {}

Version information

rustc 1.93.0-nightly (adaa83897 2025-10-27)
binary: rustc
commit-hash: adaa838976ff99a4f0661136322f64cb466b58a0
commit-date: 2025-10-27
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.3

Possibly related line of code:

fn normalize_generic_arg_after_erasing_regions(
&self,
arg: ty::GenericArg<'tcx>,
) -> ty::GenericArg<'tcx> {
let arg = self.typing_env.as_query_input(arg);
self.tcx.try_normalize_generic_arg_after_erasing_regions(arg).unwrap_or_else(|_| {
bug!(
"Failed to normalize {:?} in typing_env={:?}, \
maybe try to call `try_normalize_erasing_regions` instead",
arg.value,
self.typing_env,
)
})

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

Program output

error[E0428]: the name `Map` is defined multiple times
  --> /tmp/icemaker_global_tempdir.3oNURlDYLjS7/rustc_testrunner_tmpdir_reporting.8U3OHERs9wrR/mvce.rs:11:5
   |
 6 |     Map {
   |     --- previous definition of the type `Map` here
...
11 |     Map {
   |     ^^^ `Map` redefined here
   |
   = note: `Map` must be defined only once in the type namespace of this enum

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.3oNURlDYLjS7/rustc_testrunner_tmpdir_reporting.8U3OHERs9wrR/mvce.rs:16:2
   |
16 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.3oNURlDYLjS7/rustc_testrunner_tmpdir_reporting.8U3OHERs9wrR/mvce.rs`

error[E0277]: the trait bound `B: WhereTrait` is not satisfied
  --> /tmp/icemaker_global_tempdir.3oNURlDYLjS7/rustc_testrunner_tmpdir_reporting.8U3OHERs9wrR/mvce.rs:14:13
   |
14 |         c4: Option<<B as WhereTrait>::Type>,
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WhereTrait` is not implemented for `B`
   |
help: consider restricting type parameter `B` with trait `WhereTrait`
   |
 5 | enum Enum<B: WhereTrait, C> {
   |            ++++++++++++

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:171:13: Failed to normalize std::option::Option<Alias(Projection, AliasTy { args: [B/#0], def_id: DefId(0:4 ~ mvce[8eec]::WhereTrait::Type), .. })> in typing_env=TypingEnv { typing_mode: Analysis { defining_opaque_types_and_generators: [] }, param_env: ParamEnv { caller_bounds: [Binder { value: TraitPredicate(<C as std::fmt::Debug>, polarity:Positive), bound_vars: [] }, Binder { value: TraitPredicate(<B as std::fmt::Debug>, polarity:Positive), bound_vars: [] }, Binder { value: TraitPredicate(<C as std::marker::Sized>, polarity:Positive), bound_vars: [] }, Binder { value: TraitPredicate(<B as std::marker::Sized>, polarity:Positive), bound_vars: [] }] } }, maybe try to call `try_normalize_erasing_regions` instead


thread 'rustc' (1298368) panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:171:13:
Box<dyn Any>
stack backtrace:
   0:     0x7f5bb10697d3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h745485f6d0da29f2
   1:     0x7f5bb1801b58 - core::fmt::write::h5ca30caf938b8f38
   2:     0x7f5bb101dc73 - std::io::Write::write_fmt::h8a9e8d8a55b62179
   3:     0x7f5bb102f332 - std::sys::backtrace::BacktraceLock::print::h57aecb36e542db2d
   4:     0x7f5bb1035409 - std::panicking::default_hook::{{closure}}::h6b09674b04f8384a
   5:     0x7f5bb1034f33 - std::panicking::default_hook::h38455ae175386e59
   6:     0x7f5bb002f761 - std[6bb7ebd1ee7cfb78]::panicking::update_hook::<alloc[127da13bc8f1b24c]::boxed::Box<rustc_driver_impl[89b7377193a66b58]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7f5bb103582f - std::panicking::panic_with_hook::hc6fd8c6c5311db19
   8:     0x7f5bb006c1b1 - std[6bb7ebd1ee7cfb78]::panicking::begin_panic::<rustc_errors[fd6986f752ab1d3e]::ExplicitBug>::{closure#0}
   9:     0x7f5bb005e346 - std[6bb7ebd1ee7cfb78]::sys::backtrace::__rust_end_short_backtrace::<std[6bb7ebd1ee7cfb78]::panicking::begin_panic<rustc_errors[fd6986f752ab1d3e]::ExplicitBug>::{closure#0}, !>
  10:     0x7f5bb005b834 - std[6bb7ebd1ee7cfb78]::panicking::begin_panic::<rustc_errors[fd6986f752ab1d3e]::ExplicitBug>
  11:     0x7f5bb007d761 - <rustc_errors[fd6986f752ab1d3e]::diagnostic::BugAbort as rustc_errors[fd6986f752ab1d3e]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7f5bb0615b1a - rustc_middle[414b3e7bcdf520cb]::util::bug::opt_span_bug_fmt::<rustc_span[8f290dc910631f84]::span_encoding::Span>::{closure#0}
  13:     0x7f5bb0615c9a - rustc_middle[414b3e7bcdf520cb]::ty::context::tls::with_opt::<rustc_middle[414b3e7bcdf520cb]::util::bug::opt_span_bug_fmt<rustc_span[8f290dc910631f84]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f5bb06066bb - rustc_middle[414b3e7bcdf520cb]::ty::context::tls::with_context_opt::<rustc_middle[414b3e7bcdf520cb]::ty::context::tls::with_opt<rustc_middle[414b3e7bcdf520cb]::util::bug::opt_span_bug_fmt<rustc_span[8f290dc910631f84]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f5bae210be0 - rustc_middle[414b3e7bcdf520cb]::util::bug::bug_fmt
  16:     0x7f5bb1851989 - <rustc_middle[414b3e7bcdf520cb]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[a6a60075bca9e921]::fold::TypeFolder<rustc_middle[414b3e7bcdf520cb]::ty::context::TyCtxt>>::fold_ty
  17:     0x7f5bb1c492d1 - <rustc_pattern_analysis[1b03f2ebfe0dde7a]::rustc::RustcPatCtxt as rustc_pattern_analysis[1b03f2ebfe0dde7a]::PatCx>::ctor_sub_tys
  18:     0x7f5bb1c49683 - <rustc_pattern_analysis[1b03f2ebfe0dde7a]::pat::WitnessPat<rustc_pattern_analysis[1b03f2ebfe0dde7a]::rustc::RustcPatCtxt>>::wild_from_ctor
  19:     0x7f5bb1c55f8f - <rustc_pattern_analysis[1b03f2ebfe0dde7a]::usefulness::WitnessMatrix<rustc_pattern_analysis[1b03f2ebfe0dde7a]::rustc::RustcPatCtxt>>::apply_constructor
  20:     0x7f5bb1c5a129 - rustc_pattern_analysis[1b03f2ebfe0dde7a]::usefulness::compute_exhaustiveness_and_usefulness::<rustc_pattern_analysis[1b03f2ebfe0dde7a]::rustc::RustcPatCtxt>::{closure#0}
  21:     0x7f5bb1c5a0bc - rustc_pattern_analysis[1b03f2ebfe0dde7a]::usefulness::compute_exhaustiveness_and_usefulness::<rustc_pattern_analysis[1b03f2ebfe0dde7a]::rustc::RustcPatCtxt>::{closure#0}
  22:     0x7f5bb1c54327 - rustc_pattern_analysis[1b03f2ebfe0dde7a]::rustc::analyze_match
  23:     0x7f5bae319f35 - <rustc_mir_build[cdfc528c5eaf545a]::thir::pattern::check_match::MatchVisitor>::check_match
  24:     0x7f5bb1c4a8e9 - <rustc_mir_build[cdfc528c5eaf545a]::thir::pattern::check_match::MatchVisitor as rustc_middle[414b3e7bcdf520cb]::thir::visit::Visitor>::visit_expr
  25:     0x7f5bb1c4a8bf - <rustc_mir_build[cdfc528c5eaf545a]::thir::pattern::check_match::MatchVisitor as rustc_middle[414b3e7bcdf520cb]::thir::visit::Visitor>::visit_expr
  26:     0x7f5bb1c4a990 - <rustc_mir_build[cdfc528c5eaf545a]::thir::pattern::check_match::MatchVisitor as rustc_middle[414b3e7bcdf520cb]::thir::visit::Visitor>::visit_expr
  27:     0x7f5bb1c4a8bf - <rustc_mir_build[cdfc528c5eaf545a]::thir::pattern::check_match::MatchVisitor as rustc_middle[414b3e7bcdf520cb]::thir::visit::Visitor>::visit_expr
  28:     0x7f5bb1c4cb0b - rustc_mir_build[cdfc528c5eaf545a]::thir::pattern::check_match::check_match
  29:     0x7f5bb1c4c79b - rustc_query_impl[4060c40254611f86]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4060c40254611f86]::query_impl::check_match::dynamic_query::{closure#2}::{closure#0}, rustc_middle[414b3e7bcdf520cb]::query::erase::Erased<[u8; 1usize]>>
  30:     0x7f5bb20a19af - rustc_query_system[87657291faf7369e]::query::plumbing::try_execute_query::<rustc_query_impl[4060c40254611f86]::DynamicConfig<rustc_data_structures[d2846361f834d381]::vec_cache::VecCache<rustc_span[8f290dc910631f84]::def_id::LocalDefId, rustc_middle[414b3e7bcdf520cb]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[87657291faf7369e]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[4060c40254611f86]::plumbing::QueryCtxt, false>
  31:     0x7f5bb20a167d - rustc_query_impl[4060c40254611f86]::query_impl::check_match::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f5bb1bb1f66 - rustc_mir_build[cdfc528c5eaf545a]::builder::build_mir
  33:     0x7f5bb18093b7 - rustc_mir_transform[9fac9653c45deb52]::mir_built
  34:     0x7f5bb1809319 - rustc_query_impl[4060c40254611f86]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4060c40254611f86]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[414b3e7bcdf520cb]::query::erase::Erased<[u8; 8usize]>>
  35:     0x7f5bb19e6ff7 - rustc_query_system[87657291faf7369e]::query::plumbing::try_execute_query::<rustc_query_impl[4060c40254611f86]::DynamicConfig<rustc_data_structures[d2846361f834d381]::vec_cache::VecCache<rustc_span[8f290dc910631f84]::def_id::LocalDefId, rustc_middle[414b3e7bcdf520cb]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[87657291faf7369e]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[4060c40254611f86]::plumbing::QueryCtxt, false>
  36:     0x7f5bb19e6a49 - rustc_query_impl[4060c40254611f86]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f5bb19e276d - rustc_mir_build[cdfc528c5eaf545a]::check_unsafety::check_unsafety
  38:     0x7f5bb19e24e3 - rustc_query_impl[4060c40254611f86]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4060c40254611f86]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[414b3e7bcdf520cb]::query::erase::Erased<[u8; 0usize]>>
  39:     0x7f5bb19e117f - rustc_query_system[87657291faf7369e]::query::plumbing::try_execute_query::<rustc_query_impl[4060c40254611f86]::DynamicConfig<rustc_data_structures[d2846361f834d381]::vec_cache::VecCache<rustc_span[8f290dc910631f84]::def_id::LocalDefId, rustc_middle[414b3e7bcdf520cb]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[87657291faf7369e]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[4060c40254611f86]::plumbing::QueryCtxt, false>
  40:     0x7f5bb19e0efd - rustc_query_impl[4060c40254611f86]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7f5bb19dffe6 - <rustc_middle[414b3e7bcdf520cb]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[7a81ce6675ad65a1]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
  42:     0x7f5bb19dd969 - rustc_interface[7a81ce6675ad65a1]::passes::analysis
  43:     0x7f5bb19dcdf5 - rustc_query_impl[4060c40254611f86]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[4060c40254611f86]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[414b3e7bcdf520cb]::query::erase::Erased<[u8; 0usize]>>
  44:     0x7f5bb28b634e - rustc_query_system[87657291faf7369e]::query::plumbing::try_execute_query::<rustc_query_impl[4060c40254611f86]::DynamicConfig<rustc_query_system[87657291faf7369e]::query::caches::SingleCache<rustc_middle[414b3e7bcdf520cb]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[4060c40254611f86]::plumbing::QueryCtxt, false>
  45:     0x7f5bb28b5f86 - rustc_query_impl[4060c40254611f86]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  46:     0x7f5bb2ab9c0a - <rustc_interface[7a81ce6675ad65a1]::passes::create_and_enter_global_ctxt<core[6c2537e03a6d3b1]::option::Option<rustc_interface[7a81ce6675ad65a1]::queries::Linker>, rustc_driver_impl[89b7377193a66b58]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[6c2537e03a6d3b1]::ops::function::FnOnce<(&rustc_session[86504acf0e5c5aa0]::session::Session, rustc_middle[414b3e7bcdf520cb]::ty::context::CurrentGcx, alloc[127da13bc8f1b24c]::sync::Arc<rustc_data_structures[d2846361f834d381]::jobserver::Proxy>, &std[6bb7ebd1ee7cfb78]::sync::once_lock::OnceLock<rustc_middle[414b3e7bcdf520cb]::ty::context::GlobalCtxt>, &rustc_data_structures[d2846361f834d381]::sync::worker_local::WorkerLocal<rustc_middle[414b3e7bcdf520cb]::arena::Arena>, &rustc_data_structures[d2846361f834d381]::sync::worker_local::WorkerLocal<rustc_hir[6b2d2cd20d3e6ebb]::Arena>, rustc_driver_impl[89b7377193a66b58]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  47:     0x7f5bb29753df - rustc_interface[7a81ce6675ad65a1]::interface::run_compiler::<(), rustc_driver_impl[89b7377193a66b58]::run_compiler::{closure#0}>::{closure#1}
  48:     0x7f5bb256ca38 - std[6bb7ebd1ee7cfb78]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[7a81ce6675ad65a1]::util::run_in_thread_with_globals<rustc_interface[7a81ce6675ad65a1]::util::run_in_thread_pool_with_globals<rustc_interface[7a81ce6675ad65a1]::interface::run_compiler<(), rustc_driver_impl[89b7377193a66b58]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  49:     0x7f5bb256c708 - <<std[6bb7ebd1ee7cfb78]::thread::Builder>::spawn_unchecked_<rustc_interface[7a81ce6675ad65a1]::util::run_in_thread_with_globals<rustc_interface[7a81ce6675ad65a1]::util::run_in_thread_pool_with_globals<rustc_interface[7a81ce6675ad65a1]::interface::run_compiler<(), rustc_driver_impl[89b7377193a66b58]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[6c2537e03a6d3b1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:     0x7f5bb2b3d36f - std::sys::thread::unix::Thread::new::thread_start::hbb7cc2ea20621a0f
  51:     0x7f5bac0969cb - <unknown>
  52:     0x7f5bac11aa0c - <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.93.0-nightly (adaa83897 2025-10-27) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_match] match-checking `<impl at /tmp/icemaker_global_tempdir.3oNURlDYLjS7/rustc_testrunner_tmpdir_reporting.8U3OHERs9wrR/mvce.rs:4:10: 4:15>::fmt`
#1 [mir_built] building MIR for `<impl at /tmp/icemaker_global_tempdir.3oNURlDYLjS7/rustc_testrunner_tmpdir_reporting.8U3OHERs9wrR/mvce.rs:4:10: 4:15>::fmt`
#2 [check_unsafety] unsafety-checking `<impl at /tmp/icemaker_global_tempdir.3oNURlDYLjS7/rustc_testrunner_tmpdir_reporting.8U3OHERs9wrR/mvce.rs:4:10: 4:15>::fmt`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions