ICE: `Failed to normalize Alias(Projection, ..`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
auto-reduced (treereduce-rust):
//@compile-flags: -Zvalidate-mir -Znext-solver=globally
mod defining_scope {
use super::*;
pub type Alias<T> = impl Sized;
pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> {
x
}
}
struct Container<T: Trait<U>, U> {
x: <T as Trait<U>>::Assoc,
}
trait Trait<T> {
type Assoc;
}
impl<T> Trait<T> for T {
type Assoc = Box<u32>;
}
impl<T> Trait<T> for defining_scope::Alias<T> {
type Assoc = usize;
}
fn main() {
let x: Box<u32> = defining_scope::cast::<()>(Container { x: 0 }).x;
}
original:
// Regression test for #137287
mod defining_scope {
use super::*;
pub type Alias<T> = impl Sized;
//~^ ERROR unconstrained opaque type
//~| ERROR `impl Trait` in type aliases is unstable
pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> {
x
//~^ ERROR mismatched types
}
}
struct Container<T: Trait<U>, U> {
x: <T as Trait<U>>::Assoc,
}
trait Trait<T> {
type Assoc;
}
impl<T> Trait<T> for T {
type Assoc = Box<u32>;
}
impl<T> Trait<T> for defining_scope::Alias<T> {
//~^ ERROR conflicting implementations of trait `Trait<_>`
type Assoc = usize;
}
fn main() {
let x: Box<u32> = defining_scope::cast::<()>(Container { x: 0 }).x;
}
Version information
rustc 1.95.0-nightly (621d76794 2026-01-18)
binary: rustc
commit-hash: 621d76794c76fc21c0a6151fbc090120e0230a91
commit-date: 2026-01-18
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8
Possibly related line of code:
https://github.com/rust-lang/rust/blob/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs#L165-L177
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zvalidate-mir -Znext-solver=globally
Program output
error[E0658]: `impl Trait` in type aliases is unstable
--> /tmp/icemaker_global_tempdir.KcBzPm9Try5v/rustc_testrunner_tmpdir_reporting.Tf2RSRvyyp2v/mvce.rs:3:25
|
3 | pub type Alias<T> = impl Sized;
| ^^^^^^^^^^
|
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
= note: this compiler was built on 2026-01-18; consider upgrading it if it is out of date
error[E0119]: conflicting implementations of trait `Trait<_>`
--> /tmp/icemaker_global_tempdir.KcBzPm9Try5v/rustc_testrunner_tmpdir_reporting.Tf2RSRvyyp2v/mvce.rs:21:1
|
18 | impl<T> Trait<T> for T {
| ---------------------- first implementation here
...
21 | impl<T> Trait<T> for defining_scope::Alias<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
error: unconstrained opaque type
--> /tmp/icemaker_global_tempdir.KcBzPm9Try5v/rustc_testrunner_tmpdir_reporting.Tf2RSRvyyp2v/mvce.rs:3:25
|
3 | pub type Alias<T> = impl Sized;
| ^^^^^^^^^^
|
= note: `Alias` must be used in combination with a concrete type within the same crate
error[E0308]: mismatched types
--> /tmp/icemaker_global_tempdir.KcBzPm9Try5v/rustc_testrunner_tmpdir_reporting.Tf2RSRvyyp2v/mvce.rs:6:9
|
3 | pub type Alias<T> = impl Sized;
| ---------- the found opaque type
4 |
5 | pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> {
| --------------- expected `Container<T, T>` because of return type
6 | x
| ^ types differ
|
= note: expected struct `Container<T, _>`
found struct `Container<Alias<T>, _>`
warning: unused variable: `x`
--> /tmp/icemaker_global_tempdir.KcBzPm9Try5v/rustc_testrunner_tmpdir_reporting.Tf2RSRvyyp2v/mvce.rs:26:9
|
26 | let x: Box<u32> = defining_scope::cast::<()>(Container { x: 0 }).x;
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
error: internal compiler error: /rustc-dev/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:171:13: Failed to normalize Alias(Projection, AliasTy { args: [Alias(Opaque, AliasTy { args: [()], def_id: DefId(0:7 ~ mvce[a621]::defining_scope::Alias::{opaque#0}), .. }), ()], def_id: DefId(0:16 ~ mvce[a621]::Trait::Assoc), .. }) in typing_env=TypingEnv { typing_mode: PostAnalysis, param_env: ParamEnv { caller_bounds: [] } }, maybe try to call `try_normalize_erasing_regions` instead
thread 'rustc' (945137) panicked at /rustc-dev/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:171:13:
Box<dyn Any>
stack backtrace:
0: 0x7f393de33fd3 - <<std[287527946f71f0bc]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[7477a31a1a34cc49]::fmt::Display>::fmt
1: 0x7f393e40e2c8 - core[7477a31a1a34cc49]::fmt::write
2: 0x7f393de4a9c6 - <std[287527946f71f0bc]::sys::stdio::unix::Stderr as std[287527946f71f0bc]::io::Write>::write_fmt
3: 0x7f393de0a048 - std[287527946f71f0bc]::panicking::default_hook::{closure#0}
4: 0x7f393de27703 - std[287527946f71f0bc]::panicking::default_hook
5: 0x7f393cdfbb8a - std[287527946f71f0bc]::panicking::update_hook::<alloc[979041e9952e771b]::boxed::Box<rustc_driver_impl[517260a07841a630]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f393de279e2 - std[287527946f71f0bc]::panicking::panic_with_hook
7: 0x7f393ce38bc1 - std[287527946f71f0bc]::panicking::begin_panic::<rustc_errors[26c9ea40265c581b]::ExplicitBug>::{closure#0}
8: 0x7f393ce28fe6 - std[287527946f71f0bc]::sys::backtrace::__rust_end_short_backtrace::<std[287527946f71f0bc]::panicking::begin_panic<rustc_errors[26c9ea40265c581b]::ExplicitBug>::{closure#0}, !>
9: 0x7f393ce264b9 - std[287527946f71f0bc]::panicking::begin_panic::<rustc_errors[26c9ea40265c581b]::ExplicitBug>
10: 0x7f393ce56901 - <rustc_errors[26c9ea40265c581b]::diagnostic::BugAbort as rustc_errors[26c9ea40265c581b]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7f393d4074f9 - rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt::<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}
12: 0x7f393d407682 - rustc_middle[725063e074f29df]::ty::context::tls::with_opt::<rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}, !>::{closure#0}
13: 0x7f393d3f8cab - rustc_middle[725063e074f29df]::ty::context::tls::with_context_opt::<rustc_middle[725063e074f29df]::ty::context::tls::with_opt<rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
14: 0x7f393a891cc4 - rustc_middle[725063e074f29df]::util::bug::bug_fmt
15: 0x7f393e65bf74 - <rustc_middle[725063e074f29df]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[b93cf349b3a4f34d]::fold::TypeFolder<rustc_middle[725063e074f29df]::ty::context::TyCtxt>>::fold_ty
16: 0x7f393efbfa8d - rustc_mir_transform[f63ee9052e691c]::validate::validate_types
17: 0x7f393efb4946 - <rustc_mir_transform[f63ee9052e691c]::validate::Validator as rustc_mir_transform[f63ee9052e691c]::pass_manager::MirPass>::run_pass
18: 0x7f393bb5d7a5 - rustc_mir_transform[f63ee9052e691c]::pass_manager::validate_body
19: 0x7f393e40b494 - rustc_mir_transform[f63ee9052e691c]::run_analysis_to_runtime_passes
20: 0x7f393f1a9e80 - rustc_mir_transform[f63ee9052e691c]::mir_drops_elaborated_and_const_checked
21: 0x7f393f1a9829 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 8usize]>>
22: 0x7f393e55522a - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_data_structures[e0d8483206daafa2]::vec_cache::VecCache<rustc_span[851f35e07e3c2dd4]::def_id::LocalDefId, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[b7e73caa2c2ad9a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
23: 0x7f393e5548cd - rustc_query_impl[f20b8284200e680a]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
24: 0x7f393e54c4ff - <rustc_middle[725063e074f29df]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[5c48368f5debe80d]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
25: 0x7f393e549c0a - rustc_interface[5c48368f5debe80d]::passes::analysis
26: 0x7f393e549035 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>
27: 0x7f393f5a4be3 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::SingleCache<rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
28: 0x7f393f5a49ce - rustc_query_impl[f20b8284200e680a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
29: 0x7f393f782c11 - <rustc_interface[5c48368f5debe80d]::passes::create_and_enter_global_ctxt<core[7477a31a1a34cc49]::option::Option<rustc_interface[5c48368f5debe80d]::queries::Linker>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[7477a31a1a34cc49]::ops::function::FnOnce<(&rustc_session[eb79e6d3104f29ae]::session::Session, rustc_middle[725063e074f29df]::ty::context::CurrentGcx, alloc[979041e9952e771b]::sync::Arc<rustc_data_structures[e0d8483206daafa2]::jobserver::Proxy>, &std[287527946f71f0bc]::sync::once_lock::OnceLock<rustc_middle[725063e074f29df]::ty::context::GlobalCtxt>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_middle[725063e074f29df]::arena::Arena>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_hir[7eac7792dedc1861]::Arena>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
30: 0x7f393f5f5d34 - rustc_interface[5c48368f5debe80d]::interface::run_compiler::<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}
31: 0x7f393f55aa3a - std[287527946f71f0bc]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
32: 0x7f393f55a7fe - <std[287527946f71f0bc]::thread::lifecycle::spawn_unchecked<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7477a31a1a34cc49]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
33: 0x7f393f55c5c4 - <std[287527946f71f0bc]::sys::thread::unix::Thread>::new::thread_start
34: 0x7f3938e9698b - <unknown>
35: 0x7f3938f1a9cc - <unknown>
36: 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.95.0-nightly (621d76794 2026-01-18) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z validate-mir -Z next-solver=globally -Z dump-mir-dir=dir
query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 5 previous errors; 1 warning emitted
Some errors have detailed explanations: E0119, E0308, E0658.
For more information about an error, try `rustc --explain E0119`.
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 reproducing the reduced test in the issue with -Zvalidate-mir -Znext-solver=globally. Trace the ICE from rustc_mir_transform::validate::validate_types into compiler/rustc_middle/src/ty/normalize_erasing_regions.rs, especially the reported normalization failure. Done means the reproducer no longer triggers an internal compiler error and a regression test covers the case.
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
- 35/100