From c6d69e852edfd2e25d96e8e3f453e2fe9a8896d4 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Fri, 22 Oct 2021 15:47:36 -0700 Subject: [PATCH] Ignore errors re: unreachable blocks in dataflow cursor unit tests --- compiler/rustc_mir_dataflow/src/framework/cursor.rs | 7 +++++++ compiler/rustc_mir_dataflow/src/framework/tests.rs | 2 ++ 2 files changed, 9 insertions(+) diff --git a/compiler/rustc_mir_dataflow/src/framework/cursor.rs b/compiler/rustc_mir_dataflow/src/framework/cursor.rs index c000e49c14bc1..ba6b566a304a5 100644 --- a/compiler/rustc_mir_dataflow/src/framework/cursor.rs +++ b/compiler/rustc_mir_dataflow/src/framework/cursor.rs @@ -64,6 +64,13 @@ where } } + /// Allows inspection of unreachable basic blocks even with `debug_assertions` enabled. + #[cfg(test)] + pub(crate) fn allow_unreachable(&mut self) { + #[cfg(debug_assertions)] + self.reachable_blocks.insert_all() + } + /// Returns the underlying `Results`. pub fn results(&self) -> &Results<'tcx, A> { &self.results.borrow() diff --git a/compiler/rustc_mir_dataflow/src/framework/tests.rs b/compiler/rustc_mir_dataflow/src/framework/tests.rs index a5989121679c4..6efa8daec489a 100644 --- a/compiler/rustc_mir_dataflow/src/framework/tests.rs +++ b/compiler/rustc_mir_dataflow/src/framework/tests.rs @@ -268,6 +268,8 @@ fn test_cursor(analysis: MockAnalysis<'tcx, D>) { let mut cursor = Results { entry_sets: analysis.mock_entry_sets(), analysis }.into_results_cursor(body); + cursor.allow_unreachable(); + let every_target = || { body.basic_blocks() .iter_enumerated()