Skip to content

Commit 16f4980

Browse files
Document check_region_obligations_and_report_errors, simplify a call to resolve_regions
1 parent 1694ea1 commit 16f4980

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

compiler/rustc_infer/src/infer/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13241324
/// result. After this, no more unification operations should be
13251325
/// done -- or the compiler will panic -- but it is legal to use
13261326
/// `resolve_vars_if_possible` as well as `fully_resolve`.
1327+
///
1328+
/// Make sure to call [`InferCtxt::process_registered_region_obligations`]
1329+
/// first, or preferrably use [`InferCtxt::check_region_obligations_and_report_errors`]
1330+
/// to do both of these operations together.
13271331
pub fn resolve_regions_and_report_errors(
13281332
&self,
13291333
generic_param_scope: LocalDefId,

compiler/rustc_infer/src/infer/outlives/obligations.rs

+6
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
111111
std::mem::take(&mut self.inner.borrow_mut().region_obligations)
112112
}
113113

114+
/// NOTE: Prefer using [`InferCtxt::check_region_obligations_and_report_errors`]
115+
/// instead of calling this directly.
116+
///
114117
/// Process the region obligations that must be proven (during
115118
/// `regionck`) for the given `body_id`, given information about
116119
/// the region bounds in scope and so forth. This function must be
@@ -162,6 +165,9 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
162165
}
163166
}
164167

168+
/// Processes registered region obliations and resolves regions, reporting
169+
/// any errors if any were raised. Prefer using this function over manually
170+
/// calling `resolve_regions_and_report_errors`.
165171
pub fn check_region_obligations_and_report_errors(
166172
&self,
167173
generic_param_scope: LocalDefId,

compiler/rustc_trait_selection/src/traits/coherence.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -398,13 +398,7 @@ fn resolve_negative_obligation<'cx, 'tcx>(
398398
let outlives_env = OutlivesEnvironment::new(param_env);
399399
infcx.process_registered_region_obligations(outlives_env.region_bound_pairs(), param_env);
400400

401-
let errors = infcx.resolve_regions(&outlives_env);
402-
403-
if !errors.is_empty() {
404-
return false;
405-
}
406-
407-
true
401+
infcx.resolve_regions(&outlives_env).is_empty()
408402
}
409403

410404
pub fn trait_ref_is_knowable<'tcx>(

0 commit comments

Comments
 (0)