Repository: rust
Issue: Crash documenting a mangled version of diesel
Labels: T-rustdoc,I-ICE,C-bug,E-needs-mcve

<!--
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

I haven't had time to make an MCVE. https://github.com/jyn514/diesel/tree/mangled-diesel-ice


### 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.66.0-nightly (2019147c5 2022-09-19)
```

### Error output

```
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: unresolved inference variable in outlives: _#0t
   --> diesel/src/insertable.rs:234:5
    |
234 |     fn walk_ast(&self, mut out: AstPass<DB>) -> QueryResult<()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_infer/src/infer/outlives/obligations.rs:296:35
```

<!--
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>

```
jnelson@pop-os:~/rust-lang/diesel/diesel$ cargo +nightly doc -p diesel --no-default-features --no-deps
 Documenting diesel v1.4.8 (/home/jnelson/rust-lang/diesel/diesel)
warning: unresolved link to `allow_tables_to_appear_in_same_query`
   --> diesel/src/macros/mod.rs:882:28
    |
882 | /// still need to invoke [`allow_tables_to_appear_in_same_query!`] for these two tables to
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `allow_tables_to_appear_in_same_query` in scope
    |
    = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
    = note: `macro_rules` named `allow_tables_to_appear_in_same_query` exists in this crate, but it is not in scope at this link's location

warning: unresolved link to `diesel::sql_types`
   --> diesel/src/expression/functions/mod.rs:394:44
    |
394 | /// Typically these types will come from [`diesel::sql_types`].
    |                                            ^^^^^^^^^^^^^^^^^ no item named `diesel` in scope

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: unresolved inference variable in outlives: _#0t
   --> diesel/src/insertable.rs:234:5
    |
234 |     fn walk_ast(&self, mut out: AstPass<DB>) -> QueryResult<()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_infer/src/infer/outlives/obligations.rs:296:35

error: internal compiler error: unresolved inference variable in outlives: _#1t
   --> diesel/src/insertable.rs:234:5
    |
234 |     fn walk_ast(&self, mut out: AstPass<DB>) -> QueryResult<()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_infer/src/infer/outlives/obligations.rs:296:35

error: internal compiler error: unresolved inference variable in outlives: _#2t
   --> diesel/src/insertable.rs:234:5
    |
234 |     fn walk_ast(&self, mut out: AstPass<DB>) -> QueryResult<()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_infer/src/infer/outlives/obligations.rs:296:35

error: internal compiler error: unresolved inference variable in outlives: _#3t
   --> diesel/src/insertable.rs:234:5
    |
234 |     fn walk_ast(&self, mut out: AstPass<DB>) -> QueryResult<()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_infer/src/infer/outlives/obligations.rs:296:35

error: internal compiler error: unresolved inference variable in outlives: _#4t
   --> diesel/src/insertable.rs:234:5
    |
234 |     fn walk_ast(&self, mut out: AstPass<DB>) -> QueryResult<()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_infer/src/infer/outlives/obligations.rs:296:35

error: internal compiler error: unresolved inference variable in outlives: _#5t
   --> diesel/src/insertable.rs:234:5
    |
234 |     fn walk_ast(&self, mut out: AstPass<DB>) -> QueryResult<()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_infer/src/infer/outlives/obligations.rs:296:35

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1496:13
stack backtrace:
   0:     0x7f0c4a3f3d50 - std::backtrace_rs::backtrace::libunwind::trace::hca58970939440ddb
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f0c4a3f3d50 - std::backtrace_rs::backtrace::trace_unsynchronized::hecbb24b0111a587f
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f0c4a3f3d50 - std::sys_common::backtrace::_print_fmt::he61830d72c18b03f
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f0c4a3f3d50 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h44a4d5ffd8b5f12f
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f0c4a44eaae - core::fmt::write::h36f409545d48f3ab
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f0c4a3e4965 - std::io::Write::write_fmt::hbebd5f2eabb29835
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/std/src/io/mod.rs:1679:15
   6:     0x7f0c4a3f6a03 - std::sys_common::backtrace::_print::hfc821bd870e7c2f9
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f0c4a3f6a03 - std::sys_common::backtrace::print::h2089c5a622ce25a2
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f0c4a3f6a03 - std::panicking::default_hook::{{closure}}::h9797a49e0840e11f
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/std/src/panicking.rs:295:22
   9:     0x7f0c4a3f66ef - std::panicking::default_hook::h0fea6f7c99363bb8
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/std/src/panicking.rs:314:9
  10:     0x7f0c4cc004d1 - <rustc_driver[4d8ae11669fe9251]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[a07eb80c9c85c032]::ops::function::FnOnce<(&core[a07eb80c9c85c032]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f0c4a3f723d - std::panicking::rust_panic_with_hook::hcfad96d8dd42468a
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/std/src/panicking.rs:702:17
  12:     0x7f0c4dd16801 - std[a279f2880638d09]::panicking::begin_panic::<rustc_errors[d4603f296c4da6bc]::ExplicitBug>::{closure#0}
  13:     0x7f0c4dd16566 - std[a279f2880638d09]::sys_common::backtrace::__rust_end_short_backtrace::<std[a279f2880638d09]::panicking::begin_panic<rustc_errors[d4603f296c4da6bc]::ExplicitBug>::{closure#0}, !>
  14:     0x7f0c4dd16206 - std[a279f2880638d09]::panicking::begin_panic::<rustc_errors[d4603f296c4da6bc]::ExplicitBug>
  15:     0x7f0c4dd139e6 - std[a279f2880638d09]::panic::panic_any::<rustc_errors[d4603f296c4da6bc]::ExplicitBug>
  16:     0x7f0c4c720e7b - <rustc_errors[d4603f296c4da6bc]::HandlerInner as core[a07eb80c9c85c032]::ops::drop::Drop>::drop
  17:     0x55f4b25daed8 - core[a07eb80c9c85c032]::ptr::drop_in_place::<rustc_session[a0ecee5adbc982cc]::parse::ParseSess>
  18:     0x55f4b25e45e8 - <alloc[d879d42b3a851228]::rc::Rc<rustc_session[a0ecee5adbc982cc]::session::Session> as core[a07eb80c9c85c032]::ops::drop::Drop>::drop
  19:     0x55f4b25ee9ed - core[a07eb80c9c85c032]::ptr::drop_in_place::<rustc_interface[a3cde090deaae6ca]::interface::Compiler>
  20:     0x55f4b25e6318 - rustc_span[5e9b8ed3473e32ba]::with_source_map::<core[a07eb80c9c85c032]::result::Result<(), rustc_errors[d4603f296c4da6bc]::ErrorGuaranteed>, rustc_interface[a3cde090deaae6ca]::interface::create_compiler_and_run<core[a07eb80c9c85c032]::result::Result<(), rustc_errors[d4603f296c4da6bc]::ErrorGuaranteed>, rustdoc[ede9c2b591c7550c]::main_options::{closure#0}>::{closure#1}>
  21:     0x55f4b22e6ab5 - rustdoc[ede9c2b591c7550c]::main_options
  22:     0x55f4b24bb32b - <scoped_tls[880a10f1daa2c7e]::ScopedKey<rustc_span[5e9b8ed3473e32ba]::SessionGlobals>>::set::<rustdoc[ede9c2b591c7550c]::main_args::{closure#0}, core[a07eb80c9c85c032]::result::Result<(), rustc_errors[d4603f296c4da6bc]::ErrorGuaranteed>>
  23:     0x55f4b25886e0 - std[a279f2880638d09]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a3cde090deaae6ca]::util::run_in_thread_pool_with_globals<rustdoc[ede9c2b591c7550c]::main_args::{closure#0}, core[a07eb80c9c85c032]::result::Result<(), rustc_errors[d4603f296c4da6bc]::ErrorGuaranteed>>::{closure#0}, core[a07eb80c9c85c032]::result::Result<(), rustc_errors[d4603f296c4da6bc]::ErrorGuaranteed>>
  24:     0x55f4b2438bec - <<std[a279f2880638d09]::thread::Builder>::spawn_unchecked_<rustc_interface[a3cde090deaae6ca]::util::run_in_thread_pool_with_globals<rustdoc[ede9c2b591c7550c]::main_args::{closure#0}, core[a07eb80c9c85c032]::result::Result<(), rustc_errors[d4603f296c4da6bc]::ErrorGuaranteed>>::{closure#0}, core[a07eb80c9c85c032]::result::Result<(), rustc_errors[d4603f296c4da6bc]::ErrorGuaranteed>>::{closure#1} as core[a07eb80c9c85c032]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f0c4a401013 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9e10d852f2b411a9
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/alloc/src/boxed.rs:1940:9
  26:     0x7f0c4a401013 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbc63898c23a1b20e
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/alloc/src/boxed.rs:1940:9
  27:     0x7f0c4a401013 - std::sys::unix::thread::Thread::new::thread_start::hcf2cf034dfc26d4f
                               at /rustc/2019147c5642c08cdb9ad4cacd97dd1fa4ffa701/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f0c4a2a2609 - start_thread
                               at /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477:8
  29:     0x7f0c4a1c7133 - clone
                               at /build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  30:                0x0 - <unknown>

note: 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.66.0-nightly (2019147c5 2022-09-19) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `diesel` (lib doc) generated 2 warnings
error: could not document `diesel`

Caused by:
  process didn't exit successfully: `rustdoc --crate-type lib --crate-name diesel diesel/src/lib.rs -o /home/jnelson/.local/lib/cargo/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat -C metadata=a02c99419513cad6 -L dependency=/home/jnelson/.local/lib/cargo/target/debug/deps --extern byteorder=/home/jnelson/.local/lib/cargo/target/debug/deps/libbyteorder-19cac908f6232626.rmeta --extern diesel_derives=/home/jnelson/.local/lib/cargo/target/debug/deps/libdiesel_derives-80b3c881c4d4ed6a.so --crate-version 1.4.8` (exit status: 101)
```

</p>
</details>