Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustfmt: self.stashed_diagnostics.is_empty() #121517

Closed
matthiaskrgr opened this issue Feb 23, 2024 · 3 comments · Fixed by #121615
Closed

rustfmt: self.stashed_diagnostics.is_empty() #121517

matthiaskrgr opened this issue Feb 23, 2024 · 3 comments · Fixed by #121615
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

trait Trait<'1> { s> {}

Meta

rustc --version --verbose:

rustfmt 1.7.0-nightly (52cea08 2024-02-23)


rustc 1.78.0-nightly (52cea084b 2024-02-23)
binary: rustc
commit-hash: 52cea084bd5bbac12ecfa5c0499f5c777025c968
commit-date: 2024-02-23
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Error output

error: this file contains an unclosed delimiter
 --> /tmp/im/fmt.rs:2:2
  |
1 | trait Trait<'1> { s> {}
  |                 - unclosed delimiter
2 |
  |  ^
Backtrace


thread 'main' panicked at compiler/rustc_errors/src/lib.rs:565:9:
assertion failed: self.stashed_diagnostics.is_empty()
stack backtrace:
   0:     0x7f117c672af6 - std::backtrace_rs::backtrace::libunwind::trace::he0282bd7aa79d0f5
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f117c672af6 - std::backtrace_rs::backtrace::trace_unsynchronized::hd257d30ae267ec37
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f117c672af6 - std::sys_common::backtrace::_print_fmt::h4d76d87d5818822c
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f117c672af6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hda8b13640513c0ca
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f117c6c3a7c - core::fmt::rt::Argument::fmt::h0e78e7472c6726f6
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/core/src/fmt/rt.rs:142:9
   5:     0x7f117c6c3a7c - core::fmt::write::h92726084111378c3
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f117c6674bf - std::io::Write::write_fmt::hae4e2cfe04fc8ffe
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/io/mod.rs:1846:15
   7:     0x7f117c6728a4 - std::sys_common::backtrace::_print::ha088f411ecf7b854
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f117c6728a4 - std::sys_common::backtrace::print::h3cf71d8220ad62fb
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f117c6755eb - std::panicking::default_hook::{{closure}}::h40fbaa4ba62f2a25
  10:     0x7f117c675339 - std::panicking::default_hook::h4bae8cc7cdeafbdc
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/panicking.rs:292:9
  11:     0x7f11792859dc - std[67003dfa8d3cf222]::panicking::update_hook::<alloc[39168ee3c7236603]::boxed::Box<rustc_driver_impl[7f540b76ed15adf]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f117c675d50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h9766e5d4d8db67de
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/alloc/src/boxed.rs:2030:9
  13:     0x7f117c675d50 - std::panicking::rust_panic_with_hook::h8e53bf6707538e9c
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/panicking.rs:786:13
  14:     0x7f117c675a59 - std::panicking::begin_panic_handler::{{closure}}::h26d54e6ef9a6c6b8
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/panicking.rs:652:13
  15:     0x7f117c672fd6 - std::sys_common::backtrace::__rust_end_short_backtrace::h820826df8359172f
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f117c6757c4 - rust_begin_unwind
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/panicking.rs:648:5
  17:     0x7f117c6bff95 - core::panicking::panic_fmt::h8ddceedf455eb6ab
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/core/src/panicking.rs:72:14
  18:     0x7f117c6c0053 - core::panicking::panic::h2937174c0915040f
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/core/src/panicking.rs:144:5
  19:     0x7f117bbddbdb - <rustc_errors[69afeb585d680721]::DiagCtxtInner as core[e4f656a50871fc5f]::ops::drop::Drop>::drop.cold.0
  20:     0x564134bcb50b - core[e4f656a50871fc5f]::ptr::drop_in_place::<rustfmt_nightly[734c678f573b2d80]::parse::session::ParseSess>
  21:     0x564134bd2cc0 - <rustfmt_nightly[734c678f573b2d80]::Session<std[67003dfa8d3cf222]::io::stdio::Stdout>>::format_input_inner::{closure#0}
  22:     0x564134be8dd1 - rustfmt[40fef13c054501be]::format_and_emit_report::<std[67003dfa8d3cf222]::io::stdio::Stdout>
  23:     0x564134be726c - rustfmt[40fef13c054501be]::execute
  24:     0x564134be293b - rustfmt[40fef13c054501be]::main
  25:     0x564134bcd023 - std[67003dfa8d3cf222]::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  26:     0x564134bcf2c9 - std[67003dfa8d3cf222]::rt::lang_start::<()>::{closure#0}
  27:     0x7f117c657f83 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h369d12c4942e7526
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/core/src/ops/function.rs:284:13
  28:     0x7f117c657f83 - std::panicking::try::do_call::h951a588450e41da0
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/panicking.rs:555:40
  29:     0x7f117c657f83 - std::panicking::try::h45c068d6d7241dfb
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/panicking.rs:519:19
  30:     0x7f117c657f83 - std::panic::catch_unwind::h7e2d0c5ea10dda27
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/panic.rs:142:14
  31:     0x7f117c657f83 - std::rt::lang_start_internal::{{closure}}::hba10876b1ebd8163
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/rt.rs:148:48
  32:     0x7f117c657f83 - std::panicking::try::do_call::h4de9141859218b0f
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/panicking.rs:555:40
  33:     0x7f117c657f83 - std::panicking::try::h2528c2b62a63cf2f
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/panicking.rs:519:19
  34:     0x7f117c657f83 - std::panic::catch_unwind::h7b8241c110740d48
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/panic.rs:142:14
  35:     0x7f117c657f83 - std::rt::lang_start_internal::h65f44bcaf429c087
                               at /rustc/52cea084bd5bbac12ecfa5c0499f5c777025c968/library/std/src/rt.rs:148:20
  36:     0x564134be9f95 - main
  37:     0x7f1176158cd0 - <unknown>
  38:     0x7f1176158d8a - __libc_start_main
  39:     0x564134bbc699 - <unknown>
  40:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rustfmt/issues/new?labels=bug

note: please attach the file at `/tmp/im/rustc-ice-2024-02-23T17_30_19-757026.txt` to your bug report

query stack during panic:
end of query stack

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Feb 23, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 23, 2024
@matthiaskrgr
Copy link
Member Author

cc @nnethercote

@nnethercote
Copy link
Contributor

Probably a duplicate of #121450, and hopefully will be fixed by #121487.

@matthiaskrgr
Copy link
Member Author

no, I checked, while #121450 is fixed, this one isn't :(

@saethlin saethlin added A-diagnostics Area: Messages for errors, warnings, and lints and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 25, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 26, 2024
Move `emit_stashed_diagnostic` call in rustfmt.

This call was added to `parse_crate_mod` in rust-lang#121487, to fix a case where a stashed diagnostic wasn't emitted. But there is another path where a stashed diagnostic might fail to be emitted if there's a parse error, if the `build` call in `parse_crate_inner` fails before `parse_crate_mod` is reached.

So this commit moves the `emit_stashed_diagnostic` call outwards, from `parse_crate_mod` to `format_project`, just after the `Parser::parse_crate` call. This should be far out enough to catch any parsing errors.

Fixes rust-lang#121517.

r? `@oli-obk`
cc `@ytmimi`
@bors bors closed this as completed in bf7d1b5 Feb 26, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 26, 2024
Rollup merge of rust-lang#121615 - nnethercote:fix-121517, r=oli-obk

Move `emit_stashed_diagnostic` call in rustfmt.

This call was added to `parse_crate_mod` in rust-lang#121487, to fix a case where a stashed diagnostic wasn't emitted. But there is another path where a stashed diagnostic might fail to be emitted if there's a parse error, if the `build` call in `parse_crate_inner` fails before `parse_crate_mod` is reached.

So this commit moves the `emit_stashed_diagnostic` call outwards, from `parse_crate_mod` to `format_project`, just after the `Parser::parse_crate` call. This should be far out enough to catch any parsing errors.

Fixes rust-lang#121517.

r? `@oli-obk`
cc `@ytmimi`
calebcartwright pushed a commit to calebcartwright/rust that referenced this issue Jun 22, 2024
This call was added to `parse_crate_mod` in rust-lang#121487, to fix a case where
a stashed diagnostic wasn't emitted. But there is another path where a
stashed diagnostic might fail to be emitted if there's a parse error, if
the `build` call in `parse_crate_inner` fails before `parse_crate_mod`
is reached.

So this commit moves the `emit_stashed_diagnostic` call outwards, from
`parse_crate_mod` to `format_project`, just after the
`Parser::parse_crate` call. This should be far out enough to catch any
parsing errors.

Fixes rust-lang#121517.
calebcartwright pushed a commit to calebcartwright/rust that referenced this issue Jun 22, 2024
Move `emit_stashed_diagnostic` call in rustfmt.

This call was added to `parse_crate_mod` in rust-lang#121487, to fix a case where a stashed diagnostic wasn't emitted. But there is another path where a stashed diagnostic might fail to be emitted if there's a parse error, if the `build` call in `parse_crate_inner` fails before `parse_crate_mod` is reached.

So this commit moves the `emit_stashed_diagnostic` call outwards, from `parse_crate_mod` to `format_project`, just after the `Parser::parse_crate` call. This should be far out enough to catch any parsing errors.

Fixes rust-lang#121517.

r? `@oli-obk`
cc `@ytmimi`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants