ICE: `None` in compiler/rustc_hir_analysis/src/coherence/orphan.rs
Opened this issue · 2 comments
cushionbadak commented
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
-
ICE location:
compiler/rustc_hir_analysis/src/coherence/orphan.rs Line-485
rust/compiler/rustc_hir_analysis/src/coherence/orphan.rs
Lines 475 to 486 in c90bcb9
-
Duplication Check
- I searched for ICE issues with "orphan.rs", (Github issue page with query)
- #136188 (comment) shows identical ICE location, but that one requires
-Znext-solverto ICE, while this one ICEs with justrustc. - In my observation, the first reproduction code in issue-136188 does not ICE for current compiler version.
@rustbot label +F-type_alias_impl_trait
cyrgani commented
type Foo<V> = impl std::fmt::Debug;
trait Identity<Q> {
type T;
}
impl<Q> Clone for Foo<<() as Identity<Q>>::T> {
fn clone(&self) -> Self {
loop {}
}
}
fn main() {}cushionbadak commented
cargo-bisect-rustc --start=2024-01-01 --end=2025-11-07 --regress ice --preserve --script rustc -- 148621.rs
********************************************************************************
Regression in nightly-2024-06-06
********************************************************************************
fetching https://static.rust-lang.org/dist/2024-06-05/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2024-06-05: 40 B / 40 B [================================================================================================================================================] 100.00 % 981.47 KB/s converted 2024-06-05 to a330e49593ee890f9197727a3a558b6e6b37f843
fetching https://static.rust-lang.org/dist/2024-06-06/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2024-06-06: 40 B / 40 B [================================================================================================================================================] 100.00 % 753.69 KB/s converted 2024-06-06 to 72fdf913c53dd0e75313ba83e4aa80df3f6e2871
looking for regression commit between 2024-06-05 and 2024-06-06
fetching (via remote github) commits from max(a330e49593ee890f9197727a3a558b6e6b37f843, 2024-06-03) to 72fdf913c53dd0e75313ba83e4aa80df3f6e2871
ending github query because we found starting sha: a330e49593ee890f9197727a3a558b6e6b37f843
get_commits_between returning commits, len: 6
commit[0] 2024-06-04: Auto merge of #125989 - GuillaumeGomez:rollup-xu69i13, r=GuillaumeGomez
commit[1] 2024-06-05: Auto merge of #126011 - workingjubilee:try-fix-solaris-build, r=workingjubilee
commit[2] 2024-06-05: Auto merge of #126016 - workingjubilee:rollup-nh6ehbz, r=workingjubilee
commit[3] 2024-06-05: Auto merge of #126005 - weihanglo:update-cargo, r=weihanglo
commit[4] 2024-06-05: Auto merge of #126037 - matthiaskrgr:rollup-7pz1nhr, r=matthiaskrgr
commit[5] 2024-06-05: Auto merge of #126038 - matthiaskrgr:rollup-h4rm3x2, r=matthiaskrgr
ERROR: no CI builds available between a330e49593ee890f9197727a3a558b6e6b37f843 and 72fdf913c53dd0e75313ba83e4aa80df3f6e2871 within last 167 days