From 17eb8d8b34a733640a0565e5ae589711f28c6e7a Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 17:51:24 +0430 Subject: [PATCH 01/20] ICEs should print the top of the query stack --- compiler/rustc_driver/src/lib.rs | 7 +------ compiler/rustc_middle/src/ty/query/plumbing.rs | 5 ++++- src/tools/clippy/src/driver.rs | 7 +------ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 066a61a7a7b..a6648639509 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1211,12 +1211,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { handler.note_without_error(¬e); } - // If backtraces are enabled, also print the query stack - let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false); - - if backtrace { - TyCtxt::try_print_query_stack(&handler); - } + TyCtxt::try_print_query_stack(&handler, Some(2)); #[cfg(windows)] unsafe { diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index f3fa3634026..6debd0cc7f3 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -124,7 +124,7 @@ impl<'tcx> TyCtxt<'tcx> { }) } - pub fn try_print_query_stack(handler: &Handler) { + pub fn try_print_query_stack(handler: &Handler, num_frames: Option) { eprintln!("query stack during panic:"); // Be careful reyling on global state here: this code is called from @@ -138,6 +138,9 @@ impl<'tcx> TyCtxt<'tcx> { let mut i = 0; while let Some(query) = current_query { + if i == num_frames.unwrap() { + break; + } let query_info = if let Some(info) = query_map.as_ref().and_then(|map| map.get(&query)) { info diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index f4f2259cefd..c88dffc88f4 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -274,12 +274,7 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { handler.note_without_error(¬e); } - // If backtraces are enabled, also print the query stack - let backtrace = env::var_os("RUST_BACKTRACE").map_or(false, |x| &x != "0"); - - if backtrace { - TyCtxt::try_print_query_stack(&handler); - } + TyCtxt::try_print_query_stack(&handler, Some(2)); } fn toolchain_path(home: Option, toolchain: Option) -> Option { From 20ea9290ed152b0c25cf4f54dbe2c4a269ecace7 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 18:37:58 +0430 Subject: [PATCH 02/20] run full query stack print just when RUST_BACKTRACE is set --- compiler/rustc_driver/src/lib.rs | 5 ++++- compiler/rustc_middle/src/ty/query/plumbing.rs | 10 +++++++--- src/tools/clippy/src/driver.rs | 5 ++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index a6648639509..177256008f8 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1211,7 +1211,10 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { handler.note_without_error(¬e); } - TyCtxt::try_print_query_stack(&handler, Some(2)); + // If backtraces are enabled, also print the query stack + let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false); + + TyCtxt::try_print_query_stack(&handler, Some(2), Some(backtrace)); #[cfg(windows)] unsafe { diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 6debd0cc7f3..239d5bce607 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -124,7 +124,11 @@ impl<'tcx> TyCtxt<'tcx> { }) } - pub fn try_print_query_stack(handler: &Handler, num_frames: Option) { + pub fn try_print_query_stack( + handler: &Handler, + num_frames: Option, + backtrace: Option, + ) { eprintln!("query stack during panic:"); // Be careful reyling on global state here: this code is called from @@ -138,9 +142,9 @@ impl<'tcx> TyCtxt<'tcx> { let mut i = 0; while let Some(query) = current_query { - if i == num_frames.unwrap() { + if backtrace.unwrap() == false && i == num_frames.unwrap() { break; - } + } let query_info = if let Some(info) = query_map.as_ref().and_then(|map| map.get(&query)) { info diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index c88dffc88f4..0b324775b0d 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -274,7 +274,10 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { handler.note_without_error(¬e); } - TyCtxt::try_print_query_stack(&handler, Some(2)); + // If backtraces are enabled, also print the query stack + let backtrace = env::var_os("RUST_BACKTRACE").map_or(false, |x| &x != "0"); + + TyCtxt::try_print_query_stack(&handler, Some(2), Some(backtrace)); } fn toolchain_path(home: Option, toolchain: Option) -> Option { From 7ccca35c66591607dff49fd1e6c93b380b072e42 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 22:05:04 +0430 Subject: [PATCH 03/20] fix invalid-punct-ident-1 test --- src/test/ui/proc-macro/invalid-punct-ident-1.rs | 3 +++ src/test/ui/proc-macro/invalid-punct-ident-1.stderr | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/ui/proc-macro/invalid-punct-ident-1.rs b/src/test/ui/proc-macro/invalid-punct-ident-1.rs index 3f78dea917b..a3133a1a790 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-1.rs +++ b/src/test/ui/proc-macro/invalid-punct-ident-1.rs @@ -9,6 +9,9 @@ // normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" // normalize-stderr-test "note: compiler flags.*\n\n" -> "" // normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" +// normalize-stderr-test "query stack during panic:\n" -> "" +// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> "" +// normalize-stderr-test "end of query stack\n" -> "" #[macro_use] extern crate invalid_punct_ident; diff --git a/src/test/ui/proc-macro/invalid-punct-ident-1.stderr b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr index fc821d29d5a..5ef22709cb3 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-1.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr @@ -1,5 +1,5 @@ error: proc macro panicked - --> $DIR/invalid-punct-ident-1.rs:16:1 + --> $DIR/invalid-punct-ident-1.rs:19:1 | LL | invalid_punct!(); | ^^^^^^^^^^^^^^^^^ From d6d4388ae78737891d10e15244dce2df7627fb46 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sun, 20 Sep 2020 17:07:55 +0430 Subject: [PATCH 04/20] add filter regexes to load-panic-backtraces test --- src/test/ui/proc-macro/invalid-punct-ident-2.rs | 3 +++ src/test/ui/proc-macro/invalid-punct-ident-2.stderr | 2 +- src/test/ui/proc-macro/invalid-punct-ident-3.rs | 3 +++ src/test/ui/proc-macro/invalid-punct-ident-3.stderr | 2 +- src/test/ui/proc-macro/load-panic-backtrace.rs | 3 +++ src/test/ui/proc-macro/load-panic-backtrace.stderr | 2 +- 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/test/ui/proc-macro/invalid-punct-ident-2.rs b/src/test/ui/proc-macro/invalid-punct-ident-2.rs index 4e89e80ae7c..04a0a873311 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-2.rs +++ b/src/test/ui/proc-macro/invalid-punct-ident-2.rs @@ -9,6 +9,9 @@ // normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" // normalize-stderr-test "note: compiler flags.*\n\n" -> "" // normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" +// normalize-stderr-test "query stack during panic:\n" -> "" +// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> "" +// normalize-stderr-test "end of query stack\n" -> "" #[macro_use] extern crate invalid_punct_ident; diff --git a/src/test/ui/proc-macro/invalid-punct-ident-2.stderr b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr index 8b30edaf85c..4bd7a5351d3 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-2.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr @@ -1,5 +1,5 @@ error: proc macro panicked - --> $DIR/invalid-punct-ident-2.rs:16:1 + --> $DIR/invalid-punct-ident-2.rs:19:1 | LL | invalid_ident!(); | ^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/proc-macro/invalid-punct-ident-3.rs b/src/test/ui/proc-macro/invalid-punct-ident-3.rs index 8d8ce8f932e..aebba341625 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-3.rs +++ b/src/test/ui/proc-macro/invalid-punct-ident-3.rs @@ -9,6 +9,9 @@ // normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" // normalize-stderr-test "note: compiler flags.*\n\n" -> "" // normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" +// normalize-stderr-test "query stack during panic:\n" -> "" +// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> "" +// normalize-stderr-test "end of query stack\n" -> "" #[macro_use] extern crate invalid_punct_ident; diff --git a/src/test/ui/proc-macro/invalid-punct-ident-3.stderr b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr index d46fab08e14..072d13956ac 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-3.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr @@ -1,5 +1,5 @@ error: proc macro panicked - --> $DIR/invalid-punct-ident-3.rs:16:1 + --> $DIR/invalid-punct-ident-3.rs:19:1 | LL | invalid_raw_ident!(); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/proc-macro/load-panic-backtrace.rs b/src/test/ui/proc-macro/load-panic-backtrace.rs index 90fe109abb8..4a3ba9aee74 100644 --- a/src/test/ui/proc-macro/load-panic-backtrace.rs +++ b/src/test/ui/proc-macro/load-panic-backtrace.rs @@ -10,6 +10,9 @@ // normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" // normalize-stderr-test "note: compiler flags.*\n\n" -> "" // normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" +// normalize-stderr-test "query stack during panic:\n" -> "" +// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> "" +// normalize-stderr-test "end of query stack\n" -> "" #[macro_use] extern crate test_macros; diff --git a/src/test/ui/proc-macro/load-panic-backtrace.stderr b/src/test/ui/proc-macro/load-panic-backtrace.stderr index 63378b5735a..f825047e331 100644 --- a/src/test/ui/proc-macro/load-panic-backtrace.stderr +++ b/src/test/ui/proc-macro/load-panic-backtrace.stderr @@ -1,6 +1,6 @@ at 'panic-derive', $DIR/auxiliary/test-macros.rs:43:5 error: proc-macro derive panicked - --> $DIR/load-panic-backtrace.rs:17:10 + --> $DIR/load-panic-backtrace.rs:20:10 | LL | #[derive(Panic)] | ^^^^^ From d60b7e29f7f80674984c8d2f3567b15253b14f2f Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Wed, 23 Sep 2020 19:08:21 +0330 Subject: [PATCH 05/20] fix show we're just showing... message instead of the end of query stack message when RUST_BACKTRACE=0 --- compiler/rustc_middle/src/ty/query/plumbing.rs | 6 +++++- src/test/ui/pattern/const-pat-ice.stderr | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/pattern/const-pat-ice.stderr diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 239d5bce607..d5fbcf6c9b1 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -170,7 +170,11 @@ impl<'tcx> TyCtxt<'tcx> { } }); - eprintln!("end of query stack"); + if num_frames != None { + eprintln!("we're just showing a limited slice of the query stack"); + } else { + eprintln!("end of query stack"); + } } } diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr new file mode 100644 index 00000000000..90497db519c --- /dev/null +++ b/src/test/ui/pattern/const-pat-ice.stderr @@ -0,0 +1,17 @@ +thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', compiler/rustc_mir_build/src/thir/pattern/_match.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + +error: internal compiler error: unexpected panic + +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 VERSION running on TARGET + +note: compiler flags: FLAGS + +query stack during panic: +#0 [check_match] match-checking `main` +#1 [analysis] running analysis passes on this crate +we're just showing a limited slice of the query stack From 6e7e4ac419554883c430be7f4b234b0b4d88648c Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Fri, 25 Sep 2020 19:55:32 +0330 Subject: [PATCH 06/20] fix clippy custom_ice_message test --- src/tools/clippy/tests/ui/custom_ice_message.stderr | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/clippy/tests/ui/custom_ice_message.stderr b/src/tools/clippy/tests/ui/custom_ice_message.stderr index a9a65a38c10..784ab9e5c70 100644 --- a/src/tools/clippy/tests/ui/custom_ice_message.stderr +++ b/src/tools/clippy/tests/ui/custom_ice_message.stderr @@ -9,3 +9,5 @@ note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy note: Clippy version: foo +query stack during panic: +we're just showing a limited slice of the query stack \ No newline at end of file From 15663a432d281749655916ac22eaca8248260551 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Mon, 28 Sep 2020 22:07:31 +0330 Subject: [PATCH 07/20] add new line --- src/tools/clippy/tests/ui/custom_ice_message.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/clippy/tests/ui/custom_ice_message.stderr b/src/tools/clippy/tests/ui/custom_ice_message.stderr index 784ab9e5c70..87cdb7a8b99 100644 --- a/src/tools/clippy/tests/ui/custom_ice_message.stderr +++ b/src/tools/clippy/tests/ui/custom_ice_message.stderr @@ -10,4 +10,4 @@ note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy note: Clippy version: foo query stack during panic: -we're just showing a limited slice of the query stack \ No newline at end of file +we're just showing a limited slice of the query stack From 2124e9b50e2ba208700f1ab928e0863e407eb158 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Tue, 29 Sep 2020 18:14:07 +0330 Subject: [PATCH 08/20] rebase with master --- compiler/rustc_driver/src/lib.rs | 4 +++- compiler/rustc_middle/src/ty/query/plumbing.rs | 8 ++++++++ src/tools/clippy/src/driver.rs | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 177256008f8..a2c244d6f17 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1214,7 +1214,9 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { // If backtraces are enabled, also print the query stack let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false); - TyCtxt::try_print_query_stack(&handler, Some(2), Some(backtrace)); + let num_frames = if backtrace { None } else { Some(2) }; + + TyCtxt::try_print_query_stack(&handler, num_frames); #[cfg(windows)] unsafe { diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index d5fbcf6c9b1..d64e32c4d36 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -124,11 +124,15 @@ impl<'tcx> TyCtxt<'tcx> { }) } +<<<<<<< HEAD pub fn try_print_query_stack( handler: &Handler, num_frames: Option, backtrace: Option, ) { +======= + pub fn try_print_query_stack(handler: &Handler, num_frames: Option) { +>>>>>>> 15827338aa231fd408561bf5db8d8eea85d1a51a eprintln!("query stack during panic:"); // Be careful reyling on global state here: this code is called from @@ -142,7 +146,11 @@ impl<'tcx> TyCtxt<'tcx> { let mut i = 0; while let Some(query) = current_query { +<<<<<<< HEAD if backtrace.unwrap() == false && i == num_frames.unwrap() { +======= + if num_frames == Some(i) { +>>>>>>> 15827338aa231fd408561bf5db8d8eea85d1a51a break; } let query_info = diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index 0b324775b0d..bf9110b4349 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -277,7 +277,9 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { // If backtraces are enabled, also print the query stack let backtrace = env::var_os("RUST_BACKTRACE").map_or(false, |x| &x != "0"); - TyCtxt::try_print_query_stack(&handler, Some(2), Some(backtrace)); + let num_frames = if backtrace { None } else { Some(2) }; + + TyCtxt::try_print_query_stack(&handler, num_frames); } fn toolchain_path(home: Option, toolchain: Option) -> Option { From 2b91b7fba99c47ffc214b2fd36b586b844a509bd Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 17:51:24 +0430 Subject: [PATCH 09/20] ICEs should print the top of the query stack --- compiler/rustc_middle/src/ty/query/plumbing.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index d64e32c4d36..451ed6506f4 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -124,15 +124,7 @@ impl<'tcx> TyCtxt<'tcx> { }) } -<<<<<<< HEAD - pub fn try_print_query_stack( - handler: &Handler, - num_frames: Option, - backtrace: Option, - ) { -======= pub fn try_print_query_stack(handler: &Handler, num_frames: Option) { ->>>>>>> 15827338aa231fd408561bf5db8d8eea85d1a51a eprintln!("query stack during panic:"); // Be careful reyling on global state here: this code is called from @@ -146,11 +138,7 @@ impl<'tcx> TyCtxt<'tcx> { let mut i = 0; while let Some(query) = current_query { -<<<<<<< HEAD - if backtrace.unwrap() == false && i == num_frames.unwrap() { -======= - if num_frames == Some(i) { ->>>>>>> 15827338aa231fd408561bf5db8d8eea85d1a51a + if Some(i) == num_frames { break; } let query_info = From 01f838a6269460ea97fdf305b1afb236f6528b74 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 18:37:58 +0430 Subject: [PATCH 10/20] run full query stack print just when RUST_BACKTRACE is set --- compiler/rustc_middle/src/ty/query/plumbing.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 451ed6506f4..61f8cd8caad 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -124,7 +124,11 @@ impl<'tcx> TyCtxt<'tcx> { }) } - pub fn try_print_query_stack(handler: &Handler, num_frames: Option) { + pub fn try_print_query_stack( + handler: &Handler, + num_frames: Option, + backtrace: Option, + ) { eprintln!("query stack during panic:"); // Be careful reyling on global state here: this code is called from From 2bfdd644dc65b7ef746b7128dbaef2333e5cec7f Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 19:54:04 +0430 Subject: [PATCH 11/20] change approach and run ui tests --- compiler/rustc_middle/src/ty/query/plumbing.rs | 6 +----- src/test/ui/proc-macro/invalid-punct-ident-1.stderr | 2 ++ src/test/ui/proc-macro/invalid-punct-ident-2.stderr | 2 ++ src/test/ui/proc-macro/invalid-punct-ident-3.stderr | 2 ++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 61f8cd8caad..451ed6506f4 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -124,11 +124,7 @@ impl<'tcx> TyCtxt<'tcx> { }) } - pub fn try_print_query_stack( - handler: &Handler, - num_frames: Option, - backtrace: Option, - ) { + pub fn try_print_query_stack(handler: &Handler, num_frames: Option) { eprintln!("query stack during panic:"); // Be careful reyling on global state here: this code is called from diff --git a/src/test/ui/proc-macro/invalid-punct-ident-1.stderr b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr index 5ef22709cb3..9948670b691 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-1.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr @@ -1,3 +1,5 @@ +query stack during panic: +end of query stack error: proc macro panicked --> $DIR/invalid-punct-ident-1.rs:19:1 | diff --git a/src/test/ui/proc-macro/invalid-punct-ident-2.stderr b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr index 4bd7a5351d3..55f7344e2e6 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-2.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr @@ -1,3 +1,5 @@ +query stack during panic: +end of query stack error: proc macro panicked --> $DIR/invalid-punct-ident-2.rs:19:1 | diff --git a/src/test/ui/proc-macro/invalid-punct-ident-3.stderr b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr index 072d13956ac..915720482de 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-3.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr @@ -1,3 +1,5 @@ +query stack during panic: +end of query stack error: proc macro panicked --> $DIR/invalid-punct-ident-3.rs:19:1 | From b6e9f08fbfce298082817bf7f2eaf00dd9097d14 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 21:29:57 +0430 Subject: [PATCH 12/20] show a message when we are showing limited slice of query stack --- compiler/rustc_middle/src/ty/query/plumbing.rs | 3 +++ src/test/ui/pattern/const-pat-ice.stderr | 1 + src/test/ui/proc-macro/invalid-punct-ident-1.stderr | 1 + src/test/ui/proc-macro/invalid-punct-ident-2.stderr | 1 + src/test/ui/proc-macro/invalid-punct-ident-3.stderr | 1 + 5 files changed, 7 insertions(+) diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 451ed6506f4..17eb8dbdca9 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -127,6 +127,9 @@ impl<'tcx> TyCtxt<'tcx> { pub fn try_print_query_stack(handler: &Handler, num_frames: Option) { eprintln!("query stack during panic:"); + if num_frames != None { + eprintln!("we're just showing a limited slice of the query stack"); + } // Be careful reyling on global state here: this code is called from // a panic hook, which means that the global `Handler` may be in a weird // state if it was responsible for triggering the panic. diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr index 90497db519c..436958d210a 100644 --- a/src/test/ui/pattern/const-pat-ice.stderr +++ b/src/test/ui/pattern/const-pat-ice.stderr @@ -12,6 +12,7 @@ note: rustc VERSION running on TARGET note: compiler flags: FLAGS query stack during panic: +we're just showing a limited slice of the query stack #0 [check_match] match-checking `main` #1 [analysis] running analysis passes on this crate we're just showing a limited slice of the query stack diff --git a/src/test/ui/proc-macro/invalid-punct-ident-1.stderr b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr index 9948670b691..edfb977f7ae 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-1.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr @@ -1,4 +1,5 @@ query stack during panic: +we're just showing a limited slice of the query stack end of query stack error: proc macro panicked --> $DIR/invalid-punct-ident-1.rs:19:1 diff --git a/src/test/ui/proc-macro/invalid-punct-ident-2.stderr b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr index 55f7344e2e6..ea17175253f 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-2.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr @@ -1,4 +1,5 @@ query stack during panic: +we're just showing a limited slice of the query stack end of query stack error: proc macro panicked --> $DIR/invalid-punct-ident-2.rs:19:1 diff --git a/src/test/ui/proc-macro/invalid-punct-ident-3.stderr b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr index 915720482de..d60afd12095 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-3.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr @@ -1,4 +1,5 @@ query stack during panic: +we're just showing a limited slice of the query stack end of query stack error: proc macro panicked --> $DIR/invalid-punct-ident-3.rs:19:1 From 3c56ba5a6d69d9376a4998dc559796b8b47ace0b Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 22:05:04 +0430 Subject: [PATCH 13/20] fix invalid-punct-ident-1 test --- src/test/ui/proc-macro/invalid-punct-ident-1.stderr | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/ui/proc-macro/invalid-punct-ident-1.stderr b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr index edfb977f7ae..5ef22709cb3 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-1.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr @@ -1,6 +1,3 @@ -query stack during panic: -we're just showing a limited slice of the query stack -end of query stack error: proc macro panicked --> $DIR/invalid-punct-ident-1.rs:19:1 | From d1e30592b330bda437cc8584d30f751dc97c08fc Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sun, 20 Sep 2020 17:07:55 +0430 Subject: [PATCH 14/20] add filter regexes to load-panic-backtraces test --- src/test/ui/proc-macro/invalid-punct-ident-2.stderr | 3 --- src/test/ui/proc-macro/invalid-punct-ident-3.stderr | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/test/ui/proc-macro/invalid-punct-ident-2.stderr b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr index ea17175253f..4bd7a5351d3 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-2.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr @@ -1,6 +1,3 @@ -query stack during panic: -we're just showing a limited slice of the query stack -end of query stack error: proc macro panicked --> $DIR/invalid-punct-ident-2.rs:19:1 | diff --git a/src/test/ui/proc-macro/invalid-punct-ident-3.stderr b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr index d60afd12095..072d13956ac 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-3.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr @@ -1,6 +1,3 @@ -query stack during panic: -we're just showing a limited slice of the query stack -end of query stack error: proc macro panicked --> $DIR/invalid-punct-ident-3.rs:19:1 | From 6c0f06a107992eefa93a57f6f29f2a008e5051a1 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Wed, 23 Sep 2020 19:08:21 +0330 Subject: [PATCH 15/20] fix show we're just showing... message instead of the end of query stack message when RUST_BACKTRACE=0 --- compiler/rustc_middle/src/ty/query/plumbing.rs | 3 --- src/test/ui/pattern/const-pat-ice.stderr | 1 - 2 files changed, 4 deletions(-) diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 17eb8dbdca9..451ed6506f4 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -127,9 +127,6 @@ impl<'tcx> TyCtxt<'tcx> { pub fn try_print_query_stack(handler: &Handler, num_frames: Option) { eprintln!("query stack during panic:"); - if num_frames != None { - eprintln!("we're just showing a limited slice of the query stack"); - } // Be careful reyling on global state here: this code is called from // a panic hook, which means that the global `Handler` may be in a weird // state if it was responsible for triggering the panic. diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr index 436958d210a..90497db519c 100644 --- a/src/test/ui/pattern/const-pat-ice.stderr +++ b/src/test/ui/pattern/const-pat-ice.stderr @@ -12,7 +12,6 @@ note: rustc VERSION running on TARGET note: compiler flags: FLAGS query stack during panic: -we're just showing a limited slice of the query stack #0 [check_match] match-checking `main` #1 [analysis] running analysis passes on this crate we're just showing a limited slice of the query stack From c61d95b2cd62020e916d316014dd95b5601cd71d Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Tue, 29 Sep 2020 21:17:44 +0330 Subject: [PATCH 16/20] remove new line --- src/test/ui/pattern/const-pat-ice.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr index 90497db519c..5116531d9cf 100644 --- a/src/test/ui/pattern/const-pat-ice.stderr +++ b/src/test/ui/pattern/const-pat-ice.stderr @@ -14,4 +14,4 @@ note: compiler flags: FLAGS query stack during panic: #0 [check_match] match-checking `main` #1 [analysis] running analysis passes on this crate -we're just showing a limited slice of the query stack +we're just showing a limited slice of the query stack \ No newline at end of file From 998186eb156345767007cca323e2f756ba1abfff Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 3 Oct 2020 17:04:27 +0330 Subject: [PATCH 17/20] revert deleted new line --- src/test/ui/pattern/const-pat-ice.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr index 5116531d9cf..90497db519c 100644 --- a/src/test/ui/pattern/const-pat-ice.stderr +++ b/src/test/ui/pattern/const-pat-ice.stderr @@ -14,4 +14,4 @@ note: compiler flags: FLAGS query stack during panic: #0 [check_match] match-checking `main` #1 [analysis] running analysis passes on this crate -we're just showing a limited slice of the query stack \ No newline at end of file +we're just showing a limited slice of the query stack From 42ebae3175a542c07b75c174bdddb22c6b18b10d Mon Sep 17 00:00:00 2001 From: hosseind88 Date: Tue, 6 Oct 2020 22:15:31 +0330 Subject: [PATCH 18/20] delete const-pat-ice test stderr --- src/test/ui/pattern/const-pat-ice.stderr | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 src/test/ui/pattern/const-pat-ice.stderr diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr deleted file mode 100644 index 90497db519c..00000000000 --- a/src/test/ui/pattern/const-pat-ice.stderr +++ /dev/null @@ -1,17 +0,0 @@ -thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', compiler/rustc_mir_build/src/thir/pattern/_match.rs:LL:CC -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace - -error: internal compiler error: unexpected panic - -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 VERSION running on TARGET - -note: compiler flags: FLAGS - -query stack during panic: -#0 [check_match] match-checking `main` -#1 [analysis] running analysis passes on this crate -we're just showing a limited slice of the query stack From 73d8f0045fff127c3bdbf907da7a8c3e07b7145a Mon Sep 17 00:00:00 2001 From: hosseind88 Date: Thu, 8 Oct 2020 21:07:12 +0330 Subject: [PATCH 19/20] change condition for end of query stack message --- compiler/rustc_middle/src/ty/query/plumbing.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 451ed6506f4..27bf22dac75 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -130,12 +130,12 @@ impl<'tcx> TyCtxt<'tcx> { // Be careful reyling on global state here: this code is called from // a panic hook, which means that the global `Handler` may be in a weird // state if it was responsible for triggering the panic. + let mut i = 0; ty::tls::with_context_opt(|icx| { if let Some(icx) = icx { let query_map = icx.tcx.queries.try_collect_active_jobs(); let mut current_query = icx.query; - let mut i = 0; while let Some(query) = current_query { if Some(i) == num_frames { @@ -166,10 +166,10 @@ impl<'tcx> TyCtxt<'tcx> { } }); - if num_frames != None { - eprintln!("we're just showing a limited slice of the query stack"); - } else { + if num_frames == None || num_frames >= Some(i) { eprintln!("end of query stack"); + } else { + eprintln!("we're just showing a limited slice of the query stack"); } } } From 46cc889abf6564408ffa1d9e896a3fc22a859d10 Mon Sep 17 00:00:00 2001 From: hosseind88 Date: Wed, 14 Oct 2020 18:19:26 +0330 Subject: [PATCH 20/20] fix stderr file of clippy/custom_ice_message test --- src/tools/clippy/tests/ui/custom_ice_message.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/clippy/tests/ui/custom_ice_message.stderr b/src/tools/clippy/tests/ui/custom_ice_message.stderr index 87cdb7a8b99..a1b8e2ee162 100644 --- a/src/tools/clippy/tests/ui/custom_ice_message.stderr +++ b/src/tools/clippy/tests/ui/custom_ice_message.stderr @@ -10,4 +10,4 @@ note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy note: Clippy version: foo query stack during panic: -we're just showing a limited slice of the query stack +end of query stack