Repository: rust
Issue: rustfmt is not getting backtraces anymore
Labels: A-parser,T-compiler,C-bug,A-rustfmt

with beta:

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary>Backtrace</summary>
<p>

```
thread 'main' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1679:13
stack backtrace:
   0:     0x7f1db46a9cca - std::backtrace_rs::backtrace::libunwind::trace::hbbcc434e126c5eca
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f1db46a9cca - std::backtrace_rs::backtrace::trace_unsynchronized::hcfeb3591de6223ed
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f1db46a9cca - std::sys_common::backtrace::_print_fmt::hf4b07ca914823b07
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f1db46a9cca - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2628663c094a9edc
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f1db470e0cf - core::fmt::write::hd25d124b6b2a7e4f
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/core/src/fmt/mod.rs:1254:17
   5:     0x7f1db469c905 - std::io::Write::write_fmt::hfef477eb673474c1
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/io/mod.rs:1698:15
   6:     0x7f1db46a9a95 - std::sys_common::backtrace::_print::h588f914870da083b
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f1db46a9a95 - std::sys_common::backtrace::print::hf78f5877c23d9346
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f1db46ac73e - std::panicking::default_hook::{{closure}}::h784b6e5db2cb63a8
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/panicking.rs:269:22
   9:     0x7f1db46ac4e5 - std::panicking::default_hook::hc5b6890130ed568f
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/panicking.rs:288:9
  10:     0x7f1db46acdae - std::panicking::rust_panic_with_hook::hdc442d3dd8d62303
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/panicking.rs:691:13
  11:     0x7f1db34a4861 - std[b5e30104ae0f0b4b]::panicking::begin_panic::<rustc_errors[9f37727e913390d1]::DelayedBugPanic>::{closure#0}
  12:     0x7f1db34a4216 - std[b5e30104ae0f0b4b]::sys_common::backtrace::__rust_end_short_backtrace::<std[b5e30104ae0f0b4b]::panicking::begin_panic<rustc_errors[9f37727e913390d1]::DelayedBugPanic>::{closure#0}, !>
  13:     0x7f1db34bad16 - std[b5e30104ae0f0b4b]::panicking::begin_panic::<rustc_errors[9f37727e913390d1]::DelayedBugPanic>
  14:     0x7f1db29aa505 - <rustc_errors[9f37727e913390d1]::HandlerInner>::flush_delayed::<alloc[34d29d50fa9f75c3]::vec::Vec<rustc_errors[9f37727e913390d1]::DelayedDiagnostic>, &str>
  15:     0x7f1db29a9ce2 - <rustc_errors[9f37727e913390d1]::HandlerInner as core[63ff77d62dfc71d6]::ops::drop::Drop>::drop
  16:     0x55eca68257c2 - core[63ff77d62dfc71d6]::ptr::drop_in_place::<rustfmt_nightly[be1cd8d871d9742b]::parse::session::ParseSess>
  17:     0x55eca6826d61 - rustfmt_nightly[be1cd8d871d9742b]::formatting::format_project::<rustfmt_nightly[be1cd8d871d9742b]::Session<std[b5e30104ae0f0b4b]::io::stdio::Stdout>>
  18:     0x55eca68233eb - <scoped_tls[b45299cb45a61baa]::ScopedKey<rustc_span[9c7b16a21c6fef94]::SessionGlobals>>::with::<<rustfmt_nightly[be1cd8d871d9742b]::Session<std[b5e30104ae0f0b4b]::io::stdio::Stdout>>::format_input_inner::{closure#0}, core[63ff77d62dfc71d6]::result::Result<rustfmt_nightly[be1cd8d871d9742b]::FormatReport, rustfmt_nightly[be1cd8d871d9742b]::ErrorKind>>
  19:     0x55eca682049f - <scoped_tls[b45299cb45a61baa]::ScopedKey<rustc_span[9c7b16a21c6fef94]::SessionGlobals>>::set::<rustc_span[9c7b16a21c6fef94]::create_session_if_not_set_then<core[63ff77d62dfc71d6]::result::Result<rustfmt_nightly[be1cd8d871d9742b]::FormatReport, rustfmt_nightly[be1cd8d871d9742b]::ErrorKind>, <rustfmt_nightly[be1cd8d871d9742b]::Session<std[b5e30104ae0f0b4b]::io::stdio::Stdout>>::format_input_inner::{closure#0}>::{closure#0}, core[63ff77d62dfc71d6]::result::Result<rustfmt_nightly[be1cd8d871d9742b]::FormatReport, rustfmt_nightly[be1cd8d871d9742b]::ErrorKind>>
  20:     0x55eca6848a50 - <rustfmt_nightly[be1cd8d871d9742b]::Session<std[b5e30104ae0f0b4b]::io::stdio::Stdout>>::format
  21:     0x55eca6838e85 - rustfmt[6715a6dd9643e3d2]::format_and_emit_report::<std[b5e30104ae0f0b4b]::io::stdio::Stdout>
  22:     0x55eca68472b9 - <rustfmt_nightly[be1cd8d871d9742b]::Session<std[b5e30104ae0f0b4b]::io::stdio::Stdout>>::override_config::<rustfmt[6715a6dd9643e3d2]::format::{closure#0}, ()>
  23:     0x55eca6837c75 - rustfmt[6715a6dd9643e3d2]::execute
  24:     0x55eca6835b00 - rustfmt[6715a6dd9643e3d2]::main
  25:     0x55eca68466c3 - std[b5e30104ae0f0b4b]::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  26:     0x55eca68466d9 - std[b5e30104ae0f0b4b]::rt::lang_start::<()>::{closure#0}
  27:     0x7f1db468d4ce - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h0b5065893570e567
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/core/src/ops/function.rs:287:13
  28:     0x7f1db468d4ce - std::panicking::try::do_call::h5ca800981fed74c2
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/panicking.rs:485:40
  29:     0x7f1db468d4ce - std::panicking::try::h2f87932175597ce0
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/panicking.rs:449:19
  30:     0x7f1db468d4ce - std::panic::catch_unwind::hc959c362133244dc
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/panic.rs:140:14
  31:     0x7f1db468d4ce - std::rt::lang_start_internal::{{closure}}::hae43aabf49dbb8b7
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/rt.rs:148:48
  32:     0x7f1db468d4ce - std::panicking::try::do_call::h7edcf4ca1357a230
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/panicking.rs:485:40
  33:     0x7f1db468d4ce - std::panicking::try::h78993a725b68247e
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/panicking.rs:449:19
  34:     0x7f1db468d4ce - std::panic::catch_unwind::h4311e9b74efd560c
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/panic.rs:140:14
  35:     0x7f1db468d4ce - std::rt::lang_start_internal::h2a251b184d140e41
                               at /rustc/2013813b65016b39d456a12e3b0a90366e9fb5e3/library/std/src/rt.rs:148:20
  36:     0x55eca6839c25 - main
  37:     0x7f1daff32790 - <unknown>
  38:     0x7f1daff3284a - __libc_start_main
  39:     0x55eca681ca59 - <unknown>
  40:                0x0 - <unknown>
```

</p>
</details>

with nightly `rustfmt 1.5.2-nightly (69fef92 2023-05-13)`
`RUST_BACKTRACE=full rustfmt 8E72B7907D9D7F81DC6329AAC44D7D42D638688A0797C99F636739F9BFE5BEC1.rs`

````
note: we would appreciate a bug report: https://github.com/rust-lang/rustfmt/issues/new?labels=bug

note: rustc 1.71.0-nightly (69fef92ab 2023-05-13) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
````

Could this be a sideeffect of 2469afef1a9697e671f9e90971c342fa3e0006e6 ? cc @jyn514 

File to make rustfmt crash is attached (--check is sufficient)
[ice.rs.zip](https://github.com/rust-lang/rust/files/11469273/ice.rs.zip)