Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 200ed9f

Browse files
committed
leak_check: remove unused codepath
1 parent 578bcbc commit 200ed9f

File tree

6 files changed

+9
-42
lines changed

6 files changed

+9
-42
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
824824
// want the coerced type to be the actual supertype of these two,
825825
// but for now, we want to just error to ensure we don't lock
826826
// ourselves into a specific behavior with NLL.
827-
self.leak_check(false, snapshot)?;
827+
self.leak_check(snapshot)?;
828828

829829
result
830830
})

compiler/rustc_infer/src/infer/higher_ranked/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ impl<'tcx> InferCtxt<'tcx> {
108108
/// See [RegionConstraintCollector::leak_check][1].
109109
///
110110
/// [1]: crate::infer::region_constraints::RegionConstraintCollector::leak_check
111-
pub fn leak_check(
112-
&self,
113-
overly_polymorphic: bool,
114-
snapshot: &CombinedSnapshot<'tcx>,
115-
) -> RelateResult<'tcx, ()> {
111+
pub fn leak_check(&self, snapshot: &CombinedSnapshot<'tcx>) -> RelateResult<'tcx, ()> {
116112
// If the user gave `-Zno-leak-check`, or we have been
117113
// configured to skip the leak check, then skip the leak check
118114
// completely. The leak check is deprecated. Any legitimate
@@ -125,7 +121,6 @@ impl<'tcx> InferCtxt<'tcx> {
125121

126122
self.inner.borrow_mut().unwrap_region_constraints().leak_check(
127123
self.tcx,
128-
overly_polymorphic,
129124
self.universe(),
130125
snapshot,
131126
)

compiler/rustc_infer/src/infer/region_constraints/leak_check.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,12 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
6565
pub fn leak_check(
6666
&mut self,
6767
tcx: TyCtxt<'tcx>,
68-
overly_polymorphic: bool,
6968
max_universe: ty::UniverseIndex,
7069
snapshot: &CombinedSnapshot<'tcx>,
7170
) -> RelateResult<'tcx, ()> {
7271
debug!(
73-
"leak_check(max_universe={:?}, snapshot.universe={:?}, overly_polymorphic={:?})",
74-
max_universe, snapshot.universe, overly_polymorphic
72+
"leak_check(max_universe={:?}, snapshot.universe={:?})",
73+
max_universe, snapshot.universe
7574
);
7675

7776
assert!(UndoLogs::<super::UndoLog<'_>>::in_snapshot(&self.undo_log));
@@ -84,14 +83,8 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
8483
let mini_graph =
8584
&MiniGraph::new(tcx, self.undo_log.region_constraints(), &self.storage.data.verifys);
8685

87-
let mut leak_check = LeakCheck::new(
88-
tcx,
89-
universe_at_start_of_snapshot,
90-
max_universe,
91-
overly_polymorphic,
92-
mini_graph,
93-
self,
94-
);
86+
let mut leak_check =
87+
LeakCheck::new(tcx, universe_at_start_of_snapshot, max_universe, mini_graph, self);
9588
leak_check.assign_placeholder_values()?;
9689
leak_check.propagate_scc_value()?;
9790
Ok(())
@@ -101,8 +94,6 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
10194
struct LeakCheck<'me, 'tcx> {
10295
tcx: TyCtxt<'tcx>,
10396
universe_at_start_of_snapshot: ty::UniverseIndex,
104-
/// Only used when reporting region errors.
105-
overly_polymorphic: bool,
10697
mini_graph: &'me MiniGraph<'tcx>,
10798
rcc: &'me RegionConstraintCollector<'me, 'tcx>,
10899

@@ -132,15 +123,13 @@ impl<'me, 'tcx> LeakCheck<'me, 'tcx> {
132123
tcx: TyCtxt<'tcx>,
133124
universe_at_start_of_snapshot: ty::UniverseIndex,
134125
max_universe: ty::UniverseIndex,
135-
overly_polymorphic: bool,
136126
mini_graph: &'me MiniGraph<'tcx>,
137127
rcc: &'me RegionConstraintCollector<'me, 'tcx>,
138128
) -> Self {
139129
let dummy_scc_universe = SccUniverse { universe: max_universe, region: None };
140130
Self {
141131
tcx,
142132
universe_at_start_of_snapshot,
143-
overly_polymorphic,
144133
mini_graph,
145134
rcc,
146135
scc_placeholders: IndexVec::from_elem_n(None, mini_graph.sccs.num_sccs()),
@@ -289,11 +278,7 @@ impl<'me, 'tcx> LeakCheck<'me, 'tcx> {
289278
other_region: ty::Region<'tcx>,
290279
) -> TypeError<'tcx> {
291280
debug!("error: placeholder={:?}, other_region={:?}", placeholder, other_region);
292-
if self.overly_polymorphic {
293-
TypeError::RegionsOverlyPolymorphic(placeholder.bound.kind, other_region)
294-
} else {
295-
TypeError::RegionsInsufficientlyPolymorphic(placeholder.bound.kind, other_region)
296-
}
281+
TypeError::RegionsInsufficientlyPolymorphic(placeholder.bound.kind, other_region)
297282
}
298283
}
299284

compiler/rustc_middle/src/ty/error.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ pub enum TypeError<'tcx> {
4545

4646
RegionsDoesNotOutlive(Region<'tcx>, Region<'tcx>),
4747
RegionsInsufficientlyPolymorphic(BoundRegionKind, Region<'tcx>),
48-
RegionsOverlyPolymorphic(BoundRegionKind, Region<'tcx>),
4948
RegionsPlaceholderMismatch,
5049

5150
Sorts(ExpectedFound<Ty<'tcx>>),
@@ -74,7 +73,6 @@ impl TypeError<'_> {
7473
match self {
7574
TypeError::RegionsDoesNotOutlive(_, _)
7675
| TypeError::RegionsInsufficientlyPolymorphic(_, _)
77-
| TypeError::RegionsOverlyPolymorphic(_, _)
7876
| TypeError::RegionsPlaceholderMismatch => true,
7977
_ => false,
8078
}
@@ -98,11 +96,6 @@ impl<'tcx> TypeError<'tcx> {
9896
}
9997
}
10098

101-
let br_string = |br: ty::BoundRegionKind| match br {
102-
ty::BrNamed(_, name) => format!(" {}", name),
103-
_ => String::new(),
104-
};
105-
10699
match self {
107100
CyclicTy(_) => "cyclic type of infinite size".into(),
108101
CyclicConst(_) => "encountered a self-referencing constant".into(),
@@ -144,11 +137,6 @@ impl<'tcx> TypeError<'tcx> {
144137
RegionsInsufficientlyPolymorphic(..) => {
145138
"one type is more general than the other".into()
146139
}
147-
RegionsOverlyPolymorphic(br, _) => format!(
148-
"expected concrete lifetime, found bound lifetime parameter{}",
149-
br_string(br)
150-
)
151-
.into(),
152140
RegionsPlaceholderMismatch => "one type is more general than the other".into(),
153141
ArgumentSorts(values, _) | Sorts(values) => {
154142
let expected = values.expected.sort_string(tcx);
@@ -228,7 +216,6 @@ impl<'tcx> TypeError<'tcx> {
228216
| FieldMisMatch(..)
229217
| RegionsDoesNotOutlive(..)
230218
| RegionsInsufficientlyPolymorphic(..)
231-
| RegionsOverlyPolymorphic(..)
232219
| RegionsPlaceholderMismatch
233220
| Traits(_)
234221
| ProjectionMismatched(_)

compiler/rustc_trait_selection/src/traits/coherence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ fn overlap_within_probe<'cx, 'tcx>(
200200

201201
// We disable the leak when creating the `snapshot` by using
202202
// `infcx.probe_maybe_disable_leak_check`.
203-
if infcx.leak_check(true, snapshot).is_err() {
203+
if infcx.leak_check(snapshot).is_err() {
204204
debug!("overlap: leak check failed");
205205
return None;
206206
}

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
563563
self.infcx.probe(|snapshot| -> Result<EvaluationResult, OverflowError> {
564564
let result = op(self)?;
565565

566-
match self.infcx.leak_check(true, snapshot) {
566+
match self.infcx.leak_check(snapshot) {
567567
Ok(()) => {}
568568
Err(_) => return Ok(EvaluatedToErr),
569569
}

0 commit comments

Comments
 (0)