Repository: rust
Issue: Unexpected result when selecting aliases
Labels: T-rustdoc,I-ICE,C-bug,A-synthetic-impls,A-auto-traits

Happens when building docs `cargo docs --document-private-items`

https://github.com/paradigmxyz/reth/pull/13735 

https://github.com/paradigmxyz/reth/pull/13735/commits/2fe6d519b4a8d0c22aaf49d161aac498618c21b6

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code

```Rust
type EngineServiceType<N, Client> = ChainOrchestrator<
    EngineHandler<
        EngineApiRequestHandler<
            EngineApiRequest<<N as NodeTypesWithEngine>::Engine, <N as NodeTypes>::Primitives>,
            <N as NodeTypes>::Primitives,
        >,
        EngineMessageStream<<N as NodeTypesWithEngine>::Engine>,
        BasicBlockDownloader<Client, BlockTy<N>>,
    >,
    PipelineSync<N>,
>;
```
https://github.com/paradigmxyz/reth/actions/runs/12723951444/job/35469586386?pr=13735

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.86.0-nightly (a580b5c37 2025-01-08)
binary: rustc
commit-hash: a580b5c379b4fca50dfe5afc0fc0ce00921e4e00
commit-date: 2025-01-08
host: aarch64-apple-darwin
release: 1.86.0-nightly
LLVM version: 19.1.6

```

### Error output

```
thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/auto_trait.rs:720:33:
Unexpected result when selecting service::EngineService<N/#0, Client/#1, E/#2> Obligation(predicate=Binder { value: ProjectionPredicate(AliasTerm { args: [Client/#1], def_id: DefId(377:807 ~ reth_network_p2p[7774]::headers::client::HeadersClient::Header), .. }, Term::Ty(?15t)), bound_vars: [] }, depth=2)

query stack during panic:
end of query stack
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```
   0:        0x10cbedbc8 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hdf6b0ec9c000d35c
   1:        0x10a3f02b0 - core::fmt::write::h16c5bd41dd834a6b
   2:        0x10cbe1bb8 - std::io::Write::write_fmt::hec5eafa956dd01b2
   3:        0x10cbeda88 - std::sys::backtrace::BacktraceLock::print::hdc26b9278d26ab98
   4:        0x10cbeffac - std::panicking::default_hook::{{closure}}::ha59987241794d851
   5:        0x10cbefda8 - std::panicking::default_hook::hd22dec52cb554d05
   6:        0x10ae55a3c - std[3f4798804b5c7a44]::panicking::update_hook::<alloc[f8a9b9de03ffcad8]::boxed::Box<rustc_driver_impl[5f5e67e55176e86b]::install_ice_hook::{closure#1}>>::{closure#0}
   7:        0x10cbf09d4 - std::panicking::rust_panic_with_hook::h749e8bc345b0ef8c
   8:        0x10cbf0540 - std::panicking::begin_panic_handler::{{closure}}::h1b2213429acd8861
   9:        0x10cbee058 - std::sys::backtrace::__rust_end_short_backtrace::h7a0f0fe1c5a10461
  10:        0x10cbf0204 - _rust_begin_unwind
  11:        0x10f2be958 - core::panicking::panic_fmt::h859835561e58f44c
  12:        0x10c99fb04 - <rustc_trait_selection[424d8f1623cf1e5f]::traits::auto_trait::AutoTraitFinder>::evaluate_predicates
  13:        0x100a9831c - rustdoc[c63cc3a5136b6fa1]::clean::auto_trait::synthesize_auto_trait_impl
  14:        0x1009853d8 - rustdoc[c63cc3a5136b6fa1]::clean::utils::synthesize_auto_trait_and_blanket_impls
  15:        0x100a7618c - <rustdoc[c63cc3a5136b6fa1]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[c63cc3a5136b6fa1]::visit::DocVisitor>::visit_item
  16:        0x100a76288 - <rustdoc[c63cc3a5136b6fa1]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[c63cc3a5136b6fa1]::visit::DocVisitor>::visit_item
  17:        0x100a76288 - <rustdoc[c63cc3a5136b6fa1]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[c63cc3a5136b6fa1]::visit::DocVisitor>::visit_item
  18:        0x100a72f5c - rustdoc[c63cc3a5136b6fa1]::passes::collect_trait_impls::collect_trait_impls
  19:        0x1009a8c5c - rustdoc[c63cc3a5136b6fa1]::core::run_global_ctxt
  20:        0x100a95474 - rustdoc[c63cc3a5136b6fa1]::main_args::{closure#2}::{closure#0}
  21:        0x1008a155c - <rustc_interface[de273c1981fa55fc]::passes::create_and_enter_global_ctxt<(), rustdoc[c63cc3a5136b6fa1]::main_args::{closure#2}::{closure#0}>::{closure#2} as core[b8802227b17cbab3]::ops::function::FnOnce<(&rustc_session[5f519a7c706e20bb]::session::Session, rustc_middle[5b96f28b450e74f0]::ty::context::CurrentGcx, &std[3f4798804b5c7a44]::sync::once_lock::OnceLock<rustc_middle[5b96f28b450e74f0]::ty::context::GlobalCtxt>, &rustc_data_structures[8091d705d2ed9275]::sync::worker_local::WorkerLocal<rustc_middle[5b96f28b450e74f0]::arena::Arena>, &rustc_data_structures[8091d705d2ed9275]::sync::worker_local::WorkerLocal<rustc_hir[fa2110f737f883df]::Arena>, rustdoc[c63cc3a5136b6fa1]::main_args::{closure#2}::{closure#0})>>::call_once::{shim:vtable#0}
  22:        0x1008932ec - rustc_interface[de273c1981fa55fc]::interface::run_compiler::<(), rustdoc[c63cc3a5136b6fa1]::main_args::{closure#2}>::{closure#1}
  23:        0x10082b3f4 - std[3f4798804b5c7a44]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[de273c1981fa55fc]::util::run_in_thread_with_globals<rustc_interface[de273c1981fa55fc]::util::run_in_thread_pool_with_globals<rustc_interface[de273c1981fa55fc]::interface::run_compiler<(), rustdoc[c63cc3a5136b6fa1]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  24:        0x10089d894 - <<std[3f4798804b5c7a44]::thread::Builder>::spawn_unchecked_<rustc_interface[de273c1981fa55fc]::util::run_in_thread_with_globals<rustc_interface[de273c1981fa55fc]::util::run_in_thread_pool_with_globals<rustc_interface[de273c1981fa55fc]::interface::run_compiler<(), rustdoc[c63cc3a5136b6fa1]::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b8802227b17cbab3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:        0x10cbfb9b8 - std::sys::pal::unix::thread::Thread::new::thread_start::h6d88171faf776f6f
  26:        0x197b63fa8 - __pthread_joiner_wake
```

</p>
</details>