Skip to content

Commit 9157775

Browse files
authored
Rollup merge of #94215 - lcnr:leak-check, r=jackh726
trait system: comments and small nonfunctional changes r? `@nikomatsakis` because of the leak-check check removal
2 parents d3649f8 + 6a1f5ea commit 9157775

File tree

7 files changed

+19
-23
lines changed

7 files changed

+19
-23
lines changed

compiler/rustc_data_structures/src/obligation_forest/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ type ObligationTreeIdGenerator =
132132
std::iter::Map<std::ops::RangeFrom<usize>, fn(usize) -> ObligationTreeId>;
133133

134134
pub struct ObligationForest<O: ForestObligation> {
135-
/// The list of obligations. In between calls to `process_obligations`,
135+
/// The list of obligations. In between calls to [Self::process_obligations],
136136
/// this list only contains nodes in the `Pending` or `Waiting` state.
137137
///
138138
/// `usize` indices are used here and throughout this module, rather than
139-
/// `rustc_index::newtype_index!` indices, because this code is hot enough
139+
/// [`rustc_index::newtype_index!`] indices, because this code is hot enough
140140
/// that the `u32`-to-`usize` conversions that would be required are
141141
/// significant, and space considerations are not important.
142142
nodes: Vec<Node<O>>,
@@ -146,10 +146,11 @@ pub struct ObligationForest<O: ForestObligation> {
146146

147147
/// A cache of the nodes in `nodes`, indexed by predicate. Unfortunately,
148148
/// its contents are not guaranteed to match those of `nodes`. See the
149-
/// comments in `process_obligation` for details.
149+
/// comments in [`Self::process_obligation` for details.
150150
active_cache: FxHashMap<O::CacheKey, usize>,
151151

152-
/// A vector reused in compress() and find_cycles_from_node(), to avoid allocating new vectors.
152+
/// A vector reused in [Self::compress()] and [Self::find_cycles_from_node()],
153+
/// to avoid allocating new vectors.
153154
reused_node_vec: Vec<usize>,
154155

155156
obligation_tree_id_generator: ObligationTreeIdGenerator,

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
123123
result
124124
}
125125

126-
/// See `infer::region_constraints::RegionConstraintCollector::leak_check`.
126+
/// See [RegionConstraintCollector::leak_check][1].
127+
///
128+
/// [1]: crate::infer::region_constraints::RegionConstraintCollector::leak_check
127129
pub fn leak_check(
128130
&self,
129131
overly_polymorphic: bool,

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

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
100100
struct LeakCheck<'me, 'tcx> {
101101
tcx: TyCtxt<'tcx>,
102102
universe_at_start_of_snapshot: ty::UniverseIndex,
103+
/// Only used when reporting region errors.
103104
overly_polymorphic: bool,
104105
mini_graph: &'me MiniGraph<'tcx>,
105106
rcc: &'me RegionConstraintCollector<'me, 'tcx>,

compiler/rustc_trait_selection/src/traits/coherence.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,12 @@ fn overlap<'cx, 'tcx>(
160160
);
161161

162162
selcx.infcx().probe_maybe_skip_leak_check(skip_leak_check.is_yes(), |snapshot| {
163-
overlap_within_probe(
164-
selcx,
165-
skip_leak_check,
166-
impl1_def_id,
167-
impl2_def_id,
168-
overlap_mode,
169-
snapshot,
170-
)
163+
overlap_within_probe(selcx, impl1_def_id, impl2_def_id, overlap_mode, snapshot)
171164
})
172165
}
173166

174167
fn overlap_within_probe<'cx, 'tcx>(
175168
selcx: &mut SelectionContext<'cx, 'tcx>,
176-
skip_leak_check: SkipLeakCheck,
177169
impl1_def_id: DefId,
178170
impl2_def_id: DefId,
179171
overlap_mode: OverlapMode,
@@ -207,11 +199,11 @@ fn overlap_within_probe<'cx, 'tcx>(
207199
}
208200
}
209201

210-
if !skip_leak_check.is_yes() {
211-
if infcx.leak_check(true, snapshot).is_err() {
212-
debug!("overlap: leak check failed");
213-
return None;
214-
}
202+
// We disable the leak when when creating the `snapshot` by using
203+
// `infcx.probe_maybe_disable_leak_check`.
204+
if infcx.leak_check(true, snapshot).is_err() {
205+
debug!("overlap: leak check failed");
206+
return None;
215207
}
216208

217209
let intercrate_ambiguity_causes = selcx.take_intercrate_ambiguity_causes();

compiler/rustc_trait_selection/src/traits/fulfill.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
314314
return ProcessResult::Unchanged;
315315
}
316316

317-
self.progress_changed_obligations(pending_obligation)
317+
self.process_changed_obligations(pending_obligation)
318318
}
319319

320320
fn process_backedge<'c, I>(
@@ -338,7 +338,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
338338
// actually uses this, so move this part of the code
339339
// out of that loop.
340340
#[inline(never)]
341-
fn progress_changed_obligations(
341+
fn process_changed_obligations(
342342
&mut self,
343343
pending_obligation: &mut PendingPredicateObligation<'tcx>,
344344
) -> ProcessResult<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
389389
for bound in matching_bounds {
390390
// FIXME(oli-obk): it is suspicious that we are dropping the constness and
391391
// polarity here.
392-
let wc = self.evaluate_where_clause(stack, bound.map_bound(|t| t.trait_ref))?;
392+
let wc = self.where_clause_may_apply(stack, bound.map_bound(|t| t.trait_ref))?;
393393
if wc.may_apply() {
394394
candidates.vec.push(ParamCandidate(bound));
395395
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14811481
.map_err(|_| ())
14821482
}
14831483

1484-
fn evaluate_where_clause<'o>(
1484+
fn where_clause_may_apply<'o>(
14851485
&mut self,
14861486
stack: &TraitObligationStack<'o, 'tcx>,
14871487
where_clause_trait_ref: ty::PolyTraitRef<'tcx>,

0 commit comments

Comments
 (0)