Skip to content

rustc hangs when implementing a trait for a recursive impl Trait type alias #144065

@sososopy

Description

@sososopy

I tried this code:

#![feature(type_alias_impl_trait)]
trait Id {
    type Assoc;
}
impl<T> Id for T {
    type Assoc = T;
}
trait NewTrait {}
impl NewTrait for Ty {}
type Ty
where
    Ty: Id<Assoc = Ty> = impl Sized;
fn main(){}

Meta

rustc --version --verbose:

rustc 1.90.0-nightly (5795086bd 2025-07-16)
binary: rustc
commit-hash: 5795086bdfe7ed988aa53a110bd0692c33d8755b
commit-date: 2025-07-16
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8

-Z time-passes

time:   0.001; rss:   39MB ->   48MB (   +9MB)  expand_crate
time:   0.001; rss:   39MB ->   48MB (   +9MB)  macro_expand_crate
time:   0.000; rss:   48MB ->   50MB (   +2MB)  finalize_macro_resolutions
time:   0.000; rss:   48MB ->   50MB (   +2MB)  resolve_crate
time:   0.000; rss:   53MB ->   55MB (   +2MB)  misc_checking_1
thread 'rustc' panicked at /rust/deps/stacker-0.1.21/src/mmap_stack_restore_guard.rs:70:13:
assertion `left != right` failed: mprotect/mmap failed: Cannot allocate memory (os error 12)
  left: -1
 right: -1
stack backtrace:
   0:     0x7fcebbc07a73 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::haaf8507f4a29a394
   1:     0x7fcebc402937 - core::fmt::write::h7fe83e6df373f5c3
   2:     0x7fcebbbfd6b3 - std::io::Write::write_fmt::hfb6586c2ced9705e
   3:     0x7fcebbc078d2 - std::sys::backtrace::BacktraceLock::print::ha382153d3e9a178f
   4:     0x7fcebbc0b377 - std::panicking::default_hook::{{closure}}::h1a9ba0d9da485095
   5:     0x7fcebbc0aedb - std::panicking::default_hook::h563da6c810118569
   6:     0x7fcebaca2de3 - std[ea124994cc9a9fb0]::panicking::update_hook::<alloc[35701694d0a2dbaf]::boxed::Box<rustc_driver_impl[29bade070c17738b]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7fcebbc0bbbe - std::panicking::rust_panic_with_hook::h71417bd18a2cf999
   8:     0x7fcebbc0b8ba - std::panicking::begin_panic_handler::{{closure}}::h7305fbb11ba45cb7
   9:     0x7fcebbc07f39 - std::sys::backtrace::__rust_end_short_backtrace::ha063cf6dcc7048b1
  10:     0x7fcebbc0b59d - __rustc[b55d4bfdbafc8d45]::rust_begin_unwind
  11:     0x7fceb82f49e0 - core::panicking::panic_fmt::hcea42e82ff26abdd
  12:     0x7fceba675e97 - core::panicking::assert_failed_inner::h797a2210404b97d1
  13:     0x7fcebbbd95da - core::panicking::assert_failed::hf235ecc29859684c
  14:     0x7fcebbbc70f0 - stacker[95082f485f82d86f]::_grow
  15:     0x7fcebc52d709 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::poly_select::{closure#0}
  16:     0x7fcebc4a6933 - rustc_trait_selection[c35e178390ab42ec]::traits::project::opt_normalize_projection_term
  17:     0x7fcebc4a43b5 - <rustc_infer[8a84da415e79f5d0]::infer::InferCtxt>::commit_if_ok::<rustc_trait_selection[c35e178390ab42ec]::traits::project::ProjectAndUnifyResult, rustc_infer[8a84da415e79f5d0]::traits::project::MismatchedProjectionTypes, rustc_trait_selection[c35e178390ab42ec]::traits::project::poly_project_and_unify_term::{closure#0}>
  18:     0x7fcebc4b1a79 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_candidate::{closure#0}::{closure#0}
  19:     0x7fcebc4b398d - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  20:     0x7fcebc4ae192 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_predicate_recursively
  21:     0x7fcebc4b7604 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  22:     0x7fcebc4ae192 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_predicate_recursively
  23:     0x7fcebc4b7604 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  24:     0x7fcebc4ae192 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_predicate_recursively
  25:     0x7fcebc4b7604 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  26:     0x7fcebc4ae192 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_predicate_recursively
  27:     0x7fcebc4b7604 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  28:     0x7fcebc4ae192 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_predicate_recursively
  29:     0x7fcebc4b7604 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
  30:     0x7fcebc4ae192 - <rustc_trait_selection[c35e178390ab42ec]::traits::select::SelectionContext>::evaluate_predicate_recursively
......
......

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions