Skip to content

Commit

Permalink
change approach and run ui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hosseind75 committed Sep 19, 2020
1 parent 132c9ef commit 767e84a
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 12 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_middle/src/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ impl<'tcx> TyCtxt<'tcx> {
})
}

pub fn try_print_query_stack(
handler: &Handler,
num_frames: Option<usize>,
backtrace: Option<bool>,
) {
pub fn try_print_query_stack(handler: &Handler, num_frames: Option<usize>) {
eprintln!("query stack during panic:");

// Be careful reyling on global state here: this code is called from
Expand All @@ -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 =
Expand Down
4 changes: 0 additions & 4 deletions src/test/ui/consts/const-eval/const-eval-query-stack.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/test/ui/pattern/const-pat-ice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/test/ui/proc-macro/invalid-punct-ident-1.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
query stack during panic:
end of query stack
error: proc macro panicked
--> $DIR/invalid-punct-ident-1.rs:16:1
|
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/proc-macro/invalid-punct-ident-2.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
query stack during panic:
end of query stack
error: proc macro panicked
--> $DIR/invalid-punct-ident-2.rs:16:1
|
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/proc-macro/invalid-punct-ident-3.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
query stack during panic:
end of query stack
error: proc macro panicked
--> $DIR/invalid-punct-ident-3.rs:16:1
|
Expand Down
8 changes: 7 additions & 1 deletion src/tools/clippy/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>, toolchain: Option<String>) -> Option<PathBuf> {
Expand Down

0 comments on commit 767e84a

Please sign in to comment.