extract a enabled
helper to remove some ad-hoc conditionals
This commit is contained in:
parent
65ceec71ec
commit
e7a9e7aef2
@ -23,6 +23,10 @@ use std::path::Path;
|
||||
crate type AllFacts = PoloniusAllFacts<RegionVid, BorrowIndex, LocationIndex>;
|
||||
|
||||
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<Path>,
|
||||
@ -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<Path>,
|
||||
|
@ -91,9 +91,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
|
||||
Option<Rc<Output<RegionVid, BorrowIndex, LocationIndex>>>,
|
||||
Option<ClosureRegionRequirements<'gcx>>,
|
||||
) {
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user