From 5fd6301bcd2d7a9260a5d5ca3f5abcc05830761b Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 17:51:24 +0430 Subject: [PATCH 01/19] 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 972e04fd101f0..b272920d5fcba 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1202,12 +1202,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 f3fa3634026fd..6debd0cc7f3b8 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 47315fa64cd80..24da90ea0b538 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 132c9efbcbe6b63e36fb53fc95beaed6627ecc2d Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 18:37:58 +0430 Subject: [PATCH 02/19] 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 b272920d5fcba..14659a331228f 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1202,7 +1202,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 6debd0cc7f3b8..239d5bce607c4 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 24da90ea0b538..375e2f4b59fa3 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 767e84a834d21eb8acc063f5f89753f4d467f589 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 19:54:04 +0430 Subject: [PATCH 03/19] change approach and run ui tests --- compiler/rustc_driver/src/lib.rs | 4 +++- compiler/rustc_middle/src/ty/query/plumbing.rs | 8 ++------ .../ui/consts/const-eval/const-eval-query-stack.stderr | 4 ---- src/test/ui/pattern/const-pat-ice.stderr | 4 ++++ 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 ++ src/tools/clippy/src/driver.rs | 8 +++++++- 8 files changed, 22 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 14659a331228f..30f78b982c9c4 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1205,7 +1205,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 { Some(2) } else { None }; + + 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 239d5bce607c4..d457a5e8c73e6 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 @@ -142,7 +138,7 @@ impl<'tcx> TyCtxt<'tcx> { let mut i = 0; while let Some(query) = current_query { - if backtrace.unwrap() == false && i == num_frames.unwrap() { + if num_frames == Some(i) { break; } let query_info = diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr index dc2661ee79685..d6565b59d1de1 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr @@ -11,8 +11,4 @@ LL | let x: &'static i32 = &(1 / 0); query stack during panic: #0 [const_eval_raw] const-evaluating `main::promoted[1]` #1 [const_eval_validated] const-evaluating + checking `main::promoted[1]` -#2 [const_eval_validated] const-evaluating + checking `main::promoted[1]` -#3 [normalize_generic_arg_after_erasing_regions] normalizing `main::promoted[1]` -#4 [optimized_mir] optimizing MIR for `main` -#5 [collect_and_partition_mono_items] collect_and_partition_mono_items end of query stack diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr index 6b42c0e0848e9..0ed8074b077d4 100644 --- a/src/test/ui/pattern/const-pat-ice.stderr +++ b/src/test/ui/pattern/const-pat-ice.stderr @@ -11,3 +11,7 @@ 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 +end of 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 fc821d29d5a0c..f9ffd2c0a83e8 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:16: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 8b30edaf85c09..18f0c2b513eb5 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:16: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 d46fab08e14f0..2dd8bb0b36983 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:16:1 | diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index 375e2f4b59fa3..17fbe2cc84f78 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -277,7 +277,13 @@ 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 { + Some(2) + } else { + None + }; + + TyCtxt::try_print_query_stack(&handler, num_frames); } fn toolchain_path(home: Option, toolchain: Option) -> Option { From 339181a5d94384d57e5681fbcffe9492264b5025 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 21:29:57 +0430 Subject: [PATCH 04/19] show a message when we are showing limited slice of query stack --- compiler/rustc_driver/src/lib.rs | 2 +- compiler/rustc_middle/src/ty/query/plumbing.rs | 3 +++ src/test/ui/consts/const-eval/const-eval-query-stack.stderr | 4 ++++ 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 + src/tools/clippy/src/driver.rs | 6 +----- 8 files changed, 13 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 30f78b982c9c4..6ee104b17ec83 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1205,7 +1205,7 @@ 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); - let num_frames = if backtrace { Some(2) } else { None }; + let num_frames = if backtrace { None } else { Some(2) }; TyCtxt::try_print_query_stack(&handler, num_frames); diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index d457a5e8c73e6..0e49bdb8fca21 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/consts/const-eval/const-eval-query-stack.stderr b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr index d6565b59d1de1..dc2661ee79685 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr @@ -11,4 +11,8 @@ LL | let x: &'static i32 = &(1 / 0); query stack during panic: #0 [const_eval_raw] const-evaluating `main::promoted[1]` #1 [const_eval_validated] const-evaluating + checking `main::promoted[1]` +#2 [const_eval_validated] const-evaluating + checking `main::promoted[1]` +#3 [normalize_generic_arg_after_erasing_regions] normalizing `main::promoted[1]` +#4 [optimized_mir] optimizing MIR for `main` +#5 [collect_and_partition_mono_items] collect_and_partition_mono_items end of query stack diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr index 0ed8074b077d4..7c3ba2d8a3d20 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 end of 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 f9ffd2c0a83e8..60661a2cb24f8 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:16: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 18f0c2b513eb5..fc2eacc997237 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:16: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 2dd8bb0b36983..091b3da8fd344 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:16:1 diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index 17fbe2cc84f78..09936c77b0a13 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -277,11 +277,7 @@ 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"); - let num_frames = if backtrace { - Some(2) - } else { - None - }; + let num_frames = if backtrace { None } else { Some(2) }; TyCtxt::try_print_query_stack(&handler, num_frames); } From 51c32f443ded5b264feb7e6d2bf9efc0b04e180a Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 22:05:04 +0430 Subject: [PATCH 05/19] 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 | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) 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 3f78dea917b19..a3133a1a79070 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 60661a2cb24f8..5ef22709cb371 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-1.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr @@ -1,8 +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:16:1 + --> $DIR/invalid-punct-ident-1.rs:19:1 | LL | invalid_punct!(); | ^^^^^^^^^^^^^^^^^ From d8af4b38489ce4ba3fef615da2fbc5dd6bac2d28 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sun, 20 Sep 2020 17:07:55 +0430 Subject: [PATCH 06/19] 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 | 5 +---- src/test/ui/proc-macro/invalid-punct-ident-3.rs | 3 +++ src/test/ui/proc-macro/invalid-punct-ident-3.stderr | 5 +---- 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(+), 9 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 4e89e80ae7c41..04a0a8733115a 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 fc2eacc997237..4bd7a5351d3a0 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-2.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr @@ -1,8 +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: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 8d8ce8f932e71..aebba341625ae 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 091b3da8fd344..072d13956ac6c 100644 --- a/src/test/ui/proc-macro/invalid-punct-ident-3.stderr +++ b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr @@ -1,8 +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: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 90fe109abb8f0..4a3ba9aee7453 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 63378b5735a3c..f825047e33168 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 cdd3126666d827a11735a4ab31da74b1de160fbf Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Wed, 23 Sep 2020 19:08:21 +0330 Subject: [PATCH 07/19] 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 | 9 +++++---- src/test/ui/pattern/const-pat-ice.stderr | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 0e49bdb8fca21..b8389cccad3e5 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. @@ -169,7 +166,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 index 7c3ba2d8a3d20..90497db519c34 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 -end of query stack +we're just showing a limited slice of the query stack From e29e1500ad4018fdaa61c7a1078cba4da2ab4539 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Fri, 25 Sep 2020 19:55:32 +0330 Subject: [PATCH 08/19] 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 a9a65a38c109d..784ab9e5c7078 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 3621afebca71cdc95b1d9ac184e2446c1cf8c097 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Mon, 28 Sep 2020 22:07:31 +0330 Subject: [PATCH 09/19] 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 784ab9e5c7078..87cdb7a8b99dd 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 8983d5bfcafe87ea04ab9874230af178b190212d Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 17:51:24 +0430 Subject: [PATCH 10/19] 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 544efc124e117..66eae5643bb5f 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1212,12 +1212,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 f3fa3634026fd..6debd0cc7f3b8 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 f4f2259cefd51..c88dffc88f422 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 a1ef12ba84b24330bdce404315543be20a8dd597 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 18:37:58 +0430 Subject: [PATCH 11/19] 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 66eae5643bb5f..b67782ae73ce7 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1212,7 +1212,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 6debd0cc7f3b8..239d5bce607c4 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 c88dffc88f422..0b324775b0d1a 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 3be44f97a5b9bf3fb786cac7728518602bad4f59 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sat, 19 Sep 2020 22:05:04 +0430 Subject: [PATCH 12/19] 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 3f78dea917b19..a3133a1a79070 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 fc821d29d5a0c..5ef22709cb371 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 56d6be3a62b0addf7f6ba0abe1122717e16b1e6e Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Sun, 20 Sep 2020 17:07:55 +0430 Subject: [PATCH 13/19] 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 4e89e80ae7c41..04a0a8733115a 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 8b30edaf85c09..4bd7a5351d3a0 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 8d8ce8f932e71..aebba341625ae 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 d46fab08e14f0..072d13956ac6c 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 90fe109abb8f0..4a3ba9aee7453 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 63378b5735a3c..f825047e33168 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 e837539ecbdffd4c8b57fad8fc159c37d3a4bfe1 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Wed, 23 Sep 2020 19:08:21 +0330 Subject: [PATCH 14/19] 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 239d5bce607c4..d5fbcf6c9b14b 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 0000000000000..90497db519c34 --- /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 51d2e7eda9add1a043feefb145fb07d0b06e88c1 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Fri, 25 Sep 2020 19:55:32 +0330 Subject: [PATCH 15/19] 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 a9a65a38c109d..784ab9e5c7078 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 8bfeaef61ced4c43f8105f0ceeb9cb75e92071e6 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Mon, 28 Sep 2020 22:07:31 +0330 Subject: [PATCH 16/19] 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 784ab9e5c7078..87cdb7a8b99dd 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 d61d859e69108eaeae308c95fa61751658f51290 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Tue, 29 Sep 2020 18:14:07 +0330 Subject: [PATCH 17/19] 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 b67782ae73ce7..092fc9d409c94 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -1215,7 +1215,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 d5fbcf6c9b14b..d64e32c4d36b7 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 0b324775b0d1a..bf9110b43492f 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 bf73a64bf70bfc7d4b90c956029db901fe3cc8b2 Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Tue, 29 Sep 2020 18:56:42 +0330 Subject: [PATCH 18/19] fix rebase messed up files --- Cargo.lock | 29 ++++++++++++------- .../rustc_middle/src/ty/query/plumbing.rs | 20 ------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c0d15c373197b..d23b29d39bf86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -343,7 +343,6 @@ dependencies = [ name = "cargo-miri" version = "0.1.0" dependencies = [ - "cargo_metadata 0.11.1", "directories", "rustc-workspace-hack", "rustc_version", @@ -577,9 +576,9 @@ dependencies = [ [[package]] name = "colored" -version = "1.9.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" +checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" dependencies = [ "atty", "lazy_static", @@ -887,11 +886,10 @@ dependencies = [ [[package]] name = "directories" -version = "2.0.2" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "551a778172a450d7fc12e629ca3b0428d00f6afa9a43da1b630d54604e97371c" +checksum = "f8fed639d60b58d0f53498ab13d26f621fd77569cc6edb031f4cc36a2ad9da0f" dependencies = [ - "cfg-if", "dirs-sys", ] @@ -1187,6 +1185,17 @@ dependencies = [ "wasi", ] +[[package]] +name = "getrandom" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "gimli" version = "0.22.0" @@ -2015,7 +2024,7 @@ dependencies = [ "colored", "compiletest_rs", "env_logger 0.7.1", - "getrandom", + "getrandom 0.2.0", "hex 0.4.2", "libc", "log", @@ -2607,7 +2616,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.14", "libc", "rand_chacha", "rand_core", @@ -2631,7 +2640,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.14", ] [[package]] @@ -2707,7 +2716,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" dependencies = [ - "getrandom", + "getrandom 0.1.14", "redox_syscall", "rust-argon2", ] diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 7f06a60591785..b8389cccad3e5 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -124,19 +124,7 @@ impl<'tcx> TyCtxt<'tcx> { }) } -<<<<<<< HEAD -<<<<<<< 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 -======= - 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 @@ -150,15 +138,7 @@ impl<'tcx> TyCtxt<'tcx> { let mut i = 0; while let Some(query) = current_query { -<<<<<<< HEAD -<<<<<<< HEAD - if backtrace.unwrap() == false && i == num_frames.unwrap() { -======= - if num_frames == Some(i) { ->>>>>>> 15827338aa231fd408561bf5db8d8eea85d1a51a -======= if num_frames == Some(i) { ->>>>>>> 15827338aa231fd408561bf5db8d8eea85d1a51a break; } let query_info = From 665bd46f29fd8433d42918b6f626ef23f13b86fc Mon Sep 17 00:00:00 2001 From: hosseind75 Date: Tue, 29 Sep 2020 21:17:44 +0330 Subject: [PATCH 19/19] 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 90497db519c34..5116531d9cfca 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