Skip to content

Commit f05e40e

Browse files
committed
address review comments
1 parent a804868 commit f05e40e

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

src/librustc_mir/borrow_check/diagnostics/region_errors.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
138138
if let DefiningTy::Closure(def_id, substs) =
139139
self.regioncx.universal_regions().defining_ty
140140
{
141-
let closure_kind_ty = substs.as_closure().kind_ty(def_id, self.infcx.tcx);
142-
return Some(ty::ClosureKind::FnMut) == closure_kind_ty.to_opt_closure_kind();
141+
return substs.as_closure().kind(def_id, self.infcx.tcx)
142+
== ty::ClosureKind::FnMut;
143143
}
144144
}
145145
}
@@ -160,7 +160,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
160160
// Try to convert the lower-bound region into something named we can print for the user.
161161
let lower_bound_region = self.to_error_region(type_test.lower_bound);
162162

163-
// Skip duplicate-ish errors.
164163
let type_test_span = type_test.locations.span(&self.body);
165164

166165
if let Some(lower_bound_region) = lower_bound_region {
@@ -236,7 +235,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
236235

237236
RegionErrorKind::RegionError { fr_origin, longer_fr, shorter_fr, is_reported } => {
238237
if is_reported {
239-
self.report_error(
238+
self.report_region_error(
240239
longer_fr,
241240
fr_origin,
242241
shorter_fr,
@@ -270,21 +269,21 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
270269
/// ```
271270
///
272271
/// Here we would be invoked with `fr = 'a` and `outlived_fr = `'b`.
273-
pub(in crate::borrow_check) fn report_error(
272+
pub(in crate::borrow_check) fn report_region_error(
274273
&mut self,
275274
fr: RegionVid,
276275
fr_origin: NLLRegionVariableOrigin,
277276
outlived_fr: RegionVid,
278277
outlives_suggestion: &mut OutlivesSuggestionBuilder,
279278
) {
280-
debug!("report_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);
279+
debug!("report_region_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);
281280

282281
let (category, _, span) =
283282
self.regioncx.best_blame_constraint(&self.body, fr, fr_origin, |r| {
284283
self.regioncx.provides_universal_region(r, fr, outlived_fr)
285284
});
286285

287-
debug!("report_error: category={:?} {:?}", category, span);
286+
debug!("report_region_error: category={:?} {:?}", category, span);
288287
// Check if we can use one of the "nice region errors".
289288
if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) {
290289
let tables = self.infcx.tcx.typeck_tables_of(self.mir_def_id);
@@ -301,7 +300,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
301300
);
302301

303302
debug!(
304-
"report_error: fr_is_local={:?} outlived_fr_is_local={:?} category={:?}",
303+
"report_region_error: fr_is_local={:?} outlived_fr_is_local={:?} category={:?}",
305304
fr_is_local, outlived_fr_is_local, category
306305
);
307306

src/librustc_mir/borrow_check/diagnostics/region_name.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
123123
///
124124
/// This is _not_ idempotent. Call `give_region_a_name` when possible.
125125
fn synthesize_region_name(&self) -> Symbol {
126-
let mut counter = self.next_region_name.try_borrow_mut().unwrap();
127-
let c = *counter;
128-
*counter += 1;
126+
let c = self.next_region_name.replace_with(|counter| *counter + 1);
129127
Symbol::intern(&format!("'{:?}", c))
130128
}
131129

src/librustc_mir/borrow_check/region_infer/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
846846

847847
// Type-test failed. Report the error.
848848
let erased_generic_kind = infcx.tcx.erase_regions(&type_test.generic_kind);
849+
850+
// Skip duplicate-ish errors.
849851
if deduplicate_errors.insert((
850852
erased_generic_kind,
851853
type_test.lower_bound,
@@ -1850,8 +1852,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
18501852
self.scc_values.contains(r_scc, upper)
18511853
}
18521854

1853-
crate fn universal_regions(&self) -> Rc<UniversalRegions<'tcx>> {
1854-
self.universal_regions.clone()
1855+
crate fn universal_regions(&self) -> &UniversalRegions<'tcx> {
1856+
self.universal_regions.as_ref()
18551857
}
18561858

18571859
/// Tries to find the best constraint to blame for the fact that

0 commit comments

Comments
 (0)