From c01985387d8c00e04acc87d04d52e3a5e5c82c10 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 22 Dec 2022 12:43:27 -0600 Subject: [PATCH] Make `sess.bug` much less noisy Before: ``` Compiling core v0.0.0 (C:\Users\Joshua Nelson\src\rust2\library\core) error: internal compiler error: no warnings or errors encountered even though `delayed_good_path_bugs` issued error: internal compiler error: oops | = note: delayed at 0: std::backtrace_rs::backtrace::trace_unsynchronized 1: std::backtrace::Backtrace::disabled 2: std::backtrace::Backtrace::force_capture 3: ::delay_good_path_bug::<&str> 4: ::enter::> 5: RINvMs2_NtCsiwHPejSviHg_15rustc_interface7queriesNtNtB8_9interface8Compiler5enterNCNCNvCs7PhwInflpyf_12rustc_driver12run_compilers_0s0_0INtNtCslM5znELOk5i_4core6result6ResultINtNtB2f_6option6OptionNtB6_6LinkerENtCshthk7JDUYGg_12rustc_errors15ErrorGuarante 6: RINvCs6uSsza6NDuD_10rustc_span15with_source_mapINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_errors15ErrorGuaranteedENCNCINvNtCsiwHPejSviHg_15rustc_interface9interface12run_compilerBJ_NCNvCs7PhwInflpyf_12rustc_driver12run_compilers_0E00EB 7: RINvMs_Cs9yvsqs6YnUZ_10scoped_tlsINtB5_9ScopedKeyNtCs6uSsza6NDuD_10rustc_span14SessionGlobalsE3setNCINvNtCsiwHPejSviHg_15rustc_interface9interface12run_compilerINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_errors15ErrorGuaranteedENCNvCs7P 8: RINvNtNtCs5xszGlR5JQw_3std10sys_common9backtrace28___rust_begin_short_backtraceNCNCINvNtCsiwHPejSviHg_15rustc_interface4util31run_in_thread_pool_with_globalsNCINvNtB1o_9interface12run_compilerINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_ 9: RINvNtCs5xszGlR5JQw_3std9panicking3tryINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_errors15ErrorGuaranteedEINtNtNtBF_5panic11unwind_safe16AssertUnwindSafeNCNCINvMNtB4_6threadNtB2S_7Builder16spawn_unchecked_NCNCINvNtCsiwHPejSviHg_15rustc_ 10: ::spawn_scoped::::{closure#0}, ()>::{closure#0}::{closure#0}, ()> 11: as core::ops::function::FnOnce>::call_once 12: std::sys::windows::thread::Thread::new 13: BaseThreadInitThunk 14: RtlUserThreadStart thread 'rustc' panicked at 'Box', compiler\rustc_errors\src\lib.rs:1610:13 stack backtrace: 0: 0x7fffbe935a15 - std::backtrace_rs::backtrace::trace_unsynchronized::h2a29ea0a35c1f799 1: 0x7fffbe968811 - ::fmt::h5e4ca8af47bfbcc0 2: 0x7fffbe98aeab - core::fmt::write::h152a9de2569e7dc7 3: 0x7fffbe961059 - std::io::Write::write_fmt::h2452e19093defac4 4: 0x7fffbe96866b - std::sys_common::backtrace::print::h550d034f7b77d60a 5: 0x7fffbe93be1b - std::panicking::default_hook::h3969ead74039b801 6: 0x7fffbe93bbad - std::panicking::default_hook::h3969ead74039b801 7: 0x7fffa5f0abe3 - rustc_driver[5b2ae43fbecaf219]::handle_options 8: 0x7fffbe93c25b - std::panicking::rust_panic_with_hook::h32bbe3ce24999160 9: 0x7fffa82baee5 - std[4086331e48bff2f6]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 10: 0x7fffa82bae89 - std[4086331e48bff2f6]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 11: 0x7fffa867ed89 - std[4086331e48bff2f6]::panicking::begin_panic:: 12: 0x7fffa8298de9 - ::write_fmt 13: 0x7fffa829b7e2 - ::flush_delayed::, ::decorate>, &str> 14: 0x7fffa8288638 - ::drop 15: 0x7fffa5eb90e1 - core[fda266aeadfb153a]::ptr::drop_in_place:: 16: 0x7fffa5ebe9fd - core[fda266aeadfb153a]::ptr::drop_in_place:: 17: 0x7fffa5ec0d7c - core[fda266aeadfb153a]::ptr::drop_in_place:: 18: 0x7fffa5ebe41c - core[fda266aeadfb153a]::ptr::drop_in_place:: 19: 0x7fffa5eea05f - RINvCs6uSsza6NDuD_10rustc_span15with_source_mapINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_errors15ErrorGuaranteedENCNCINvNtCsiwHPejSviHg_15rustc_interface9interface12run_compilerBJ_NCNvCs7PhwInflpyf_12rustc_driver12run_compilers_0E00EB 20: 0x7fffa5edbe3a - RINvMs_Cs9yvsqs6YnUZ_10scoped_tlsINtB5_9ScopedKeyNtCs6uSsza6NDuD_10rustc_span14SessionGlobalsE3setNCINvNtCsiwHPejSviHg_15rustc_interface9interface12run_compilerINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_errors15ErrorGuaranteedENCNvCs7P 21: 0x7fffa5ef4ec9 - RINvNtNtCs5xszGlR5JQw_3std10sys_common9backtrace28___rust_begin_short_backtraceNCNCINvNtCsiwHPejSviHg_15rustc_interface4util31run_in_thread_pool_with_globalsNCINvNtB1o_9interface12run_compilerINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_ 22: 0x7fffa5ee9935 - RINvNtCs5xszGlR5JQw_3std9panicking3tryINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_errors15ErrorGuaranteedEINtNtNtBF_5panic11unwind_safe16AssertUnwindSafeNCNCINvMNtB4_6threadNtB2S_7Builder16spawn_unchecked_NCNCINvNtCsiwHPejSviHg_15rustc_ 23: 0x7fffa5f0d770 - ::spawn_scoped::::{closure#0}, ()>::{closure#0}::{closure#0}, ()> 24: 0x7fffbe95b35b - as core::ops::function::FnOnce>::call_once::hfcd927f7aebafa45 25: 0x7fffbe9331d3 - std::sys::windows::thread::Thread::new::hf8f4c920eaebd965 26: 0x7ff815877614 - BaseThreadInitThunk 27: 0x7ff8166e26a1 - RtlUserThreadStart 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.68.0-dev running on x86_64-pc-windows-msvc note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -Z unstable-options -C incremental=[REDACTED] -C symbol-mangling-version=legacy -Z unstable-options -Z unstable-options -Z macro-backtrace -C split-debuginfo=packed -C target-feature=+crt-static -C prefer-dynamic -C embed-bitcode=yes -Z crate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/") -Z binary-dep-depinfo -Z force-unstable-if-unmarked note: some of the compiler flags provided by cargo are hidden query stack during panic: end of query stack error: could not compile `core` ``` After: ``` Compiling core v0.0.0 (C:\Users\Joshua Nelson\src\rust2\library\core) error: internal compiler error: no warnings or errors encountered even though `delayed_good_path_bugs` issued error: internal compiler error: oops | = note: delayed at 0: std::backtrace_rs::backtrace::trace_unsynchronized 1: std::backtrace::Backtrace::disabled 2: std::backtrace::Backtrace::force_capture 3: ::delay_good_path_bug::<&str> 4: ::enter::> 5: RINvMs2_NtCsiwHPejSviHg_15rustc_interface7queriesNtNtB8_9interface8Compiler5enterNCNCNvCs7PhwInflpyf_12rustc_driver12run_compilers_0s0_0INtNtCslM5znELOk5i_4core6result6ResultINtNtB2f_6option6OptionNtB6_6LinkerENtCshthk7JDUYGg_12rustc_errors15ErrorGuarante 6: RINvCs6uSsza6NDuD_10rustc_span15with_source_mapINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_errors15ErrorGuaranteedENCNCINvNtCsiwHPejSviHg_15rustc_interface9interface12run_compilerBJ_NCNvCs7PhwInflpyf_12rustc_driver12run_compilers_0E00EB 7: RINvMs_Cs9yvsqs6YnUZ_10scoped_tlsINtB5_9ScopedKeyNtCs6uSsza6NDuD_10rustc_span14SessionGlobalsE3setNCINvNtCsiwHPejSviHg_15rustc_interface9interface12run_compilerINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_errors15ErrorGuaranteedENCNvCs7P 8: RINvNtNtCs5xszGlR5JQw_3std10sys_common9backtrace28___rust_begin_short_backtraceNCNCINvNtCsiwHPejSviHg_15rustc_interface4util31run_in_thread_pool_with_globalsNCINvNtB1o_9interface12run_compilerINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_ 9: RINvNtCs5xszGlR5JQw_3std9panicking3tryINtNtCslM5znELOk5i_4core6result6ResultuNtCshthk7JDUYGg_12rustc_errors15ErrorGuaranteedEINtNtNtBF_5panic11unwind_safe16AssertUnwindSafeNCNCINvMNtB4_6threadNtB2S_7Builder16spawn_unchecked_NCNCINvNtCsiwHPejSviHg_15rustc_ 10: ::spawn_scoped::::{closure#0}, ()>::{closure#0}::{closure#0}, ()> 11: as core::ops::function::FnOnce>::call_once 12: std::sys::windows::thread::Thread::new 13: BaseThreadInitThunk 14: RtlUserThreadStart 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.68.0-dev running on x86_64-pc-windows-msvc note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -Z unstable-options -C incremental=[REDACTED] -C symbol-mangling-version=legacy -Z unstable-options -Z unstable-options -Z macro-backtrace -C split-debuginfo=packed -C target-feature=+crt-static -C prefer-dynamic -C embed-bitcode=yes -Z crate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/") -Z binary-dep-depinfo -Z force-unstable-if-unmarked note: some of the compiler flags provided by cargo are hidden query stack during panic: end of query stack error: could not compile `core` ``` --- compiler/rustc_driver/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 711eed2b27231..236f66eae72c3 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1199,10 +1199,13 @@ static DEFAULT_HOOK: LazyLock) + Sync + Send + }; // Invoke the default handler, which prints the actual panic message and optionally a backtrace - (*DEFAULT_HOOK)(info); + // Don't do this for `ExplicitBug`, which has an unhelpful message and backtrace. + if !info.payload().is::() { + (*DEFAULT_HOOK)(info); - // Separate the output with an empty line - eprintln!(); + // Separate the output with an empty line + eprintln!(); + } // Print the ICE message report_ice(info, BUG_REPORT_URL);