Skip to content

ICE: unreachable in compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs #148631

@cushionbadak

Description

@cushionbadak

Code

struct C; struct S<T>(Option<T>); trait Tr { type Out; } impl<T> Clone for S<C> where S<T>: Tr<Out = T>, { fn clone(&self) -> Self { *self } } fn main() {}

A mutant of tests/ui/associated-types/issue-25700-1.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

error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates --> 08.rs:9:6 | 9 | impl<T> Clone for S<C> | ^ unconstrained type parameter thread 'rustc' (6161155) panicked at compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs:1353:27: internal error: entered unreachable code 
Backtrace

thread 'rustc' (6161155) panicked at compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs:1353:27: internal error: entered unreachable code stack backtrace: 0: __rustc::rust_begin_unwind 1: core::panicking::panic_fmt 2: core::panicking::panic 3: <rustc_borrowck::MirBorrowckCtxt>::suggest_cloning 4: <rustc_borrowck::MirBorrowckCtxt>::report 5: <rustc_borrowck::MirBorrowckCtxt>::report_move_errors 6: rustc_borrowck::borrowck_check_region_constraints 7: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck 8: rustc_borrowck::mir_borrowck [... omitted 1 frame ...] 9: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0} 10: rustc_interface::passes::analysis [... omitted 1 frame ...] 11: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}> 12: 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-07T05_57_22-5613.txt` to your bug report query stack during panic: #0 [mir_borrowck] borrow-checking `<impl at 08.rs:9:1: 11:23>::clone` #1 [analysis] running analysis passes on crate `08` end of query stack error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0207`. 

Notes

  • ICE location: compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs Line-1353

    let types: Vec<_> = types.into_iter().collect();
    let msg = match &types[..] {
    [only] => format!("`{only}`"),
    [head @ .., last] => format!(
    "{} and `{last}`",
    head.iter().map(|t| format!("`{t}`")).collect::<Vec<_>>().join(", ")
    ),
    [] => unreachable!(),
    };
    err.span_note(
    span,
    format!("if {msg} implemented `Clone`, you could clone the value"),
    );

  • Duplication Check

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions