Skip to content

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

Open
@sososopy

Description

@sososopy

The code is generated by a fuzzer and reduced manually
Possibly a duplicate of #140303

Code

#![feature(type_alias_impl_trait)]
use std::hint::black_box;
trait Func {
    type Ret: Id;
}
trait Id {
    type Assoc;
}
impl Id for u32 {
    type Assoc = u32;
}
impl Id for i32 {
    type Assoc = i32;
}
impl<F: FnOnce() -> R, R: Id> Func for F {
    type Ret = R;
}
fn bar() -> MyIter {
    032
}
type MyIter = impl Copy + Id;
struct Foo<T: Func> {
    _func: T,
    value: Option<<<T as Func>::Ret as Id>::Assoc>,
}
fn main() {
    let mut fn_def = black_box(Foo {
        _func: bar,
        value: None,
    });
}

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (5526a2f47 2025-06-20)
binary: rustc
commit-hash: 5526a2f47cd676ceeedc08cf71ae75ce2e9284ae
commit-date: 2025-06-20
host: x86_64-pc-windows-msvc
release: 1.89.0-nightly
LLVM version: 20.1.7

Error output

error: unconstrained opaque type
  --> .\test.rs:21:15
   |
21 | type MyIter = impl Copy + Id;
   |               ^^^^^^^^^^^^^^
   |
   = note: `MyIter` must be used in combination with a concrete type within the same crate

error[E0308]: mismatched types
  --> .\test.rs:19:5
   |
18 | fn bar() -> MyIter {
   |             ------ expected `MyIter` because of return type
19 |     032
   |     ^^^ expected opaque type, found integer
20 | }
21 | type MyIter = impl Copy + Id;
   |               -------------- the expected opaque type
   |
   = note: expected opaque type `MyIter`
                     found type `{integer}`
note: this item must have a `#[define_opaque(MyIter)]` attribute to be able to define hidden types
  --> .\test.rs:18:4
   |
18 | fn bar() -> MyIter {
   |    ^^^

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: [Alias(Projection, AliasTy { args: [FnDef(DefId(0:16 ~ 
test[1c23]::bar), [])], def_id: DefId(0:5 ~ test[1c23]::Func::Ret), .. })], def_id: DefId(0:7 ~ test[1c23]::Id::Assoc), .. })> in 
typing_env=TypingEnv { typing_mode: PostAnalysis, param_env: ParamEnv { caller_bounds: [] } }, maybe try to call 
`try_normalize_erasing_regions` instead
Backtrace

thread 'rustc' panicked at compiler\rustc_middle\src\ty\normalize_erasing_regions.rs:171:13:
Box<dyn Any>
stack backtrace:
   0:     0x7ffa956a5cc2 - std::backtrace_rs::backtrace::win64::trace
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
   1:     0x7ffa956a5cc2 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffa956a5cc2 - std::sys::backtrace::_print_fmt
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\std\src\sys\backtrace.rs:66
   3:     0x7ffa956a5cc2 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\std\src\sys\backtrace.rs:39
   4:     0x7ffa956d89db - core::fmt::rt::Argument::fmt
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\core\src\fmt\rt.rs:173
   5:     0x7ffa956d89db - core::fmt::write
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\core\src\fmt\mod.rs:1460
   6:     0x7ffa9569ba27 - std::io::default_write_fmt
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\std\src\io\mod.rs:639
   7:     0x7ffa9569ba27 - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\std\src\io\mod.rs:1954
   8:     0x7ffa956a5b05 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\std\src\sys\backtrace.rs:42
   9:     0x7ffa956ab80a - std::panicking::default_hook::closure$0
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\std\src\panicking.rs:300
  10:     0x7ffa956ab5a0 - std::panicking::default_hook
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\std\src\panicking.rs:327
  11:     0x7ffa96e5af95 - core[ea54fb714d0d9ca7]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[745e8a0447f460db]::Level, &str), usize), <((rustc_lint_defs[745e8a0447f460db]::Level, &str), usize) as core[ea54fb714d0d9ca7]::cmp::PartialOrd>::lt>
  12:     0x7ffa956ac45c - std::panicking::rust_panic_with_hook
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\std\src\panicking.rs:841
  13:     0x7ffa9862a5b3 - RINvNtNtNtNtCsk7lixFzhFdj_4core5slice4sort6stable9quicksort9quicksortTjRNtNtCsc5729v0axqf_12rustc_errors7snippet10AnnotationENCINvMNtCs8twqms2kZVh_5alloc5sliceSB15_11sort_by_keyTINtNtBa_3cmp7ReversejEbENCNCNvMs5_NtB1c_7emitterNtB3o_12HumanEmitter18render_s
  14:     0x7ffa9861e699 - std[fdcb23eab682426c]::sys::backtrace::__rust_end_short_backtrace::<std[fdcb23eab682426c]::panicking::begin_panic<rustc_errors[8cbb6869231859f1]::ExplicitBug>::{closure#0}, !>
  15:     0x7ffa9861e581 - std[fdcb23eab682426c]::panicking::begin_panic::<rustc_errors[8cbb6869231859f1]::ExplicitBug>
  16:     0x7ffa98637045 - <rustc_errors[8cbb6869231859f1]::diagnostic::BugAbort as rustc_errors[8cbb6869231859f1]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  17:     0x7ffa98580379 - rustc_middle[46c07d95ef3dd2bb]::util::bug::span_bug_fmt::<rustc_span[f25b9a1d3de582b9]::span_encoding::Span>
  18:     0x7ffa985576fd - <rustc_middle[46c07d95ef3dd2bb]::ty::consts::Const>::walk
  19:     0x7ffa985574c6 - <rustc_middle[46c07d95ef3dd2bb]::ty::consts::Const>::walk
  20:     0x7ffa98580272 - rustc_middle[46c07d95ef3dd2bb]::util::bug::bug_fmt
  21:     0x7ffa96cba4be - <rustc_middle[46c07d95ef3dd2bb]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[b5d858062a50f1e5]::fold::TypeFolder<rustc_middle[46c07d95ef3dd2bb]::ty::context::TyCtxt>>::fold_ty
  22:     0x7ffa95cb83f5 - <rustc_mir_transform[b4353750b5cbd299]::validate::Validator as rustc_mir_transform[b4353750b5cbd299]::pass_manager::MirPass>::run_pass 
  23:     0x7ffa95cae903 - <rustc_mir_transform[b4353750b5cbd299]::validate::Validator as rustc_mir_transform[b4353750b5cbd299]::pass_manager::MirPass>::run_pass
  24:     0x7ffa974c4df7 - <rustc_mir_transform[b4353750b5cbd299]::post_drop_elaboration::CheckLiveDrops as rustc_mir_transform[b4353750b5cbd299]::pass_manager::MirLint>::run_lint
  25:     0x7ffa95be18fe - rustc_mir_transform[b4353750b5cbd299]::run_analysis_to_runtime_passes
  26:     0x7ffa95bdc2e1 - rustc_mir_transform[b4353750b5cbd299]::mir_drops_elaborated_and_const_checked
  27:     0x7ffa965e8b2b - rustc_query_impl[d8aa46a2dbba62c8]::plumbing::query_key_hash_verify_all
  28:     0x7ffa9652f2ae - RINvNtNtCskoNuHGR6BxK_18rustc_query_system5query8plumbing17try_execute_queryINtCsiBiOuvHcJFQ_16rustc_query_impl13DynamicConfigINtNtCsgz2Qsm2zsYx_21rustc_data_structures9vec_cache8VecCacheNtNtCskO41P7xScQL_10rustc_span6def_id10LocalDefIdINtNtNtCs64BRSp7mVxT
  29:     0x7ffa965ec412 - rustc_query_impl[d8aa46a2dbba62c8]::plumbing::query_key_hash_verify_all
  30:     0x7ffa95714b48 - rustc_interface[43d1a295db27a373]::passes::analysis
  31:     0x7ffa952572fa - <alloc[62ba2eed246bf855]::raw_vec::RawVec<rustc_errors[8cbb6869231859f1]::SubstitutionHighlight>>::grow_one
  32:     0x7ffa9515cf9a - RINvNtNtCskoNuHGR6BxK_18rustc_query_system5query8plumbing17try_execute_queryINtCsiBiOuvHcJFQ_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCs64BRSp7mVxT_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  33:     0x7ffa9525d6f3 - rustc_query_impl[d8aa46a2dbba62c8]::query_system
  34:     0x7ffa91ba8440 - std[fdcb23eab682426c]::sys::backtrace::__rust_begin_short_backtrace::<<std[fdcb23eab682426c]::thread::Builder>::spawn_unchecked_<ctrlc[9cb8e1be167e9585]::set_handler_inner<rustc_driver_impl[6221a2fc7aac45a2]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  35:     0x7ffa91ba2aa6 - std[fdcb23eab682426c]::sys::backtrace::__rust_begin_short_backtrace::<<std[fdcb23eab682426c]::thread::Builder>::spawn_unchecked_<ctrlc[9cb8e1be167e9585]::set_handler_inner<rustc_driver_impl[6221a2fc7aac45a2]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  36:     0x7ffa91b9eb7f - RINvNtNtCslMW5zL9tQPU_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCs5OZTDuE54qZ_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCs8qlLDMR7YdO_17rustc_driver_i
  37:     0x7ffa91bac7bd - std[fdcb23eab682426c]::sys::backtrace::__rust_begin_short_backtrace::<<std[fdcb23eab682426c]::thread::Builder>::spawn_unchecked_<ctrlc[9cb8e1be167e9585]::set_handler_inner<rustc_driver_impl[6221a2fc7aac45a2]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  38:     0x7ffa956b002d - alloc::boxed::impl$28::call_once
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\alloc\src\boxed.rs:1966
  39:     0x7ffa956b002d - alloc::boxed::impl$28::call_once
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\alloc\src\boxed.rs:1966
  40:     0x7ffa956b002d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/5526a2f47cd676ceeedc08cf71ae75ce2e9284ae/library\std\src\sys\pal\windows\thread.rs:56
  41:     0x7ffaf3447374 - BaseThreadInitThunk
  42:     0x7ffaf503cc91 - RtlUserThreadStart

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: compiler flags: -Z validate-mir

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#1 [analysis] running analysis passes on this crate
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions