Skip to content

ICE: Failed to normalize Alias(Free, AliasTy { #141380

Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Trait<T> {}
type Alias<P: Trait> = impl Trait<U>;

pub enum UninhabitedVariants {
    Tuple(Alias),
}

fn uwu(x: UninhabitedVariants) {
    match x {}
}

original:

// regression test for #127353

#![feature(WithEmplacableForFn)]
trait Trait<T> {}
type Alias<P: Trait> = impl Trait<U>;

pub enum UninhabitedVariants {
    Tuple(Alias),
    //~^ ERROR missing lifetime specifier
    //~| ERROR missing generics
}

#[define_opaque(Alias)]
fn uwu(x: UninhabitedVariants) {
    match x {}
    //~^ ERROR non-exhaustive patterns
}

fn main() {}

Version information

rustc 1.89.0-nightly (5df0f729f 2025-05-21)
binary: rustc
commit-hash: 5df0f729f5355cb3cd91f6bcff13566ae96dc220
commit-date: 2025-05-21
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

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[E0412]: cannot find type `U` in this scope
 --> /tmp/icemaker_global_tempdir.xe1wnEfpxqbR/rustc_testrunner_tmpdir_reporting.uicvEyZQMqkA/mvce.rs:2:35
  |
2 | type Alias<P: Trait> = impl Trait<U>;
  |            -                      ^ help: a type parameter with a similar name exists: `P`
  |            |
  |            similarly named type parameter `P` defined here

error[E0658]: `impl Trait` in type aliases is unstable
 --> /tmp/icemaker_global_tempdir.xe1wnEfpxqbR/rustc_testrunner_tmpdir_reporting.uicvEyZQMqkA/mvce.rs:2:24
  |
2 | type Alias<P: Trait> = impl Trait<U>;
  |                        ^^^^^^^^^^^^^
  |
  = 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 2025-05-21; consider upgrading it if it is out of date

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.xe1wnEfpxqbR/rustc_testrunner_tmpdir_reporting.uicvEyZQMqkA/mvce.rs:10:2
   |
10 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.xe1wnEfpxqbR/rustc_testrunner_tmpdir_reporting.uicvEyZQMqkA/mvce.rs`

error[E0107]: missing generics for trait `Trait`
 --> /tmp/icemaker_global_tempdir.xe1wnEfpxqbR/rustc_testrunner_tmpdir_reporting.uicvEyZQMqkA/mvce.rs:2:15
  |
2 | type Alias<P: Trait> = impl Trait<U>;
  |               ^^^^^ expected 1 generic argument
  |
note: trait defined here, with 1 generic parameter: `T`
 --> /tmp/icemaker_global_tempdir.xe1wnEfpxqbR/rustc_testrunner_tmpdir_reporting.uicvEyZQMqkA/mvce.rs:1:7
  |
1 | trait Trait<T> {}
  |       ^^^^^ -
help: add missing generic argument
  |
2 | type Alias<P: Trait<T>> = impl Trait<U>;
  |                    +++

error[E0107]: missing generics for type alias `Alias`
 --> /tmp/icemaker_global_tempdir.xe1wnEfpxqbR/rustc_testrunner_tmpdir_reporting.uicvEyZQMqkA/mvce.rs:5:11
  |
5 |     Tuple(Alias),
  |           ^^^^^ expected 1 generic argument
  |
note: type alias defined here, with 1 generic parameter: `P`
 --> /tmp/icemaker_global_tempdir.xe1wnEfpxqbR/rustc_testrunner_tmpdir_reporting.uicvEyZQMqkA/mvce.rs:2:6
  |
2 | type Alias<P: Trait> = impl Trait<U>;
  |      ^^^^^ -
help: add missing generic argument
  |
5 |     Tuple(Alias<P>),
  |                +++

error: unconstrained opaque type
 --> /tmp/icemaker_global_tempdir.xe1wnEfpxqbR/rustc_testrunner_tmpdir_reporting.uicvEyZQMqkA/mvce.rs:2:24
  |
2 | type Alias<P: Trait> = impl Trait<U>;
  |                        ^^^^^^^^^^^^^
  |
  = note: `Alias` must be used in combination with a concrete type within the same crate

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:171:13: Failed to normalize Alias(Free, AliasTy { args: [{type error}], def_id: DefId(0:5 ~ mvce[5ed8]::Alias), .. }) in typing_env=TypingEnv { typing_mode: Analysis { defining_opaque_types_and_generators: [] }, param_env: ParamEnv { caller_bounds: [] } }, maybe try to call `try_normalize_erasing_regions` instead


thread 'rustc' panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:171:13:
Box<dyn Any>
stack backtrace:
   0:     0x785763574943 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hc8215a9c66aef2ea
   1:     0x785763c05a77 - core::fmt::write::h3f8319699ee957ae
   2:     0x78576507c8d1 - std::io::Write::write_fmt::h7f7ae6e4cf0613ba
   3:     0x7857635747a2 - std::sys::backtrace::BacktraceLock::print::h772c5bb915649b23
   4:     0x78576357839a - std::panicking::default_hook::{{closure}}::h5a4bb9d04f4fb636
   5:     0x785763577f1f - std::panicking::default_hook::h7a3399257665eec0
   6:     0x7857625a0003 - std[87abf682fc70726]::panicking::update_hook::<alloc[be5c6767dc16e40]::boxed::Box<rustc_driver_impl[67fa6dff91713239]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x785763578c13 - std::panicking::rust_panic_with_hook::h1d16204f4298f006
   8:     0x7857625dc471 - std[87abf682fc70726]::panicking::begin_panic::<rustc_errors[c4c2187cf855cad6]::ExplicitBug>::{closure#0}
   9:     0x7857625d04a6 - std[87abf682fc70726]::sys::backtrace::__rust_end_short_backtrace::<std[87abf682fc70726]::panicking::begin_panic<rustc_errors[c4c2187cf855cad6]::ExplicitBug>::{closure#0}, !>
  10:     0x7857625d0333 - std[87abf682fc70726]::panicking::begin_panic::<rustc_errors[c4c2187cf855cad6]::ExplicitBug>
  11:     0x7857625e6be1 - <rustc_errors[c4c2187cf855cad6]::diagnostic::BugAbort as rustc_errors[c4c2187cf855cad6]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x785762c5611a - rustc_middle[361c9b966945ad5f]::util::bug::opt_span_bug_fmt::<rustc_span[644369ff50095af5]::span_encoding::Span>::{closure#0}
  13:     0x785762c2f67a - rustc_middle[361c9b966945ad5f]::ty::context::tls::with_opt::<rustc_middle[361c9b966945ad5f]::util::bug::opt_span_bug_fmt<rustc_span[644369ff50095af5]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x785762c2f4eb - rustc_middle[361c9b966945ad5f]::ty::context::tls::with_context_opt::<rustc_middle[361c9b966945ad5f]::ty::context::tls::with_opt<rustc_middle[361c9b966945ad5f]::util::bug::opt_span_bug_fmt<rustc_span[644369ff50095af5]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x78575fe8a2b0 - rustc_middle[361c9b966945ad5f]::util::bug::bug_fmt
  16:     0x78576440cc58 - <rustc_middle[361c9b966945ad5f]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[a70c36853e4e3da4]::fold::TypeFolder<rustc_middle[361c9b966945ad5f]::ty::context::TyCtxt>>::fold_ty
  17:     0x785764c3a8bb - <rustc_pattern_analysis[1ef3719a35dbe2f]::rustc::RustcPatCtxt as rustc_pattern_analysis[1ef3719a35dbe2f]::PatCx>::ctor_sub_tys
  18:     0x785764c3a0fb - <rustc_pattern_analysis[1ef3719a35dbe2f]::pat::WitnessPat<rustc_pattern_analysis[1ef3719a35dbe2f]::rustc::RustcPatCtxt>>::wild_from_ctor
  19:     0x785763ff7eea - <rustc_pattern_analysis[1ef3719a35dbe2f]::usefulness::WitnessMatrix<rustc_pattern_analysis[1ef3719a35dbe2f]::rustc::RustcPatCtxt>>::apply_constructor
  20:     0x785763ffaa95 - rustc_pattern_analysis[1ef3719a35dbe2f]::usefulness::compute_exhaustiveness_and_usefulness::<rustc_pattern_analysis[1ef3719a35dbe2f]::rustc::RustcPatCtxt>::{closure#0}
  21:     0x7857640a6782 - rustc_pattern_analysis[1ef3719a35dbe2f]::rustc::analyze_match
  22:     0x78576444322d - <rustc_mir_build[e66f7be2fd208f8d]::thir::pattern::check_match::MatchVisitor as rustc_middle[361c9b966945ad5f]::thir::visit::Visitor>::visit_expr
  23:     0x7857644437af - <rustc_mir_build[e66f7be2fd208f8d]::thir::pattern::check_match::MatchVisitor as rustc_middle[361c9b966945ad5f]::thir::visit::Visitor>::visit_expr
  24:     0x785764442e0d - <rustc_mir_build[e66f7be2fd208f8d]::thir::pattern::check_match::MatchVisitor as rustc_middle[361c9b966945ad5f]::thir::visit::Visitor>::visit_expr
  25:     0x7857644437af - <rustc_mir_build[e66f7be2fd208f8d]::thir::pattern::check_match::MatchVisitor as rustc_middle[361c9b966945ad5f]::thir::visit::Visitor>::visit_expr
  26:     0x785764442e0d - <rustc_mir_build[e66f7be2fd208f8d]::thir::pattern::check_match::MatchVisitor as rustc_middle[361c9b966945ad5f]::thir::visit::Visitor>::visit_expr
  27:     0x785764445c70 - rustc_mir_build[e66f7be2fd208f8d]::thir::pattern::check_match::check_match
  28:     0x78576444589b - rustc_query_impl[6163178075f45bcf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6163178075f45bcf]::query_impl::check_match::dynamic_query::{closure#2}::{closure#0}, rustc_middle[361c9b966945ad5f]::query::erase::Erased<[u8; 1usize]>>
  29:     0x785764467825 - rustc_query_system[c023df386c88c8e7]::query::plumbing::try_execute_query::<rustc_query_impl[6163178075f45bcf]::DynamicConfig<rustc_data_structures[79350e7213dd8471]::vec_cache::VecCache<rustc_span[644369ff50095af5]::def_id::LocalDefId, rustc_middle[361c9b966945ad5f]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[c023df386c88c8e7]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[6163178075f45bcf]::plumbing::QueryCtxt, false>
  30:     0x785764467461 - rustc_query_impl[6163178075f45bcf]::query_impl::check_match::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7857640140ca - rustc_mir_build[e66f7be2fd208f8d]::builder::build_mir
  32:     0x785763c09db5 - rustc_mir_transform[4cfe12e99b605988]::mir_built
  33:     0x785763c09d87 - rustc_query_impl[6163178075f45bcf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6163178075f45bcf]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[361c9b966945ad5f]::query::erase::Erased<[u8; 8usize]>>
  34:     0x785763dca3a6 - rustc_query_system[c023df386c88c8e7]::query::plumbing::try_execute_query::<rustc_query_impl[6163178075f45bcf]::DynamicConfig<rustc_data_structures[79350e7213dd8471]::vec_cache::VecCache<rustc_span[644369ff50095af5]::def_id::LocalDefId, rustc_middle[361c9b966945ad5f]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[c023df386c88c8e7]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[6163178075f45bcf]::plumbing::QueryCtxt, false>
  35:     0x785763dc9ed2 - rustc_query_impl[6163178075f45bcf]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  36:     0x785764578b43 - rustc_mir_build[e66f7be2fd208f8d]::check_unsafety::check_unsafety
  37:     0x785764578937 - rustc_query_impl[6163178075f45bcf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6163178075f45bcf]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[361c9b966945ad5f]::query::erase::Erased<[u8; 0usize]>>
  38:     0x785764577f45 - rustc_query_system[c023df386c88c8e7]::query::plumbing::try_execute_query::<rustc_query_impl[6163178075f45bcf]::DynamicConfig<rustc_data_structures[79350e7213dd8471]::vec_cache::VecCache<rustc_span[644369ff50095af5]::def_id::LocalDefId, rustc_middle[361c9b966945ad5f]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[c023df386c88c8e7]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[6163178075f45bcf]::plumbing::QueryCtxt, false>
  39:     0x785764577c13 - rustc_query_impl[6163178075f45bcf]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  40:     0x785763dc8888 - <rustc_middle[361c9b966945ad5f]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[77530f27f9e4bbc4]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  41:     0x785763dc6bb2 - rustc_interface[77530f27f9e4bbc4]::passes::run_required_analyses
  42:     0x785764b0ca9e - rustc_interface[77530f27f9e4bbc4]::passes::analysis
  43:     0x785764b0ca75 - rustc_query_impl[6163178075f45bcf]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6163178075f45bcf]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[361c9b966945ad5f]::query::erase::Erased<[u8; 0usize]>>
  44:     0x785764b0eb7a - rustc_query_system[c023df386c88c8e7]::query::plumbing::try_execute_query::<rustc_query_impl[6163178075f45bcf]::DynamicConfig<rustc_query_system[c023df386c88c8e7]::query::caches::SingleCache<rustc_middle[361c9b966945ad5f]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[6163178075f45bcf]::plumbing::QueryCtxt, false>
  45:     0x785764b0e84f - rustc_query_impl[6163178075f45bcf]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  46:     0x785764d5cd87 - rustc_interface[77530f27f9e4bbc4]::passes::create_and_enter_global_ctxt::<core[5f9a00d7f27d7732]::option::Option<rustc_interface[77530f27f9e4bbc4]::queries::Linker>, rustc_driver_impl[67fa6dff91713239]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  47:     0x785764c9d14f - rustc_interface[77530f27f9e4bbc4]::interface::run_compiler::<(), rustc_driver_impl[67fa6dff91713239]::run_compiler::{closure#0}>::{closure#1}
  48:     0x785764c57246 - std[87abf682fc70726]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[77530f27f9e4bbc4]::util::run_in_thread_with_globals<rustc_interface[77530f27f9e4bbc4]::util::run_in_thread_pool_with_globals<rustc_interface[77530f27f9e4bbc4]::interface::run_compiler<(), rustc_driver_impl[67fa6dff91713239]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  49:     0x785764c56eeb - <<std[87abf682fc70726]::thread::Builder>::spawn_unchecked_<rustc_interface[77530f27f9e4bbc4]::util::run_in_thread_with_globals<rustc_interface[77530f27f9e4bbc4]::util::run_in_thread_pool_with_globals<rustc_interface[77530f27f9e4bbc4]::interface::run_compiler<(), rustc_driver_impl[67fa6dff91713239]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[5f9a00d7f27d7732]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:     0x785764c589fd - std::sys::pal::unix::thread::Thread::new::thread_start::hcb0cd5abf7f32abf
  51:     0x78575eaa57eb - <unknown>
  52:     0x78575eb2918c - <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.89.0-nightly (5df0f729f 2025-05-21) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_match] match-checking `uwu`
#1 [mir_built] building MIR for `uwu`
#2 [check_unsafety] unsafety-checking `uwu`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 7 previous errors

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

@rustbot label +F-WithEmplacableForFn

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