diff --git a/src/librustc_mir/borrow_check/nll/facts.rs b/src/librustc_mir/borrow_check/nll/facts.rs index 6cb8e64b9f5b..fe2fc7e37b76 100644 --- a/src/librustc_mir/borrow_check/nll/facts.rs +++ b/src/librustc_mir/borrow_check/nll/facts.rs @@ -23,6 +23,10 @@ use std::path::Path; crate type AllFacts = PoloniusAllFacts; crate trait AllFactsExt { + /// Returns true if there is a need to gather `AllFacts` given the + /// current `-Z` flags. + fn enabled(tcx: TyCtxt<'_, '_, '_>) -> bool; + fn write_to_dir( &self, dir: impl AsRef, @@ -31,6 +35,12 @@ crate trait AllFactsExt { } impl AllFactsExt for AllFacts { + /// Return + fn enabled(tcx: TyCtxt<'_, '_, '_>) -> bool { + tcx.sess.opts.debugging_opts.nll_facts + || tcx.sess.opts.debugging_opts.polonius + } + fn write_to_dir( &self, dir: impl AsRef, diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index dcb52a3b18a7..e26665e8291b 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -91,9 +91,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( Option>>, Option>, ) { - let mut all_facts = if infcx.tcx.sess.opts.debugging_opts.nll_facts - || infcx.tcx.sess.opts.debugging_opts.polonius - { + let mut all_facts = if AllFacts::enabled(infcx.tcx) { Some(AllFacts::default()) } else { None