Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-i-m committed Jan 13, 2020
1 parent a804868 commit f05e40e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
15 changes: 7 additions & 8 deletions src/librustc_mir/borrow_check/diagnostics/region_errors.rs
Expand Up @@ -138,8 +138,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
if let DefiningTy::Closure(def_id, substs) =
self.regioncx.universal_regions().defining_ty
{
let closure_kind_ty = substs.as_closure().kind_ty(def_id, self.infcx.tcx);
return Some(ty::ClosureKind::FnMut) == closure_kind_ty.to_opt_closure_kind();
return substs.as_closure().kind(def_id, self.infcx.tcx)
== ty::ClosureKind::FnMut;
}
}
}
Expand All @@ -160,7 +160,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
// Try to convert the lower-bound region into something named we can print for the user.
let lower_bound_region = self.to_error_region(type_test.lower_bound);

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

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

RegionErrorKind::RegionError { fr_origin, longer_fr, shorter_fr, is_reported } => {
if is_reported {
self.report_error(
self.report_region_error(
longer_fr,
fr_origin,
shorter_fr,
Expand Down Expand Up @@ -270,21 +269,21 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
/// ```
///
/// Here we would be invoked with `fr = 'a` and `outlived_fr = `'b`.
pub(in crate::borrow_check) fn report_error(
pub(in crate::borrow_check) fn report_region_error(
&mut self,
fr: RegionVid,
fr_origin: NLLRegionVariableOrigin,
outlived_fr: RegionVid,
outlives_suggestion: &mut OutlivesSuggestionBuilder,
) {
debug!("report_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);
debug!("report_region_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);

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

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

debug!(
"report_error: fr_is_local={:?} outlived_fr_is_local={:?} category={:?}",
"report_region_error: fr_is_local={:?} outlived_fr_is_local={:?} category={:?}",
fr_is_local, outlived_fr_is_local, category
);

Expand Down
4 changes: 1 addition & 3 deletions src/librustc_mir/borrow_check/diagnostics/region_name.rs
Expand Up @@ -123,9 +123,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
///
/// This is _not_ idempotent. Call `give_region_a_name` when possible.
fn synthesize_region_name(&self) -> Symbol {
let mut counter = self.next_region_name.try_borrow_mut().unwrap();
let c = *counter;
*counter += 1;
let c = self.next_region_name.replace_with(|counter| *counter + 1);
Symbol::intern(&format!("'{:?}", c))
}

Expand Down
6 changes: 4 additions & 2 deletions src/librustc_mir/borrow_check/region_infer/mod.rs
Expand Up @@ -846,6 +846,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {

// Type-test failed. Report the error.
let erased_generic_kind = infcx.tcx.erase_regions(&type_test.generic_kind);

// Skip duplicate-ish errors.
if deduplicate_errors.insert((
erased_generic_kind,
type_test.lower_bound,
Expand Down Expand Up @@ -1850,8 +1852,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
self.scc_values.contains(r_scc, upper)
}

crate fn universal_regions(&self) -> Rc<UniversalRegions<'tcx>> {
self.universal_regions.clone()
crate fn universal_regions(&self) -> &UniversalRegions<'tcx> {
self.universal_regions.as_ref()
}

/// Tries to find the best constraint to blame for the fact that
Expand Down

0 comments on commit f05e40e

Please sign in to comment.