Skip to content

ICE: None in compiler/rustc_hir_analysis/src/coherence/orphan.rs #148621

Description

@cushionbadak

Code

#![feature(type_alias_impl_trait)]

type Foo<V> = impl std::fmt::Debug;

trait Identity<Q> {
    type T;
}

trait Holds {
    type Q;
}

struct S;
struct X(S);

struct XHelper;

impl Holds for X {
    type Q = XHelper;
}

impl<Q> Clone for Foo<<S as Identity<Q>>::T>
where
    <S as Identity<Q>>::T: Clone,
    X: Holds<Q = Q>,
{
    fn clone(&self) -> Self {
        Self(self.0.clone())
    }
}

fn main() {}

A mutant of tests/ui/trait-bounds/issue-94999.rs

Meta

rustc --version --verbose:

rustc 1.93.0-nightly (c90bcb957 2025-11-06)
binary: rustc
commit-hash: c90bcb9571b7aab0d8beaa2ce8a998ffaf079d38
commit-date: 2025-11-06
host: x86_64-apple-darwin
release: 1.93.0-nightly
LLVM version: 21.1.3

Error output

Command: rustc

thread 'rustc' (5651690) panicked at compiler/rustc_hir_analysis/src/coherence/orphan.rs:485:22:
called `Option::unwrap()` on a `None` value
Backtrace

thread 'rustc' (5651690) panicked at compiler/rustc_hir_analysis/src/coherence/orphan.rs:485:22:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: rustc_hir_analysis::coherence::orphan::orphan_check_impl
      [... omitted 1 frame ...]
   5: rustc_hir_analysis::coherence::coherent_trait
      [... omitted 1 frame ...]
   6: rustc_middle::query::inner::query_ensure_error_guaranteed::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 1]>>, ()>
   7: rustc_hir_analysis::check::check::check_item_type
   8: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
   9: rustc_hir_analysis::check::wfcheck::check_type_wf
      [... omitted 1 frame ...]
  10: rustc_hir_analysis::check_crate
  11: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  12: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  13: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

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: please attach the file at `/Users/jb/Library/CloudStorage/Dropbox/Desk/2503_rustc_ice/20251106 ice 보고용/rustc-ice-2025-11-07T04_41_49-13197.txt` to your bug report

query stack during panic:
#0 [orphan_check_impl] checking whether impl `<impl at 03.rs:22:1: 25:21>` follows the orphan rules
#1 [coherent_trait] coherence checking all impls of trait `core::clone::Clone`
#2 [check_well_formed] checking that `<impl at 03.rs:22:1: 25:21>` is well-formed
#3 [check_type_wf] checking that types are well-formed
#4 [analysis] running analysis passes on crate `03`
end of query stack

Notes

@rustbot label +F-type_alias_impl_trait

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler 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