address review comments
This commit is contained in:
parent
a804868bbf
commit
f05e40eb99
3 changed files with 12 additions and 13 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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,
|
||||
|
|
@ -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);
|
||||
|
|
@ -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
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue