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 is not getting backtraces anymore #111529

Open
matthiaskrgr opened this issue May 13, 2023 · 7 comments
Open

rustfmt is not getting backtraces anymore #111529

matthiaskrgr opened this issue May 13, 2023 · 7 comments
Labels
A-parser Area: The parsing of Rust source code to an AST A-rustfmt Area: Rustfmt C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

with beta:

Backtrace

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>

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 2469afe ? cc @jyn514

File to make rustfmt crash is attached (--check is sufficient)
ice.rs.zip

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. A-rustfmt Area: Rustfmt labels May 13, 2023
@jyn514
Copy link
Member

jyn514 commented May 18, 2023

Something was already wrong before that change - the panic was just the generic Box<dyn Any> panic, it should have had a message about the delay_span_bug:

thread 'main' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1679:13

the hook hides that backtrace because it assumes there was another panic before, but there isn't one in this case.

cc @rust-lang/rustfmt

@jyn514
Copy link
Member

jyn514 commented May 18, 2023

This looks relevant:

// Suppress error output if we have to do any further parsing.
context.parse_session.set_silent_emitter();

@jyn514
Copy link
Member

jyn514 commented May 18, 2023

If it helps, here's the original error if it isn't silenced:

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: expected one of `,` or `>`, found `=>`
  --> /home/jyn/src/rust/rustfmt-crash.rs:56:54
   |
56 |                     assert!(cx.tcx.PrimVal::Bytes(b) => {
   |                                                      ^^ expected one of `,` or `>`
   |
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
              2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic_builder::EmissionGuarantee>::diagnostic_builder_emit_producing_guarantee
                        at ./compiler/rustc_errors/src/diagnostic_builder.rs:169:28
              3: <rustc_parse::parser::Parser>::handle_ambiguous_unbraced_const_arg
                        at ./compiler/rustc_parse/src/parser/diagnostics.rs:2172:17
              4: <rustc_parse::parser::Parser>::parse_angle_args
                        at ./compiler/rustc_parse/src/parser/path.rs:566:24
              5: <rustc_parse::parser::Parser>::parse_expr_dot_or_call_with_
                        at ./compiler/rustc_parse/src/parser/diagnostics.rs:924:19
              6: <rustc_parse::parser::Parser>::parse_expr_dot_or_call_with
                        at ./compiler/rustc_parse/src/parser/expr.rs:936:19
              7: <rustc_parse::parser::Parser>::collect_tokens_for_expr::<<rustc_parse::parser::Parser>::parse_expr_dot_or_call::{closure#0}>::{closure#0}
                        at ./compiler/rustc_parse/src/parser/expr.rs:923:13
              8: <rustc_parse::parser::Parser>::collect_tokens_for_expr::<<rustc_parse::parser::Parser>::parse_expr_dot_or_call::{closure#0}>
                        at ./compiler/rustc_parse/src/parser/attr_wrapper.rs:213:23
              9: <rustc_parse::parser::Parser>::parse_expr_prefix
                        at ./compiler/rustc_parse/src/parser/expr.rs:920:9
             10: <rustc_parse::parser::Parser>::parse_expr_assoc_with
                        at ./compiler/rustc_parse/src/parser/expr.rs:174:17
             11: <rustc_parse::parser::Parser>::with_res::<core::result::Result<rustc_ast::ptr::P<rustc_ast::ast::Expr>, rustc_errors::diagnostic_builder::DiagnosticBuilder<rustc_span::ErrorGuaranteed>>, <rustc_parse::parser::Parser>::parse_expr_res::{closure#0}>
                        at ./compiler/rustc_parse/src/parser/expr.rs:153:9
             12: rustfmt_nightly::parse::macros::parse_macro_arg
                        at ./compiler/rustc_parse/src/parser/expr.rs:141:9
             13: rustfmt_nightly::parse::macros::parse_macro_args
                        at ./src/tools/rustfmt/src/parse/macros/mod.rs:110:39
             14: rustfmt_nightly::macros::rewrite_macro_inner
                        at ./src/tools/rustfmt/src/macros.rs:239:15
             15: <core::panic::unwind_safe::AssertUnwindSafe<rustfmt_nightly::macros::rewrite_macro::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
                        at ./src/tools/rustfmt/src/macros.rs:167:13
             16: std::panicking::try::<core::option::Option<alloc::string::String>, core::panic::unwind_safe::AssertUnwindSafe<rustfmt_nightly::macros::rewrite_macro::{closure#0}>>
                        at ./library/std/src/panicking.rs:485:40
             17: rustfmt_nightly::macros::rewrite_macro
                        at ./library/std/src/panic.rs:142:14
             18: <rustfmt_nightly::visitor::FmtVisitor>::with_context::<<rustfmt_nightly::visitor::FmtVisitor>::visit_mac::{closure#0}>
                        at ./src/tools/rustfmt/src/visitor.rs:686:47
             19: <rustfmt_nightly::visitor::FmtVisitor>::visit_mac
                        at ./src/tools/rustfmt/src/visitor.rs:686:23
             20: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
                        at ./src/tools/rustfmt/src/visitor.rs:178:21
             21: <rustfmt_nightly::visitor::FmtVisitor>::visit_block
                        at ./src/tools/rustfmt/src/visitor.rs:911:9
             22: rustfmt_nightly::expr::rewrite_block_with_visitor
                        at ./src/tools/rustfmt/src/expr.rs:557:5
             23: rustfmt_nightly::expr::format_expr
                        at ./src/tools/rustfmt/src/expr.rs:152:25
             24: <rustfmt_nightly::matches::ArmWrapper as rustfmt_nightly::rewrite::Rewrite>::rewrite
                        at ./src/tools/rustfmt/src/matches.rs:472:13
             25: <rustfmt_nightly::lists::ListItems<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::zip::Zip<core::slice::iter::Iter<rustc_ast::ast::Arm>, core::iter::adapters::chain::Chain<core::iter::adapters::take::Take<core::iter::sources::repeat::Repeat<bool>>, core::iter::sources::repeat::Repeat<bool>>>, alloc::vec::into_iter::IntoIter<core::option::Option<rustc_span::BytePos>>>, rustfmt_nightly::matches::rewrite_match_arms::{closure#0}>, rustfmt_nightly::matches::rewrite_match_arms::{closure#1}, rustfmt_nightly::matches::rewrite_match_arms::{closure#2}, rustfmt_nightly::matches::rewrite_match_arms::{closure#3}> as core::iter::traits::iterator::Iterator>::next
                        at ./src/tools/rustfmt/src/matches.rs:203:15
             26: <alloc::vec::Vec<rustfmt_nightly::lists::ListItem> as alloc::vec::spec_from_iter::SpecFromIter<rustfmt_nightly::lists::ListItem, rustfmt_nightly::lists::ListItems<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::zip::Zip<core::slice::iter::Iter<rustc_ast::ast::Arm>, core::iter::adapters::chain::Chain<core::iter::adapters::take::Take<core::iter::sources::repeat::Repeat<bool>>, core::iter::sources::repeat::Repeat<bool>>>, alloc::vec::into_iter::IntoIter<core::option::Option<rustc_span::BytePos>>>, rustfmt_nightly::matches::rewrite_match_arms::{closure#0}>, rustfmt_nightly::matches::rewrite_match_arms::{closure#1}, rustfmt_nightly::matches::rewrite_match_arms::{closure#2}, rustfmt_nightly::matches::rewrite_match_arms::{closure#3}>>>::from_iter
                        at ./library/alloc/src/vec/mod.rs:2812:35
             27: rustfmt_nightly::matches::rewrite_match
                        at ./library/alloc/src/vec/mod.rs:2712:9
             28: rustfmt_nightly::expr::format_expr
                        at ./src/tools/rustfmt/src/expr.rs:169:13
             29: rustfmt_nightly::expr::rewrite_assign_rhs_expr::<rustc_ast::ast::Expr>
                        at ./src/tools/rustfmt/src/expr.rs:41:9
             30: rustfmt_nightly::expr::rewrite_assign_rhs_with::<alloc::string::String, rustc_ast::ast::Expr>
                        at ./src/tools/rustfmt/src/expr.rs:1994:15
             31: <rustc_ast::ast::Local as rustfmt_nightly::rewrite::Rewrite>::rewrite
                        at ./src/tools/rustfmt/src/expr.rs:1946:5
             32: rustfmt_nightly::stmt::format_stmt
                        at ./src/tools/rustfmt/src/rewrite.rs:23:9
             33: <rustfmt_nightly::stmt::Stmt as rustfmt_nightly::rewrite::Rewrite>::rewrite
                        at ./src/tools/rustfmt/src/stmt.rs:83:9
             34: <rustfmt_nightly::visitor::FmtVisitor>::with_context::<<rustfmt_nightly::visitor::FmtVisitor>::visit_stmt::{closure#2}>
                        at ./src/tools/rustfmt/src/visitor.rs:166:59
             35: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
                        at ./src/tools/rustfmt/src/visitor.rs:166:35
             36: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
             37: <rustfmt_nightly::visitor::FmtVisitor>::visit_block
                        at ./src/tools/rustfmt/src/visitor.rs:911:9
             38: rustfmt_nightly::expr::rewrite_block_with_visitor
                        at ./src/tools/rustfmt/src/expr.rs:557:5
             39: rustfmt_nightly::expr::format_expr
                        at ./src/tools/rustfmt/src/expr.rs:152:25
             40: <rustfmt_nightly::matches::ArmWrapper as rustfmt_nightly::rewrite::Rewrite>::rewrite
                        at ./src/tools/rustfmt/src/matches.rs:472:13
             41: <rustfmt_nightly::lists::ListItems<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::zip::Zip<core::slice::iter::Iter<rustc_ast::ast::Arm>, core::iter::adapters::chain::Chain<core::iter::adapters::take::Take<core::iter::sources::repeat::Repeat<bool>>, core::iter::sources::repeat::Repeat<bool>>>, alloc::vec::into_iter::IntoIter<core::option::Option<rustc_span::BytePos>>>, rustfmt_nightly::matches::rewrite_match_arms::{closure#0}>, rustfmt_nightly::matches::rewrite_match_arms::{closure#1}, rustfmt_nightly::matches::rewrite_match_arms::{closure#2}, rustfmt_nightly::matches::rewrite_match_arms::{closure#3}> as core::iter::traits::iterator::Iterator>::next
                        at ./src/tools/rustfmt/src/matches.rs:203:15
             42: <alloc::vec::Vec<rustfmt_nightly::lists::ListItem> as alloc::vec::spec_from_iter::SpecFromIter<rustfmt_nightly::lists::ListItem, rustfmt_nightly::lists::ListItems<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::zip::Zip<core::slice::iter::Iter<rustc_ast::ast::Arm>, core::iter::adapters::chain::Chain<core::iter::adapters::take::Take<core::iter::sources::repeat::Repeat<bool>>, core::iter::sources::repeat::Repeat<bool>>>, alloc::vec::into_iter::IntoIter<core::option::Option<rustc_span::BytePos>>>, rustfmt_nightly::matches::rewrite_match_arms::{closure#0}>, rustfmt_nightly::matches::rewrite_match_arms::{closure#1}, rustfmt_nightly::matches::rewrite_match_arms::{closure#2}, rustfmt_nightly::matches::rewrite_match_arms::{closure#3}>>>::from_iter
                        at ./library/alloc/src/vec/mod.rs:2812:35
             43: rustfmt_nightly::matches::rewrite_match
                        at ./library/alloc/src/vec/mod.rs:2712:9
             44: rustfmt_nightly::expr::format_expr
                        at ./src/tools/rustfmt/src/expr.rs:169:13
             45: rustfmt_nightly::stmt::format_stmt
                        at ./src/tools/rustfmt/src/stmt.rs:111:13
             46: <rustfmt_nightly::stmt::Stmt as rustfmt_nightly::rewrite::Rewrite>::rewrite
                        at ./src/tools/rustfmt/src/stmt.rs:83:9
             47: <rustfmt_nightly::visitor::FmtVisitor>::with_context::<<rustfmt_nightly::visitor::FmtVisitor>::visit_stmt::{closure#2}>
                        at ./src/tools/rustfmt/src/visitor.rs:166:59
             48: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
                        at ./src/tools/rustfmt/src/visitor.rs:166:35
             49: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
             50: <rustfmt_nightly::visitor::FmtVisitor>::visit_block
                        at ./src/tools/rustfmt/src/visitor.rs:911:9
             51: <rustfmt_nightly::visitor::FmtVisitor>::visit_fn
                        at ./src/tools/rustfmt/src/visitor.rs:427:9
             52: <rustfmt_nightly::visitor::FmtVisitor>::visit_item
                        at ./src/tools/rustfmt/src/visitor.rs:553:25
             53: <rustfmt_nightly::visitor::FmtVisitor>::visit_items_with_reordering
                        at ./src/tools/rustfmt/src/reorder.rs:325:17
             54: <rustfmt_nightly::visitor::FmtVisitor>::format_separate_mod
                        at ./src/tools/rustfmt/src/visitor.rs:864:9
             55: rustfmt_nightly::formatting::format_project::<rustfmt_nightly::Session<std::io::stdio::Stdout>>
                        at ./src/tools/rustfmt/src/formatting.rs:213:9
             56: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::with::<<rustfmt_nightly::Session<std::io::stdio::Stdout>>::format_input_inner::{closure#0}, core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>>
                        at ./src/tools/rustfmt/src/formatting.rs:48:33
             57: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_span::create_session_if_not_set_then<core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>, <rustfmt_nightly::Session<std::io::stdio::Stdout>>::format_input_inner::{closure#0}>::{closure#0}, core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>>
                        at ./compiler/rustc_span/src/lib.rs:148:50
             58: <rustfmt_nightly::Session<std::io::stdio::Stdout>>::format
                        at ./compiler/rustc_span/src/lib.rs:148:9
             59: rustfmt::format_and_emit_report::<std::io::stdio::Stdout>
                        at ./src/tools/rustfmt/src/bin/main.rs:368:11
             60: <rustfmt_nightly::Session<std::io::stdio::Stdout>>::override_config::<rustfmt::format::{closure#0}, ()>
                        at ./src/tools/rustfmt/src/bin/main.rs:340:21
             61: rustfmt::execute
                        at ./src/tools/rustfmt/src/bin/main.rs:339:17
             62: rustfmt::main
                        at ./src/tools/rustfmt/src/bin/main.rs:35:27
             63: std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
                        at ./library/core/src/ops/function.rs:250:5
             64: std::rt::lang_start::<()>::{closure#0}
                        at ./library/std/src/rt.rs:166:18
             65: std::panicking::try
             66: std::rt::lang_start_internal
             67: main
             68: __libc_start_call_main
                        at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
             69: __libc_start_main_impl
                        at ./csu/../csu/libc-start.c:392:3
             70: _start
           

error: internal compiler error: expected one of `,` or `>`, found `=>`
  --> /home/jyn/src/rust/rustfmt-crash.rs:56:54
   |
56 |                     assert!(cx.tcx.PrimVal::Bytes(b) => {
   |                                                      ^^ expected one of `,` or `>`
   |
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
              2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic_builder::EmissionGuarantee>::diagnostic_builder_emit_producing_guarantee
                        at ./compiler/rustc_errors/src/diagnostic_builder.rs:169:28
              3: <rustc_parse::parser::Parser>::handle_ambiguous_unbraced_const_arg
                        at ./compiler/rustc_parse/src/parser/diagnostics.rs:2172:17
              4: <rustc_parse::parser::Parser>::parse_angle_args
                        at ./compiler/rustc_parse/src/parser/path.rs:566:24
              5: <rustc_parse::parser::Parser>::parse_expr_dot_or_call_with_
                        at ./compiler/rustc_parse/src/parser/diagnostics.rs:924:19
              6: <rustc_parse::parser::Parser>::parse_expr_dot_or_call_with
                        at ./compiler/rustc_parse/src/parser/expr.rs:936:19
              7: <rustc_parse::parser::Parser>::collect_tokens_for_expr::<<rustc_parse::parser::Parser>::parse_expr_dot_or_call::{closure#0}>::{closure#0}
                        at ./compiler/rustc_parse/src/parser/expr.rs:923:13
              8: <rustc_parse::parser::Parser>::collect_tokens_for_expr::<<rustc_parse::parser::Parser>::parse_expr_dot_or_call::{closure#0}>
                        at ./compiler/rustc_parse/src/parser/attr_wrapper.rs:213:23
              9: <rustc_parse::parser::Parser>::parse_expr_prefix
                        at ./compiler/rustc_parse/src/parser/expr.rs:920:9
             10: <rustc_parse::parser::Parser>::parse_expr_assoc_with
                        at ./compiler/rustc_parse/src/parser/expr.rs:174:17
             11: <rustc_parse::parser::Parser>::with_res::<core::result::Result<rustc_ast::ptr::P<rustc_ast::ast::Expr>, rustc_errors::diagnostic_builder::DiagnosticBuilder<rustc_span::ErrorGuaranteed>>, <rustc_parse::parser::Parser>::parse_expr_res::{closure#0}>
                        at ./compiler/rustc_parse/src/parser/expr.rs:153:9
             12: rustfmt_nightly::parse::macros::parse_macro_arg
                        at ./compiler/rustc_parse/src/parser/expr.rs:141:9
             13: rustfmt_nightly::parse::macros::parse_macro_args
                        at ./src/tools/rustfmt/src/parse/macros/mod.rs:110:39
             14: rustfmt_nightly::macros::rewrite_macro_inner
                        at ./src/tools/rustfmt/src/macros.rs:239:15
             15: <core::panic::unwind_safe::AssertUnwindSafe<rustfmt_nightly::macros::rewrite_macro::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
                        at ./src/tools/rustfmt/src/macros.rs:167:13
             16: std::panicking::try::<core::option::Option<alloc::string::String>, core::panic::unwind_safe::AssertUnwindSafe<rustfmt_nightly::macros::rewrite_macro::{closure#0}>>
                        at ./library/std/src/panicking.rs:485:40
             17: rustfmt_nightly::macros::rewrite_macro
                        at ./library/std/src/panic.rs:142:14
             18: <rustfmt_nightly::visitor::FmtVisitor>::with_context::<<rustfmt_nightly::visitor::FmtVisitor>::visit_mac::{closure#0}>
                        at ./src/tools/rustfmt/src/visitor.rs:686:47
             19: <rustfmt_nightly::visitor::FmtVisitor>::visit_mac
                        at ./src/tools/rustfmt/src/visitor.rs:686:23
             20: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
                        at ./src/tools/rustfmt/src/visitor.rs:178:21
             21: <rustfmt_nightly::visitor::FmtVisitor>::visit_block
                        at ./src/tools/rustfmt/src/visitor.rs:911:9
             22: rustfmt_nightly::expr::rewrite_block_with_visitor
                        at ./src/tools/rustfmt/src/expr.rs:557:5
             23: rustfmt_nightly::expr::format_expr
                        at ./src/tools/rustfmt/src/expr.rs:152:25
             24: <rustfmt_nightly::matches::ArmWrapper as rustfmt_nightly::rewrite::Rewrite>::rewrite
                        at ./src/tools/rustfmt/src/matches.rs:472:13
             25: <rustfmt_nightly::lists::ListItems<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::zip::Zip<core::slice::iter::Iter<rustc_ast::ast::Arm>, core::iter::adapters::chain::Chain<core::iter::adapters::take::Take<core::iter::sources::repeat::Repeat<bool>>, core::iter::sources::repeat::Repeat<bool>>>, alloc::vec::into_iter::IntoIter<core::option::Option<rustc_span::BytePos>>>, rustfmt_nightly::matches::rewrite_match_arms::{closure#0}>, rustfmt_nightly::matches::rewrite_match_arms::{closure#1}, rustfmt_nightly::matches::rewrite_match_arms::{closure#2}, rustfmt_nightly::matches::rewrite_match_arms::{closure#3}> as core::iter::traits::iterator::Iterator>::next
                        at ./src/tools/rustfmt/src/matches.rs:203:15
             26: <alloc::vec::Vec<rustfmt_nightly::lists::ListItem> as alloc::vec::spec_from_iter::SpecFromIter<rustfmt_nightly::lists::ListItem, rustfmt_nightly::lists::ListItems<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::zip::Zip<core::slice::iter::Iter<rustc_ast::ast::Arm>, core::iter::adapters::chain::Chain<core::iter::adapters::take::Take<core::iter::sources::repeat::Repeat<bool>>, core::iter::sources::repeat::Repeat<bool>>>, alloc::vec::into_iter::IntoIter<core::option::Option<rustc_span::BytePos>>>, rustfmt_nightly::matches::rewrite_match_arms::{closure#0}>, rustfmt_nightly::matches::rewrite_match_arms::{closure#1}, rustfmt_nightly::matches::rewrite_match_arms::{closure#2}, rustfmt_nightly::matches::rewrite_match_arms::{closure#3}>>>::from_iter
                        at ./library/alloc/src/vec/mod.rs:2812:35
             27: rustfmt_nightly::matches::rewrite_match
                        at ./library/alloc/src/vec/mod.rs:2712:9
             28: rustfmt_nightly::expr::format_expr
                        at ./src/tools/rustfmt/src/expr.rs:169:13
             29: rustfmt_nightly::expr::rewrite_assign_rhs_expr::<rustc_ast::ast::Expr>
                        at ./src/tools/rustfmt/src/expr.rs:41:9
             30: rustfmt_nightly::expr::rewrite_assign_rhs_with::<alloc::string::String, rustc_ast::ast::Expr>
                        at ./src/tools/rustfmt/src/expr.rs:1994:15
             31: <rustc_ast::ast::Local as rustfmt_nightly::rewrite::Rewrite>::rewrite
                        at ./src/tools/rustfmt/src/expr.rs:1946:5
             32: rustfmt_nightly::stmt::format_stmt
                        at ./src/tools/rustfmt/src/rewrite.rs:23:9
             33: <rustfmt_nightly::stmt::Stmt as rustfmt_nightly::rewrite::Rewrite>::rewrite
                        at ./src/tools/rustfmt/src/stmt.rs:83:9
             34: <rustfmt_nightly::visitor::FmtVisitor>::with_context::<<rustfmt_nightly::visitor::FmtVisitor>::visit_stmt::{closure#2}>
                        at ./src/tools/rustfmt/src/visitor.rs:166:59
             35: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
                        at ./src/tools/rustfmt/src/visitor.rs:166:35
             36: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
             37: <rustfmt_nightly::visitor::FmtVisitor>::visit_block
                        at ./src/tools/rustfmt/src/visitor.rs:911:9
             38: rustfmt_nightly::expr::rewrite_block_with_visitor
                        at ./src/tools/rustfmt/src/expr.rs:557:5
             39: rustfmt_nightly::expr::format_expr
                        at ./src/tools/rustfmt/src/expr.rs:152:25
             40: <rustfmt_nightly::matches::ArmWrapper as rustfmt_nightly::rewrite::Rewrite>::rewrite
                        at ./src/tools/rustfmt/src/matches.rs:472:13
             41: <rustfmt_nightly::lists::ListItems<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::zip::Zip<core::slice::iter::Iter<rustc_ast::ast::Arm>, core::iter::adapters::chain::Chain<core::iter::adapters::take::Take<core::iter::sources::repeat::Repeat<bool>>, core::iter::sources::repeat::Repeat<bool>>>, alloc::vec::into_iter::IntoIter<core::option::Option<rustc_span::BytePos>>>, rustfmt_nightly::matches::rewrite_match_arms::{closure#0}>, rustfmt_nightly::matches::rewrite_match_arms::{closure#1}, rustfmt_nightly::matches::rewrite_match_arms::{closure#2}, rustfmt_nightly::matches::rewrite_match_arms::{closure#3}> as core::iter::traits::iterator::Iterator>::next
                        at ./src/tools/rustfmt/src/matches.rs:203:15
             42: <alloc::vec::Vec<rustfmt_nightly::lists::ListItem> as alloc::vec::spec_from_iter::SpecFromIter<rustfmt_nightly::lists::ListItem, rustfmt_nightly::lists::ListItems<core::iter::adapters::map::Map<core::iter::adapters::zip::Zip<core::iter::adapters::zip::Zip<core::slice::iter::Iter<rustc_ast::ast::Arm>, core::iter::adapters::chain::Chain<core::iter::adapters::take::Take<core::iter::sources::repeat::Repeat<bool>>, core::iter::sources::repeat::Repeat<bool>>>, alloc::vec::into_iter::IntoIter<core::option::Option<rustc_span::BytePos>>>, rustfmt_nightly::matches::rewrite_match_arms::{closure#0}>, rustfmt_nightly::matches::rewrite_match_arms::{closure#1}, rustfmt_nightly::matches::rewrite_match_arms::{closure#2}, rustfmt_nightly::matches::rewrite_match_arms::{closure#3}>>>::from_iter
                        at ./library/alloc/src/vec/mod.rs:2812:35
             43: rustfmt_nightly::matches::rewrite_match
                        at ./library/alloc/src/vec/mod.rs:2712:9
             44: rustfmt_nightly::expr::format_expr
                        at ./src/tools/rustfmt/src/expr.rs:169:13
             45: rustfmt_nightly::stmt::format_stmt
                        at ./src/tools/rustfmt/src/stmt.rs:111:13
             46: <rustfmt_nightly::stmt::Stmt as rustfmt_nightly::rewrite::Rewrite>::rewrite
                        at ./src/tools/rustfmt/src/stmt.rs:83:9
             47: <rustfmt_nightly::visitor::FmtVisitor>::with_context::<<rustfmt_nightly::visitor::FmtVisitor>::visit_stmt::{closure#2}>
                        at ./src/tools/rustfmt/src/visitor.rs:166:59
             48: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
                        at ./src/tools/rustfmt/src/visitor.rs:166:35
             49: <rustfmt_nightly::visitor::FmtVisitor>::walk_stmts
             50: <rustfmt_nightly::visitor::FmtVisitor>::visit_block
                        at ./src/tools/rustfmt/src/visitor.rs:911:9
             51: <rustfmt_nightly::visitor::FmtVisitor>::visit_fn
                        at ./src/tools/rustfmt/src/visitor.rs:427:9
             52: <rustfmt_nightly::visitor::FmtVisitor>::visit_item
                        at ./src/tools/rustfmt/src/visitor.rs:553:25
             53: <rustfmt_nightly::visitor::FmtVisitor>::visit_items_with_reordering
                        at ./src/tools/rustfmt/src/reorder.rs:325:17
             54: <rustfmt_nightly::visitor::FmtVisitor>::format_separate_mod
                        at ./src/tools/rustfmt/src/visitor.rs:864:9
             55: rustfmt_nightly::formatting::format_project::<rustfmt_nightly::Session<std::io::stdio::Stdout>>
                        at ./src/tools/rustfmt/src/formatting.rs:213:9
             56: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::with::<<rustfmt_nightly::Session<std::io::stdio::Stdout>>::format_input_inner::{closure#0}, core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>>
                        at ./src/tools/rustfmt/src/formatting.rs:48:33
             57: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_span::create_session_if_not_set_then<core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>, <rustfmt_nightly::Session<std::io::stdio::Stdout>>::format_input_inner::{closure#0}>::{closure#0}, core::result::Result<rustfmt_nightly::FormatReport, rustfmt_nightly::ErrorKind>>
                        at ./compiler/rustc_span/src/lib.rs:148:50
             58: <rustfmt_nightly::Session<std::io::stdio::Stdout>>::format
                        at ./compiler/rustc_span/src/lib.rs:148:9
             59: rustfmt::format_and_emit_report::<std::io::stdio::Stdout>
                        at ./src/tools/rustfmt/src/bin/main.rs:368:11
             60: <rustfmt_nightly::Session<std::io::stdio::Stdout>>::override_config::<rustfmt::format::{closure#0}, ()>
                        at ./src/tools/rustfmt/src/bin/main.rs:340:21
             61: rustfmt::execute
                        at ./src/tools/rustfmt/src/bin/main.rs:339:17
             62: rustfmt::main
                        at ./src/tools/rustfmt/src/bin/main.rs:35:27
             63: std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
                        at ./library/core/src/ops/function.rs:250:5
             64: std::rt::lang_start::<()>::{closure#0}
                        at ./library/std/src/rt.rs:166:18
             65: std::panicking::try
             66: std::rt::lang_start_internal
             67: main
             68: __libc_start_call_main
                        at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
             69: __libc_start_main_impl
                        at ./csu/../csu/libc-start.c:392:3
             70: _start

@jyn514
Copy link
Member

jyn514 commented May 18, 2023

./compiler/rustc_parse/src/parser/diagnostics.rs:2172:17

maybe this is an upstream bug?

match self.recover_const_arg(arg.span(), err) {
Ok(arg) => {
args.push(AngleBracketedArg::Arg(arg));
if self.eat(&token::Comma) {
return Ok(true); // Continue
}
}
Err(mut err) => {
args.push(arg);
// We will emit a more generic error later.
err.delay_as_bug();

@jyn514 jyn514 added A-parser Area: The parsing of Rust source code to an AST T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 18, 2023
@calebcartwright
Copy link
Member

Would it be best to revert the ice url change until this is sorted?

@jyn514
Copy link
Member

jyn514 commented May 18, 2023

I don't mind doing so, but I don't think it helps much, Box<dyn Error> isn't really an actionable panic message ...

@calebcartwright
Copy link
Member

calebcartwright commented May 19, 2023

I don't mind doing so, but I don't think it helps much, Box<dyn Error> isn't really an actionable panic message ...

I'm looking at more from the perspective of the value gained from the bug report url vs. the possibility of any other unknown impacts (not just the one message in this one case). To be clear I'm not necessarily pushing for this, just wondering what the potential blast radius could be; the bug report url is nice but not critically important.

I probably should've thought to ask when we were adding this, but do we expect the ice hook to work even though rustfmt doesn't actually use rustc_driver?

Wrt #111529 (comment), this is very intentional and not something we'd want to change. If that's going to be problematic for the custom bug url then I imagine we'd want to roll that back for rustfmt

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 19, 2023
…ler-errors

Give a more useful location for where a span_bug was delayed

Before:
```
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
...
```

After:
```
   = note: delayed at compiler/rustc_parse/src/parser/diagnostics.rs:2158:28
              0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
...
```

This both makes the relevant frame easier to find without having to dig through diagnostic internals, and avoids the weird-looking formatting for the first frame.

Found while working on rust-lang#111529.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 19, 2023
…ler-errors

Give a more useful location for where a span_bug was delayed

Before:
```
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
...
```

After:
```
   = note: delayed at compiler/rustc_parse/src/parser/diagnostics.rs:2158:28
              0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
...
```

This both makes the relevant frame easier to find without having to dig through diagnostic internals, and avoids the weird-looking formatting for the first frame.

Found while working on rust-lang#111529.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 19, 2023
…ler-errors

Give a more useful location for where a span_bug was delayed

Before:
```
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
...
```

After:
```
   = note: delayed at compiler/rustc_parse/src/parser/diagnostics.rs:2158:28
              0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
...
```

This both makes the relevant frame easier to find without having to dig through diagnostic internals, and avoids the weird-looking formatting for the first frame.

Found while working on rust-lang#111529.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue May 20, 2023
…ler-errors

Give a more useful location for where a span_bug was delayed

Before:
```
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
...
```

After:
```
   = note: delayed at compiler/rustc_parse/src/parser/diagnostics.rs:2158:28
              0: <rustc_errors::HandlerInner>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1335:29
              1: <rustc_errors::Handler>::emit_diagnostic
                        at ./compiler/rustc_errors/src/lib.rs:1124:9
...
```

This both makes the relevant frame easier to find without having to dig through diagnostic internals, and avoids the weird-looking formatting for the first frame.

Found while working on rust-lang#111529.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST A-rustfmt Area: Rustfmt C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants