universal_regions: rustfmt
This commit is contained in:
parent
8b3ce9ca68
commit
fa02d68eec
@ -22,15 +22,15 @@
|
|||||||
//! The code in this file doesn't *do anything* with those results; it
|
//! The code in this file doesn't *do anything* with those results; it
|
||||||
//! just returns them for other code to use.
|
//! just returns them for other code to use.
|
||||||
|
|
||||||
use rustc::hir::{self, BodyOwnerKind, HirId};
|
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
use rustc::infer::{InferCtxt, NLLRegionVariableOrigin};
|
use rustc::hir::{self, BodyOwnerKind, HirId};
|
||||||
use rustc::infer::region_constraints::GenericKind;
|
|
||||||
use rustc::infer::outlives::bounds::{self, OutlivesBound};
|
use rustc::infer::outlives::bounds::{self, OutlivesBound};
|
||||||
use rustc::infer::outlives::free_region_map::FreeRegionRelations;
|
use rustc::infer::outlives::free_region_map::FreeRegionRelations;
|
||||||
use rustc::ty::{self, RegionVid, Ty, TyCtxt, ClosureSubsts, GeneratorSubsts};
|
use rustc::infer::region_constraints::GenericKind;
|
||||||
|
use rustc::infer::{InferCtxt, NLLRegionVariableOrigin};
|
||||||
use rustc::ty::fold::TypeFoldable;
|
use rustc::ty::fold::TypeFoldable;
|
||||||
use rustc::ty::subst::Substs;
|
use rustc::ty::subst::Substs;
|
||||||
|
use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid, Ty, TyCtxt};
|
||||||
use rustc::util::nodemap::FxHashMap;
|
use rustc::util::nodemap::FxHashMap;
|
||||||
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
|
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
|
||||||
use rustc_data_structures::transitive_relation::TransitiveRelation;
|
use rustc_data_structures::transitive_relation::TransitiveRelation;
|
||||||
@ -493,18 +493,15 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
|
|||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"build: global regions = {}..{}",
|
"build: global regions = {}..{}",
|
||||||
FIRST_GLOBAL_INDEX,
|
FIRST_GLOBAL_INDEX, first_extern_index
|
||||||
first_extern_index
|
|
||||||
);
|
);
|
||||||
debug!(
|
debug!(
|
||||||
"build: extern regions = {}..{}",
|
"build: extern regions = {}..{}",
|
||||||
first_extern_index,
|
first_extern_index, first_local_index
|
||||||
first_local_index
|
|
||||||
);
|
);
|
||||||
debug!(
|
debug!(
|
||||||
"build: local regions = {}..{}",
|
"build: local regions = {}..{}",
|
||||||
first_local_index,
|
first_local_index, num_universals
|
||||||
num_universals
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let yield_ty = match defining_ty {
|
let yield_ty = match defining_ty {
|
||||||
@ -548,7 +545,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
|
|||||||
let defining_ty = self.infcx
|
let defining_ty = self.infcx
|
||||||
.replace_free_regions_with_nll_infer_vars(FR, &defining_ty);
|
.replace_free_regions_with_nll_infer_vars(FR, &defining_ty);
|
||||||
|
|
||||||
match defining_ty.sty {
|
match defining_ty.sty {
|
||||||
ty::TyClosure(def_id, substs) => DefiningTy::Closure(def_id, substs),
|
ty::TyClosure(def_id, substs) => DefiningTy::Closure(def_id, substs),
|
||||||
ty::TyGenerator(def_id, substs, movability) => {
|
ty::TyGenerator(def_id, substs, movability) => {
|
||||||
DefiningTy::Generator(def_id, substs, movability)
|
DefiningTy::Generator(def_id, substs, movability)
|
||||||
@ -587,8 +584,8 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
|
|||||||
let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id);
|
let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id);
|
||||||
let identity_substs = Substs::identity_for_item(gcx, closure_base_def_id);
|
let identity_substs = Substs::identity_for_item(gcx, closure_base_def_id);
|
||||||
let fr_substs = match defining_ty {
|
let fr_substs = match defining_ty {
|
||||||
DefiningTy::Closure(_, ClosureSubsts { ref substs }) |
|
DefiningTy::Closure(_, ClosureSubsts { ref substs })
|
||||||
DefiningTy::Generator(_, GeneratorSubsts { ref substs }, _) => {
|
| DefiningTy::Generator(_, GeneratorSubsts { ref substs }, _) => {
|
||||||
// In the case of closures, we rely on the fact that
|
// In the case of closures, we rely on the fact that
|
||||||
// the first N elements in the ClosureSubsts are
|
// the first N elements in the ClosureSubsts are
|
||||||
// inherited from the `closure_base_def_id`.
|
// inherited from the `closure_base_def_id`.
|
||||||
@ -726,8 +723,7 @@ impl UniversalRegionRelations {
|
|||||||
fn relate_universal_regions(&mut self, fr_a: RegionVid, fr_b: RegionVid) {
|
fn relate_universal_regions(&mut self, fr_a: RegionVid, fr_b: RegionVid) {
|
||||||
debug!(
|
debug!(
|
||||||
"relate_universal_regions: fr_a={:?} outlives fr_b={:?}",
|
"relate_universal_regions: fr_a={:?} outlives fr_b={:?}",
|
||||||
fr_a,
|
fr_a, fr_b
|
||||||
fr_b
|
|
||||||
);
|
);
|
||||||
self.outlives.add(fr_a, fr_b);
|
self.outlives.add(fr_a, fr_b);
|
||||||
self.inverse_outlives.add(fr_b, fr_a);
|
self.inverse_outlives.add(fr_b, fr_a);
|
||||||
@ -780,8 +776,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'gcx, 'tcx> {
|
|||||||
{
|
{
|
||||||
debug!(
|
debug!(
|
||||||
"replace_bound_regions_with_nll_infer_vars(value={:?}, all_outlive_scope={:?})",
|
"replace_bound_regions_with_nll_infer_vars(value={:?}, all_outlive_scope={:?})",
|
||||||
value,
|
value, all_outlive_scope,
|
||||||
all_outlive_scope,
|
|
||||||
);
|
);
|
||||||
let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| {
|
let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| {
|
||||||
let liberated_region = self.tcx.mk_region(ty::ReFree(ty::FreeRegion {
|
let liberated_region = self.tcx.mk_region(ty::ReFree(ty::FreeRegion {
|
||||||
@ -790,7 +785,10 @@ impl<'cx, 'gcx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'gcx, 'tcx> {
|
|||||||
}));
|
}));
|
||||||
let region_vid = self.next_nll_region_var(origin);
|
let region_vid = self.next_nll_region_var(origin);
|
||||||
indices.insert_late_bound_region(liberated_region, region_vid.to_region_vid());
|
indices.insert_late_bound_region(liberated_region, region_vid.to_region_vid());
|
||||||
debug!("liberated_region={:?} => {:?}", liberated_region, region_vid);
|
debug!(
|
||||||
|
"liberated_region={:?} => {:?}",
|
||||||
|
liberated_region, region_vid
|
||||||
|
);
|
||||||
region_vid
|
region_vid
|
||||||
});
|
});
|
||||||
value
|
value
|
||||||
@ -803,9 +801,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
|
|||||||
/// in later and instantiate the late-bound regions, and then we
|
/// in later and instantiate the late-bound regions, and then we
|
||||||
/// insert the `ReFree` version of those into the map as
|
/// insert the `ReFree` version of those into the map as
|
||||||
/// well. These are used for error reporting.
|
/// well. These are used for error reporting.
|
||||||
fn insert_late_bound_region(&mut self, r: ty::Region<'tcx>,
|
fn insert_late_bound_region(&mut self, r: ty::Region<'tcx>, vid: ty::RegionVid) {
|
||||||
vid: ty::RegionVid)
|
|
||||||
{
|
|
||||||
self.indices.insert(r, vid);
|
self.indices.insert(r, vid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,9 +817,9 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
|
|||||||
if let ty::ReVar(..) = r {
|
if let ty::ReVar(..) = r {
|
||||||
r.to_region_vid()
|
r.to_region_vid()
|
||||||
} else {
|
} else {
|
||||||
*self.indices.get(&r).unwrap_or_else(|| {
|
*self.indices
|
||||||
bug!("cannot convert `{:?}` to a region vid", r)
|
.get(&r)
|
||||||
})
|
.unwrap_or_else(|| bug!("cannot convert `{:?}` to a region vid", r))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user