rust-lang / rust-lang/rust

[ICE]: rustdoc: `assertion failed: cx.impl_trait_bounds.is_empty()`

Open
#155,728 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-fn_delegation I-ICE needs-triage T-compiler T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code

rustdoc file.rs

#![feature(fn_delegation)]
#![allow(late_bound_lifetime_arguments,dead_code)]

trait Trait<T: ToString> {
   fn foo(&self, _f: impl FnOnce(T) -> String) {}
}

struct F;
impl<T: ToString> Trait<T> for F {}

struct S<'a, 'b, 'c, A, B>(F, &'a A, &'b B, &'c B);
impl<'a, 'b, 'c, A, B> S<'a, 'b, 'c, A, B> {
   reuse Trait::<String>::foo { &self.0 }
}

pub fn main() {}
Meta

rustc --version --verbose:

rustc 1.97.0-nightly (36ba2c771 2026-04-23)
binary: rustc
commit-hash: 36ba2c7712052d731a7082d0eba5ed3d9d56c133
commit-date: 2026-04-23
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.2
Error output
<output>
Backtrace

warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/delegation/generics/mapping/inherent-impl-to-trait-pass.rs:1:12
  |
1 | #![feature(fn_delegation)]
  |            ^^^^^^^^^^^^^
  |
  = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
  = note: `#[warn(incomplete_features)]` on by default


thread 'rustc' (3055611) panicked at src/librustdoc/clean/utils.rs:544:5:
assertion failed: cx.impl_trait_bounds.is_empty()
stack backtrace:
   0:     0x7f6786e1e9db - <<std[75ea15d2214b0ed8]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[2481842aaaac4afd]::fmt::Display>::fmt
   1:     0x7f678742d408 - core[2481842aaaac4afd]::fmt::write
   2:     0x7f6786e35986 - <std[75ea15d2214b0ed8]::sys::stdio::unix::Stderr as std[75ea15d2214b0ed8]::io::Write>::write_fmt
   3:     0x7f6786df4c58 - std[75ea15d2214b0ed8]::panicking::default_hook::{closure#0}
   4:     0x7f6786e12043 - std[75ea15d2214b0ed8]::panicking::default_hook
   5:     0x7f6785dd301c - std[75ea15d2214b0ed8]::panicking::update_hook::<alloc[38765da0c132a06f]::boxed::Box<rustc_driver_impl[7a2168e1d29e28dc]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f6786e12322 - std[75ea15d2214b0ed8]::panicking::panic_with_hook
   7:     0x7f6786df4d4a - std[75ea15d2214b0ed8]::panicking::panic_handler::{closure#0}
   8:     0x7f6786deba59 - std[75ea15d2214b0ed8]::sys::backtrace::__rust_end_short_backtrace::<std[75ea15d2214b0ed8]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f6786df677d - __rustc[8f3dd88aee2b0d44]::rust_begin_unwind
  10:     0x7f6783a2569c - core[2481842aaaac4afd]::panicking::panic_fmt
  11:     0x7f678384e2e2 - core[2481842aaaac4afd]::panicking::panic
  12:     0x56011c888f5f - rustdoc[eee478676427cc14]::clean::clean_function
  13:     0x56011c88bb6c - rustdoc[eee478676427cc14]::clean::clean_impl_item
  14:     0x56011c78634d - rustdoc[eee478676427cc14]::clean::clean_maybe_renamed_item::{closure#0}
  15:     0x56011c8903e3 - rustdoc[eee478676427cc14]::clean::clean_doc_module
  16:     0x56011c882271 - rustdoc[eee478676427cc14]::core::run_global_ctxt
  17:     0x56011c76fe61 - rustdoc[eee478676427cc14]::main_args::{closure#2}::{closure#0}
  18:     0x56011c767f0c - rustc_interface[27fd4870d2d649e5]::interface::run_compiler::<(), rustdoc[eee478676427cc14]::main_args::{closure#2}>::{closure#1}
  19:     0x56011c69b426 - std[75ea15d2214b0ed8]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[27fd4870d2d649e5]::util::run_in_thread_with_globals<rustc_interface[27fd4870d2d649e5]::util::run_in_thread_pool_with_globals<rustc_interface[27fd4870d2d649e5]::interface::run_compiler<(), rustdoc[eee478676427cc14]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  20:     0x56011c7a7ccd - <std[75ea15d2214b0ed8]::thread::lifecycle::spawn_unchecked<rustc_interface[27fd4870d2d649e5]::util::run_in_thread_with_globals<rustc_interface[27fd4870d2d649e5]::util::run_in_thread_pool_with_globals<rustc_interface[27fd4870d2d649e5]::interface::run_compiler<(), rustdoc[eee478676427cc14]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[2481842aaaac4afd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  21:     0x7f678852d56c - <std[75ea15d2214b0ed8]::sys::thread::unix::Thread>::new::thread_start
  22:     0x7f678203297a - <unknown>
  23:     0x7f67820b62bc - <unknown>
  24:                0x0 - <unknown>

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-rustdoc&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/home/matthias/vcs/github/rust_misc_stuff/tests/ui/delegation/rustc-ice-2026-04-24T10_36_46-3055602.txt` to your bug report

note: rustc 1.97.0-nightly (36ba2c771 2026-04-23) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
warning: 1 warning emitted

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/librustdoc/clean/utils.rs at the assertion in clean_function, then reproduce the panic with rustdoc file.rs using the provided fn_delegation example. Trace how the reused trait method reaches rustdoc cleaning; done means rustdoc no longer panics and a regression test covers the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.