leak_check: remove unused codepath

This commit is contained in:
lcnr 2023-05-23 16:32:59 +02:00
parent 578bcbc2b4
commit 200ed9f8cd
6 changed files with 9 additions and 42 deletions

View File

@ -824,7 +824,7 @@ fn coerce_from_safe_fn<F, G>(
// want the coerced type to be the actual supertype of these two, // want the coerced type to be the actual supertype of these two,
// but for now, we want to just error to ensure we don't lock // but for now, we want to just error to ensure we don't lock
// ourselves into a specific behavior with NLL. // ourselves into a specific behavior with NLL.
self.leak_check(false, snapshot)?; self.leak_check(snapshot)?;
result result
}) })

View File

@ -108,11 +108,7 @@ pub fn instantiate_binder_with_placeholders<T>(&self, binder: ty::Binder<'tcx, T
/// See [RegionConstraintCollector::leak_check][1]. /// See [RegionConstraintCollector::leak_check][1].
/// ///
/// [1]: crate::infer::region_constraints::RegionConstraintCollector::leak_check /// [1]: crate::infer::region_constraints::RegionConstraintCollector::leak_check
pub fn leak_check( pub fn leak_check(&self, snapshot: &CombinedSnapshot<'tcx>) -> RelateResult<'tcx, ()> {
&self,
overly_polymorphic: bool,
snapshot: &CombinedSnapshot<'tcx>,
) -> RelateResult<'tcx, ()> {
// If the user gave `-Zno-leak-check`, or we have been // If the user gave `-Zno-leak-check`, or we have been
// configured to skip the leak check, then skip the leak check // configured to skip the leak check, then skip the leak check
// completely. The leak check is deprecated. Any legitimate // completely. The leak check is deprecated. Any legitimate
@ -125,7 +121,6 @@ pub fn leak_check(
self.inner.borrow_mut().unwrap_region_constraints().leak_check( self.inner.borrow_mut().unwrap_region_constraints().leak_check(
self.tcx, self.tcx,
overly_polymorphic,
self.universe(), self.universe(),
snapshot, snapshot,
) )

View File

@ -65,13 +65,12 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
pub fn leak_check( pub fn leak_check(
&mut self, &mut self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
overly_polymorphic: bool,
max_universe: ty::UniverseIndex, max_universe: ty::UniverseIndex,
snapshot: &CombinedSnapshot<'tcx>, snapshot: &CombinedSnapshot<'tcx>,
) -> RelateResult<'tcx, ()> { ) -> RelateResult<'tcx, ()> {
debug!( debug!(
"leak_check(max_universe={:?}, snapshot.universe={:?}, overly_polymorphic={:?})", "leak_check(max_universe={:?}, snapshot.universe={:?})",
max_universe, snapshot.universe, overly_polymorphic max_universe, snapshot.universe
); );
assert!(UndoLogs::<super::UndoLog<'_>>::in_snapshot(&self.undo_log)); assert!(UndoLogs::<super::UndoLog<'_>>::in_snapshot(&self.undo_log));
@ -84,14 +83,8 @@ pub fn leak_check(
let mini_graph = let mini_graph =
&MiniGraph::new(tcx, self.undo_log.region_constraints(), &self.storage.data.verifys); &MiniGraph::new(tcx, self.undo_log.region_constraints(), &self.storage.data.verifys);
let mut leak_check = LeakCheck::new( let mut leak_check =
tcx, LeakCheck::new(tcx, universe_at_start_of_snapshot, max_universe, mini_graph, self);
universe_at_start_of_snapshot,
max_universe,
overly_polymorphic,
mini_graph,
self,
);
leak_check.assign_placeholder_values()?; leak_check.assign_placeholder_values()?;
leak_check.propagate_scc_value()?; leak_check.propagate_scc_value()?;
Ok(()) Ok(())
@ -101,8 +94,6 @@ pub fn leak_check(
struct LeakCheck<'me, 'tcx> { struct LeakCheck<'me, 'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
universe_at_start_of_snapshot: ty::UniverseIndex, universe_at_start_of_snapshot: ty::UniverseIndex,
/// Only used when reporting region errors.
overly_polymorphic: bool,
mini_graph: &'me MiniGraph<'tcx>, mini_graph: &'me MiniGraph<'tcx>,
rcc: &'me RegionConstraintCollector<'me, 'tcx>, rcc: &'me RegionConstraintCollector<'me, 'tcx>,
@ -132,7 +123,6 @@ fn new(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
universe_at_start_of_snapshot: ty::UniverseIndex, universe_at_start_of_snapshot: ty::UniverseIndex,
max_universe: ty::UniverseIndex, max_universe: ty::UniverseIndex,
overly_polymorphic: bool,
mini_graph: &'me MiniGraph<'tcx>, mini_graph: &'me MiniGraph<'tcx>,
rcc: &'me RegionConstraintCollector<'me, 'tcx>, rcc: &'me RegionConstraintCollector<'me, 'tcx>,
) -> Self { ) -> Self {
@ -140,7 +130,6 @@ fn new(
Self { Self {
tcx, tcx,
universe_at_start_of_snapshot, universe_at_start_of_snapshot,
overly_polymorphic,
mini_graph, mini_graph,
rcc, rcc,
scc_placeholders: IndexVec::from_elem_n(None, mini_graph.sccs.num_sccs()), scc_placeholders: IndexVec::from_elem_n(None, mini_graph.sccs.num_sccs()),
@ -289,11 +278,7 @@ fn error(
other_region: ty::Region<'tcx>, other_region: ty::Region<'tcx>,
) -> TypeError<'tcx> { ) -> TypeError<'tcx> {
debug!("error: placeholder={:?}, other_region={:?}", placeholder, other_region); debug!("error: placeholder={:?}, other_region={:?}", placeholder, other_region);
if self.overly_polymorphic { TypeError::RegionsInsufficientlyPolymorphic(placeholder.bound.kind, other_region)
TypeError::RegionsOverlyPolymorphic(placeholder.bound.kind, other_region)
} else {
TypeError::RegionsInsufficientlyPolymorphic(placeholder.bound.kind, other_region)
}
} }
} }

View File

@ -45,7 +45,6 @@ pub enum TypeError<'tcx> {
RegionsDoesNotOutlive(Region<'tcx>, Region<'tcx>), RegionsDoesNotOutlive(Region<'tcx>, Region<'tcx>),
RegionsInsufficientlyPolymorphic(BoundRegionKind, Region<'tcx>), RegionsInsufficientlyPolymorphic(BoundRegionKind, Region<'tcx>),
RegionsOverlyPolymorphic(BoundRegionKind, Region<'tcx>),
RegionsPlaceholderMismatch, RegionsPlaceholderMismatch,
Sorts(ExpectedFound<Ty<'tcx>>), Sorts(ExpectedFound<Ty<'tcx>>),
@ -74,7 +73,6 @@ pub fn involves_regions(self) -> bool {
match self { match self {
TypeError::RegionsDoesNotOutlive(_, _) TypeError::RegionsDoesNotOutlive(_, _)
| TypeError::RegionsInsufficientlyPolymorphic(_, _) | TypeError::RegionsInsufficientlyPolymorphic(_, _)
| TypeError::RegionsOverlyPolymorphic(_, _)
| TypeError::RegionsPlaceholderMismatch => true, | TypeError::RegionsPlaceholderMismatch => true,
_ => false, _ => false,
} }
@ -98,11 +96,6 @@ fn report_maybe_different(expected: &str, found: &str) -> String {
} }
} }
let br_string = |br: ty::BoundRegionKind| match br {
ty::BrNamed(_, name) => format!(" {}", name),
_ => String::new(),
};
match self { match self {
CyclicTy(_) => "cyclic type of infinite size".into(), CyclicTy(_) => "cyclic type of infinite size".into(),
CyclicConst(_) => "encountered a self-referencing constant".into(), CyclicConst(_) => "encountered a self-referencing constant".into(),
@ -144,11 +137,6 @@ fn report_maybe_different(expected: &str, found: &str) -> String {
RegionsInsufficientlyPolymorphic(..) => { RegionsInsufficientlyPolymorphic(..) => {
"one type is more general than the other".into() "one type is more general than the other".into()
} }
RegionsOverlyPolymorphic(br, _) => format!(
"expected concrete lifetime, found bound lifetime parameter{}",
br_string(br)
)
.into(),
RegionsPlaceholderMismatch => "one type is more general than the other".into(), RegionsPlaceholderMismatch => "one type is more general than the other".into(),
ArgumentSorts(values, _) | Sorts(values) => { ArgumentSorts(values, _) | Sorts(values) => {
let expected = values.expected.sort_string(tcx); let expected = values.expected.sort_string(tcx);
@ -228,7 +216,6 @@ pub fn must_include_note(self) -> bool {
| FieldMisMatch(..) | FieldMisMatch(..)
| RegionsDoesNotOutlive(..) | RegionsDoesNotOutlive(..)
| RegionsInsufficientlyPolymorphic(..) | RegionsInsufficientlyPolymorphic(..)
| RegionsOverlyPolymorphic(..)
| RegionsPlaceholderMismatch | RegionsPlaceholderMismatch
| Traits(_) | Traits(_)
| ProjectionMismatched(_) | ProjectionMismatched(_)

View File

@ -200,7 +200,7 @@ fn overlap_within_probe<'cx, 'tcx>(
// We disable the leak when creating the `snapshot` by using // We disable the leak when creating the `snapshot` by using
// `infcx.probe_maybe_disable_leak_check`. // `infcx.probe_maybe_disable_leak_check`.
if infcx.leak_check(true, snapshot).is_err() { if infcx.leak_check(snapshot).is_err() {
debug!("overlap: leak check failed"); debug!("overlap: leak check failed");
return None; return None;
} }

View File

@ -563,7 +563,7 @@ fn evaluation_probe(
self.infcx.probe(|snapshot| -> Result<EvaluationResult, OverflowError> { self.infcx.probe(|snapshot| -> Result<EvaluationResult, OverflowError> {
let result = op(self)?; let result = op(self)?;
match self.infcx.leak_check(true, snapshot) { match self.infcx.leak_check(snapshot) {
Ok(()) => {} Ok(()) => {}
Err(_) => return Ok(EvaluatedToErr), Err(_) => return Ok(EvaluatedToErr),
} }