Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
address review comments
  • Loading branch information
mark-i-m committed Jan 13, 2020
commit f05e40eb992fce44db348cfb1e8ecb4699e9cdd6
15 changes: 7 additions & 8 deletions src/librustc_mir/borrow_check/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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