ICE: failed to normalize in `build_adt_ctor` with TAIT
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
#![feature(type_alias_impl_trait)]
use std::marker::PhantomData;
trait Project1 {
type Assoc1;
}
impl<T> Project1 for T {
type Assoc1 = ();
}
trait Project2 {
type Assoc2;
}
impl<T: Project1<Assoc1 = ()>> Project2 for PhantomData<T> {
type Assoc2 = ();
}
type Alias<T> = impl Project2;
fn constrain<T>() -> Alias<T> {
PhantomData::<T>
}
struct AdtConstructor<T: Project1>(<Alias<T> as Project2>::Assoc2);
Here, the hidden type of Alias<T> is PhantomData<T> and normalizing <PhantomData<T> as Project2>::Assoc2 requires PhantomData<T>: Project2, which in turn requires T: Project1<Assoc1 = ()>. This is satisfied by the blanket impl<T> Project1 for T, but due to the T: Project1 bound, we do not normalize <T as Project1>::Assoc1 via the impl and so PhantomData<T>: Project2 does not hold and we get a normalization error.
Meta
rustc --version --verbose:
Build using the Nightly version: 1.86.0-nightly
(2025-02-13 a567209daab72b7ea59e)
Error output
error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:13: Failed to normalize Alias(Projection, AliasTy { args: [Alias(Weak, AliasTy { args: [T/#0], def_id: DefId(0:14 ~ playground[da1e]::Alias), .. })], def_id: DefId(0:10 ~ playground[da1e]::Project2::Assoc2), .. }) in typing_env=TypingEnv { typing_mode: PostAnalysis, param_env: ParamEnv { caller_bounds: [Binder { value: TraitPredicate(<T as Project1>, polarity:Positive), bound_vars: [] }, Binder { value: TraitPredicate(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }] } }, maybe try to call `try_normalize_erasing_regions` instead
Backtrace
thread 'rustc' panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:169:13:
Box<dyn Any>
stack backtrace:
0: 0x7017b2440480 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hacb3576dbc1be98e
1: 0x7017b2c289bc - core::fmt::write::hc16e8be59a3a9fc5
2: 0x7017b3f30f91 - std::io::Write::write_fmt::h8811cb6436262be0
3: 0x7017b24402e2 - std::sys::backtrace::BacktraceLock::print::h0d789c81c6c2ec20
4: 0x7017b2442762 - std::panicking::default_hook::{{closure}}::h493936f4b23e5565
5: 0x7017b24425ea - std::panicking::default_hook::he1a5dbaa09c20e90
6: 0x7017b15a7f79 - std[d810b76c7c5d023f]::panicking::update_hook::<alloc[c651bf31249c3228]::boxed::Box<rustc_driver_impl[d81ea691c08f90cf]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7017b24432e3 - std::panicking::rust_panic_with_hook::hfbf782e335191cee
8: 0x7017b15e2e21 - std[d810b76c7c5d023f]::panicking::begin_panic::<rustc_errors[d9109ad345debeea]::ExplicitBug>::{closure#0}
9: 0x7017b15d7d96 - std[d810b76c7c5d023f]::sys::backtrace::__rust_end_short_backtrace::<std[d810b76c7c5d023f]::panicking::begin_panic<rustc_errors[d9109ad345debeea]::ExplicitBug>::{closure#0}, !>
10: 0x7017b15d7d7d - std[d810b76c7c5d023f]::panicking::begin_panic::<rustc_errors[d9109ad345debeea]::ExplicitBug>
11: 0x7017b15ecdf1 - <rustc_errors[d9109ad345debeea]::diagnostic::BugAbort as rustc_errors[d9109ad345debeea]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x7017b1bc3bd3 - rustc_middle[4cc25c41f6c964b6]::util::bug::opt_span_bug_fmt::<rustc_span[b2d7632da7a4062]::span_encoding::Span>::{closure#0}
13: 0x7017b1baca1a - rustc_middle[4cc25c41f6c964b6]::ty::context::tls::with_opt::<rustc_middle[4cc25c41f6c964b6]::util::bug::opt_span_bug_fmt<rustc_span[b2d7632da7a4062]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x7017b1bac8ab - rustc_middle[4cc25c41f6c964b6]::ty::context::tls::with_context_opt::<rustc_middle[4cc25c41f6c964b6]::ty::context::tls::with_opt<rustc_middle[4cc25c41f6c964b6]::util::bug::opt_span_bug_fmt<rustc_span[b2d7632da7a4062]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x7017af908d20 - rustc_middle[4cc25c41f6c964b6]::util::bug::bug_fmt
16: 0x7017b3073998 - <rustc_middle[4cc25c41f6c964b6]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[ef0ec1dfcf4e1bc9]::fold::TypeFolder<rustc_middle[4cc25c41f6c964b6]::ty::context::TyCtxt>>::fold_ty
17: 0x7017b356c3c3 - rustc_mir_transform[15a268890479543d]::shim::build_adt_ctor
18: 0x7017b3235286 - rustc_mir_transform[15a268890479543d]::optimized_mir
19: 0x7017b3234a0d - rustc_query_impl[9cdc7c18babae614]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9cdc7c18babae614]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4cc25c41f6c964b6]::query::erase::Erased<[u8; 8usize]>>
20: 0x7017b2e6ee4c - rustc_query_system[40979d04b54c932c]::query::plumbing::try_execute_query::<rustc_query_impl[9cdc7c18babae614]::DynamicConfig<rustc_query_system[40979d04b54c932c]::query::caches::DefIdCache<rustc_middle[4cc25c41f6c964b6]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[9cdc7c18babae614]::plumbing::QueryCtxt, false>
21: 0x7017b2e6e25f - rustc_query_impl[9cdc7c18babae614]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
22: 0x7017b37d0b69 - rustc_middle[4cc25c41f6c964b6]::query::plumbing::query_get_at::<rustc_query_system[40979d04b54c932c]::query::caches::DefIdCache<rustc_middle[4cc25c41f6c964b6]::query::erase::Erased<[u8; 8usize]>>>
23: 0x7017b37d7f2a - <rustc_metadata[b4caab51ca970add]::rmeta::encoder::EncodeContext>::encode_crate_root
24: 0x7017b3c0450e - rustc_metadata[b4caab51ca970add]::rmeta::encoder::encode_metadata
25: 0x7017b3c125bc - rustc_metadata[b4caab51ca970add]::fs::encode_and_write_metadata
26: 0x7017b3c1148e - <rustc_interface[1654fa466b78c029]::queries::Linker>::codegen_and_build_linker
27: 0x7017b3c07ddd - rustc_interface[1654fa466b78c029]::passes::create_and_enter_global_ctxt::<core[79df64e2219b6595]::option::Option<rustc_interface[1654fa466b78c029]::queries::Linker>, rustc_driver_impl[d81ea691c08f90cf]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
28: 0x7017b3b578a6 - rustc_interface[1654fa466b78c029]::interface::run_compiler::<(), rustc_driver_impl[d81ea691c08f90cf]::run_compiler::{closure#0}>::{closure#1}
29: 0x7017b3ac8cc4 - std[d810b76c7c5d023f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1654fa466b78c029]::util::run_in_thread_with_globals<rustc_interface[1654fa466b78c029]::util::run_in_thread_pool_with_globals<rustc_interface[1654fa466b78c029]::interface::run_compiler<(), rustc_driver_impl[d81ea691c08f90cf]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
30: 0x7017b3ac8999 - <<std[d810b76c7c5d023f]::thread::Builder>::spawn_unchecked_<rustc_interface[1654fa466b78c029]::util::run_in_thread_with_globals<rustc_interface[1654fa466b78c029]::util::run_in_thread_pool_with_globals<rustc_interface[1654fa466b78c029]::interface::run_compiler<(), rustc_driver_impl[d81ea691c08f90cf]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[79df64e2219b6595]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
31: 0x7017b3ac812f - std::sys::pal::unix::thread::Thread::new::thread_start::ha84bd1be5e559000
32: 0x7017b51dfa94 - <unknown>
33: 0x7017b526ca34 - clone
34: 0x0 - <unknown>
Caused by this normalize call here: https://github.com/rust-lang/rust/blob/d8810e3e2dab96778d20dd6d746ff95465515509/compiler/rustc_mir_transform/src/shim.rs#L978
@rustbot label F-type_alias_impl_trait
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the linked playground reproducer with the nightly toolchain, then inspect compiler/rustc_mir_transform/src/shim.rs around line 978 and the build_adt_ctor entry shown in the backtrace. Done means the TAIT example no longer triggers an internal compiler error or normalization failure, with regression coverage for the reproducer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100