Repository: rust
Issue: rustdoc: ICE: synthetic auto trait impls: `unable to fulfill trait […]` due to ambiguity involving higher-ranked lifetimes & projection predicates 
Labels: T-rustdoc,I-ICE,T-compiler,C-bug,A-synthetic-impls,A-auto-traits,A-higher-ranked

<!--
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
mod foo {
    pub trait MyTrait<'a> {
        type MyItem: ?Sized;
    }

    pub struct Inner<'a, Q, R: ?Sized> {
        field: Q,
        field3: &'a u8,
        my_foo: Foo<Q>,
        field2: R,
    }

    pub struct Outer<'a, T, K: for<'b> Fn((&'b bool, &'a u8)) -> &'b i8> {
        my_inner: Inner<'a, T, K>,
    }

    pub struct Foo<T> {
        myfield: T,
    }
}

pub use foo::{Foo, Inner as NotInner, MyTrait as NotMyTrait, Outer as NotOuter};

unsafe impl<T> Send for Foo<T> where T: NotMyTrait<'static> {}

unsafe impl<'a, Q, R: ?Sized> Send for NotInner<'a, Q, R>
where
    Q: NotMyTrait<'a>,
    <Q as NotMyTrait<'a>>::MyItem: Copy,
    R: for<'b> Fn((&'b bool, &'a u8)) -> &'b i8,
    Foo<Q>: Send,
{
}

```


### 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`:
```
rustdoc 1.71.0-nightly (b628260df 2023-04-22)
binary: rustdoc
commit-hash: b628260df0587ae559253d8640ecb8738d3de613
commit-date: 2023-04-22
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2
```

### Error output

```
<output>
```

<!--
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>

```
thread 'rustc' panicked at 'Unable to fulfill trait DefId(2:2667 ~ core[6cf6]::marker::Send) for 'foo::Outer<'a, T, K>': [FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(AliasTy { substs: [K, ((&'b bool, &u8),)], def_id: DefId(2:2941 ~ core[6cf6]::ops::function::FnOnce::Output) }, Term::Ty(&'b i8)), [Region(BrNamed(DefId(0:35 ~ 6FE45A2C6E5FED2D2D1DB7DB67AB01ACD3334D81EA9E40465D43C623BE26A177[00f4]::{impl#1}::'b), 'b))]), depth=1),Ambiguity)]', /rustc/b628260df0587ae559253d8640ecb8738d3de613/compiler/rustc_trait_selection/src/traits/auto_trait.rs:186:13
stack backtrace:
   0:     0x7f1267168d93 - std::backtrace_rs::backtrace::libunwind::trace::hb9265895128f1f9c
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f1267168d93 - std::backtrace_rs::backtrace::trace_unsynchronized::h028901cb3a0224b1
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f1267168d93 - std::sys_common::backtrace::_print_fmt::hfa5c37f64d314fee
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f1267168d93 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5b30f1684e8bd3e6
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f12671c977f - core::fmt::write::h997ecd0e22e2af7a
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/core/src/fmt/mod.rs:1247:17
   5:     0x7f126715bde1 - std::io::Write::write_fmt::h291317e85b978e13
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/io/mod.rs:1698:15
   6:     0x7f1267168ba5 - std::sys_common::backtrace::_print::h0133b24def7b99d9
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f1267168ba5 - std::sys_common::backtrace::print::h4a42174c7f3bd207
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f126716b69f - std::panicking::default_hook::{{closure}}::h0847452fe926d6e5
   9:     0x7f126716b357 - std::panicking::default_hook::hbcdd7833994c05d0
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/panicking.rs:293:9
  10:     0x7f126a42a815 - <rustc_driver_impl[6beef204b99823c0]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[6cf684c3b560543b]::ops::function::FnOnce<(&core[6cf684c3b560543b]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f126716be55 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hd538136c3a298239
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/alloc/src/boxed.rs:1976:9
  12:     0x7f126716be55 - std::panicking::rust_panic_with_hook::hb55c52c8e21298f0
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/panicking.rs:704:13
  13:     0x7f126716bbc3 - std::panicking::begin_panic_handler::{{closure}}::h51ad0ee3ee1b4d02
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/panicking.rs:595:13
  14:     0x7f12671691d6 - std::sys_common::backtrace::__rust_end_short_backtrace::hd1006853c72eedaf
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/sys_common/backtrace.rs:150:18
  15:     0x7f126716b8c2 - rust_begin_unwind
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/panicking.rs:584:5
  16:     0x7f12671c5a13 - core::panicking::panic_fmt::h0405aceea833a54b
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/core/src/panicking.rs:67:14
  17:     0x562dff19f504 - <rustc_trait_selection[d0b596a23f484fce]::traits::auto_trait::AutoTraitFinder>::find_auto_trait_generics::<rustdoc[528331f52b1a723d]::clean::types::Generics, <rustdoc[528331f52b1a723d]::clean::auto_trait::AutoTraitFinder>::generate_for_trait::{closure#0}>
  18:     0x562dfef32a2d - <rustdoc[528331f52b1a723d]::clean::auto_trait::AutoTraitFinder>::generate_for_trait
  19:     0x562dff0cae81 - <alloc[dc090090a0f7fcb0]::vec::Vec<rustdoc[528331f52b1a723d]::clean::types::Item> as alloc[dc090090a0f7fcb0]::vec::spec_from_iter::SpecFromIter<rustdoc[528331f52b1a723d]::clean::types::Item, core[6cf684c3b560543b]::iter::adapters::filter_map::FilterMap<alloc[dc090090a0f7fcb0]::vec::into_iter::IntoIter<rustc_span[2bbd0fdc9680f436]::def_id::DefId>, <rustdoc[528331f52b1a723d]::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls::{closure#0}>>>::from_iter
  20:     0x562dfef333a7 - <rustdoc[528331f52b1a723d]::clean::auto_trait::AutoTraitFinder>::get_auto_trait_impls
  21:     0x562dff030521 - rustdoc[528331f52b1a723d]::clean::utils::get_auto_trait_and_blanket_impls
  22:     0x562dff2276ef - <rustdoc[528331f52b1a723d]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[528331f52b1a723d]::visit::DocVisitor>::visit_item
  23:     0x562dff2277fa - <rustdoc[528331f52b1a723d]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[528331f52b1a723d]::visit::DocVisitor>::visit_item
  24:     0x562dff2277fa - <rustdoc[528331f52b1a723d]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[528331f52b1a723d]::visit::DocVisitor>::visit_item
  25:     0x562dff22c0f6 - <rustdoc[528331f52b1a723d]::passes::collect_trait_impls::SyntheticImplCollector as rustdoc[528331f52b1a723d]::visit::DocVisitor>::visit_crate
  26:     0x562dff0edc31 - <rustc_session[a507976b3601bb0a]::session::Session>::time::<alloc[dc090090a0f7fcb0]::vec::Vec<rustdoc[528331f52b1a723d]::clean::types::Item>, rustdoc[528331f52b1a723d]::passes::collect_trait_impls::collect_trait_impls::{closure#0}>
  27:     0x562dff2246a9 - rustdoc[528331f52b1a723d]::passes::collect_trait_impls::collect_trait_impls
  28:     0x562dff0ede42 - <rustc_session[a507976b3601bb0a]::session::Session>::time::<rustdoc[528331f52b1a723d]::clean::types::Crate, rustdoc[528331f52b1a723d]::core::run_global_ctxt::{closure#8}>
  29:     0x562dff19770f - rustdoc[528331f52b1a723d]::core::run_global_ctxt
  30:     0x562dff0ee0be - <rustc_session[a507976b3601bb0a]::session::Session>::time::<(rustdoc[528331f52b1a723d]::clean::types::Crate, rustdoc[528331f52b1a723d]::config::RenderOptions, rustdoc[528331f52b1a723d]::formats::cache::Cache), rustdoc[528331f52b1a723d]::main_args::{closure#1}::{closure#0}::{closure#0}::{closure#0}>
  31:     0x562dfef5f9a0 - <rustc_middle[c2d73d0bca510e43]::ty::context::GlobalCtxt>::enter::<rustdoc[528331f52b1a723d]::main_args::{closure#1}::{closure#0}::{closure#0}, core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>>
  32:     0x562dfeff89aa - <rustc_interface[f51b23ce14955e2d]::interface::Compiler>::enter::<rustdoc[528331f52b1a723d]::main_args::{closure#1}::{closure#0}, core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>>
  33:     0x562dff198d2b - rustc_span[2bbd0fdc9680f436]::set_source_map::<core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>, rustc_interface[f51b23ce14955e2d]::interface::run_compiler<core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>, rustdoc[528331f52b1a723d]::main_args::{closure#1}>::{closure#0}::{closure#0}>
  34:     0x562dfeffa66d - <scoped_tls[ab8992ac05ee2537]::ScopedKey<rustc_span[2bbd0fdc9680f436]::SessionGlobals>>::set::<rustc_interface[f51b23ce14955e2d]::interface::run_compiler<core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>, rustdoc[528331f52b1a723d]::main_args::{closure#1}>::{closure#0}, core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>>
  35:     0x562dfef148e9 - std[7eada91b7b6d60d5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f51b23ce14955e2d]::util::run_in_thread_pool_with_globals<rustc_interface[f51b23ce14955e2d]::interface::run_compiler<core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>, rustdoc[528331f52b1a723d]::main_args::{closure#1}>::{closure#0}, core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>>
  36:     0x562dff24ab5d - <<std[7eada91b7b6d60d5]::thread::Builder>::spawn_unchecked_<rustc_interface[f51b23ce14955e2d]::util::run_in_thread_pool_with_globals<rustc_interface[f51b23ce14955e2d]::interface::run_compiler<core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>, rustdoc[528331f52b1a723d]::main_args::{closure#1}>::{closure#0}, core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6cf684c3b560543b]::result::Result<(), rustc_span[2bbd0fdc9680f436]::ErrorGuaranteed>>::{closure#1} as core[6cf684c3b560543b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7f1267176255 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he5dc381da166b1f4
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/alloc/src/boxed.rs:1962:9
  38:     0x7f1267176255 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2873f5088eb028a4
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/alloc/src/boxed.rs:1962:9
  39:     0x7f1267176255 - std::sys::unix::thread::Thread::new::thread_start::h737c68bdf349b13b
                               at /rustc/b628260df0587ae559253d8640ecb8738d3de613/library/std/src/sys/unix/thread.rs:108:17
  40:     0x7f1266e28bb5 - <unknown>
  41:     0x7f1266eaad90 - <unknown>
  42:                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-compiler&template=ice.md

note: rustc 1.71.0-nightly (b628260df 2023-04-22) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

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

</p>
</details>


<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"fmease"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->