mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
fold_region: remove unused parameter
This commit is contained in:
parent
4dbf9ba0ab
commit
70497d9d10
@ -879,7 +879,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut found = false;
|
let mut found = false;
|
||||||
tcx.fold_regions(tcx.type_of(body_parent_did), &mut true, |r: ty::Region<'tcx>, _| {
|
tcx.fold_regions(tcx.type_of(body_parent_did), |r: ty::Region<'tcx>, _| {
|
||||||
if *r == ty::ReEarlyBound(region) {
|
if *r == ty::ReEarlyBound(region) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1009,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
|
|
||||||
debug!("try_promote_type_test_subject(ty = {:?})", ty);
|
debug!("try_promote_type_test_subject(ty = {:?})", ty);
|
||||||
|
|
||||||
let ty = tcx.fold_regions(ty, &mut false, |r, _depth| {
|
let ty = tcx.fold_regions(ty, |r, _depth| {
|
||||||
let region_vid = self.to_region_vid(r);
|
let region_vid = self.to_region_vid(r);
|
||||||
|
|
||||||
// The challenge if this. We have some region variable `r`
|
// The challenge if this. We have some region variable `r`
|
||||||
@ -1289,7 +1289,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
tcx.fold_regions(value, &mut false, |r, _db| {
|
tcx.fold_regions(value, |r, _db| {
|
||||||
let vid = self.to_region_vid(r);
|
let vid = self.to_region_vid(r);
|
||||||
let scc = self.constraint_sccs.scc(vid);
|
let scc = self.constraint_sccs.scc(vid);
|
||||||
let repr = self.scc_representatives[scc];
|
let repr = self.scc_representatives[scc];
|
||||||
|
@ -59,7 +59,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
debug!(?concrete_type, ?substs);
|
debug!(?concrete_type, ?substs);
|
||||||
|
|
||||||
let mut subst_regions = vec![self.universal_regions.fr_static];
|
let mut subst_regions = vec![self.universal_regions.fr_static];
|
||||||
let universal_substs = infcx.tcx.fold_regions(substs, &mut false, |region, _| {
|
let universal_substs = infcx.tcx.fold_regions(substs, |region, _| {
|
||||||
if let ty::RePlaceholder(..) = region.kind() {
|
if let ty::RePlaceholder(..) = region.kind() {
|
||||||
// Higher kinded regions don't need remapping, they don't refer to anything outside of this the substs.
|
// Higher kinded regions don't need remapping, they don't refer to anything outside of this the substs.
|
||||||
return region;
|
return region;
|
||||||
@ -91,7 +91,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
subst_regions.dedup();
|
subst_regions.dedup();
|
||||||
|
|
||||||
let universal_concrete_type =
|
let universal_concrete_type =
|
||||||
infcx.tcx.fold_regions(concrete_type, &mut false, |region, _| match *region {
|
infcx.tcx.fold_regions(concrete_type, |region, _| match *region {
|
||||||
ty::ReVar(vid) => subst_regions
|
ty::ReVar(vid) => subst_regions
|
||||||
.iter()
|
.iter()
|
||||||
.find(|ur_vid| self.eval_equal(vid, **ur_vid))
|
.find(|ur_vid| self.eval_equal(vid, **ur_vid))
|
||||||
@ -146,7 +146,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
tcx.fold_regions(ty, &mut false, |region, _| match *region {
|
tcx.fold_regions(ty, |region, _| match *region {
|
||||||
ty::ReVar(vid) => {
|
ty::ReVar(vid) => {
|
||||||
// Find something that we can name
|
// Find something that we can name
|
||||||
let upper_bound = self.approx_universal_upper_bound(vid);
|
let upper_bound = self.approx_universal_upper_bound(vid);
|
||||||
|
@ -31,7 +31,7 @@ pub fn renumber_regions<'tcx, T>(infcx: &InferCtxt<'_, 'tcx>, value: T) -> T
|
|||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
infcx.tcx.fold_regions(value, &mut false, |_region, _depth| {
|
infcx.tcx.fold_regions(value, |_region, _depth| {
|
||||||
let origin = NllRegionVariableOrigin::Existential { from_forall: false };
|
let origin = NllRegionVariableOrigin::Existential { from_forall: false };
|
||||||
infcx.next_nll_region_var(origin)
|
infcx.next_nll_region_var(origin)
|
||||||
})
|
})
|
||||||
|
@ -108,7 +108,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
|
|||||||
// create new region variables, which can't be done later when
|
// create new region variables, which can't be done later when
|
||||||
// verifying these bounds.
|
// verifying these bounds.
|
||||||
if t1.has_placeholders() {
|
if t1.has_placeholders() {
|
||||||
t1 = tcx.fold_regions(t1, &mut false, |r, _| match *r {
|
t1 = tcx.fold_regions(t1, |r, _| match *r {
|
||||||
ty::RePlaceholder(placeholder) => {
|
ty::RePlaceholder(placeholder) => {
|
||||||
self.constraints.placeholder_region(self.infcx, placeholder)
|
self.constraints.placeholder_region(self.infcx, placeholder)
|
||||||
}
|
}
|
||||||
|
@ -725,7 +725,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
|
|||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
self.tcx.fold_regions(value, &mut false, |_region, _depth| self.next_nll_region_var(origin))
|
self.tcx.fold_regions(value, |_region, _depth| self.next_nll_region_var(origin))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(self, indices))]
|
#[instrument(level = "debug", skip(self, indices))]
|
||||||
@ -817,9 +817,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
|
|||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
tcx.fold_regions(value, &mut false, |region, _| {
|
tcx.fold_regions(value, |region, _| tcx.mk_region(ty::ReVar(self.to_region_vid(region))))
|
||||||
tcx.mk_region(ty::ReVar(self.to_region_vid(region)))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ pub fn find_param_with_region<'tcx>(
|
|||||||
// May return None; sometimes the tables are not yet populated.
|
// May return None; sometimes the tables are not yet populated.
|
||||||
let ty = fn_sig.inputs()[index];
|
let ty = fn_sig.inputs()[index];
|
||||||
let mut found_anon_region = false;
|
let mut found_anon_region = false;
|
||||||
let new_param_ty = tcx.fold_regions(ty, &mut false, |r, _| {
|
let new_param_ty = tcx.fold_regions(ty, |r, _| {
|
||||||
if r == anon_region {
|
if r == anon_region {
|
||||||
found_anon_region = true;
|
found_anon_region = true;
|
||||||
replace_region
|
replace_region
|
||||||
|
@ -868,7 +868,7 @@ impl<'tcx> LexicalRegionResolutions<'tcx> {
|
|||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
tcx.fold_regions(value, &mut false, |r, _db| match *r {
|
tcx.fold_regions(value, |r, _db| match *r {
|
||||||
ty::ReVar(rid) => self.resolve_var(rid),
|
ty::ReVar(rid) => self.resolve_var(rid),
|
||||||
_ => r,
|
_ => r,
|
||||||
})
|
})
|
||||||
|
@ -465,13 +465,12 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
pub fn fold_regions<T>(
|
pub fn fold_regions<T>(
|
||||||
self,
|
self,
|
||||||
value: T,
|
value: T,
|
||||||
skipped_regions: &mut bool,
|
|
||||||
mut f: impl FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>,
|
mut f: impl FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>,
|
||||||
) -> T
|
) -> T
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
value.fold_with(&mut RegionFolder::new(self, skipped_regions, &mut f))
|
value.fold_with(&mut RegionFolder::new(self, &mut f))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Invoke `callback` on every region appearing free in `value`.
|
/// Invoke `callback` on every region appearing free in `value`.
|
||||||
@ -579,7 +578,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
pub struct RegionFolder<'a, 'tcx> {
|
pub struct RegionFolder<'a, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
skipped_regions: &'a mut bool,
|
|
||||||
|
|
||||||
/// Stores the index of a binder *just outside* the stuff we have
|
/// Stores the index of a binder *just outside* the stuff we have
|
||||||
/// visited. So this begins as INNERMOST; when we pass through a
|
/// visited. So this begins as INNERMOST; when we pass through a
|
||||||
@ -597,10 +595,9 @@ impl<'a, 'tcx> RegionFolder<'a, 'tcx> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
skipped_regions: &'a mut bool,
|
|
||||||
fold_region_fn: &'a mut dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>,
|
fold_region_fn: &'a mut dyn FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>,
|
||||||
) -> RegionFolder<'a, 'tcx> {
|
) -> RegionFolder<'a, 'tcx> {
|
||||||
RegionFolder { tcx, skipped_regions, current_index: ty::INNERMOST, fold_region_fn }
|
RegionFolder { tcx, current_index: ty::INNERMOST, fold_region_fn }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,7 +621,6 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx> {
|
|||||||
match *r {
|
match *r {
|
||||||
ty::ReLateBound(debruijn, _) if debruijn < self.current_index => {
|
ty::ReLateBound(debruijn, _) if debruijn < self.current_index => {
|
||||||
debug!(?self.current_index, "skipped bound region");
|
debug!(?self.current_index, "skipped bound region");
|
||||||
*self.skipped_regions = true;
|
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -225,7 +225,7 @@ pub fn resolve_interior<'a, 'tcx>(
|
|||||||
// Note that each region slot in the types gets a new fresh late bound region,
|
// Note that each region slot in the types gets a new fresh late bound region,
|
||||||
// which means that none of the regions inside relate to any other, even if
|
// which means that none of the regions inside relate to any other, even if
|
||||||
// typeck had previously found constraints that would cause them to be related.
|
// typeck had previously found constraints that would cause them to be related.
|
||||||
let folded = fcx.tcx.fold_regions(erased, &mut false, |_, current_depth| {
|
let folded = fcx.tcx.fold_regions(erased, |_, current_depth| {
|
||||||
let br = ty::BoundRegion {
|
let br = ty::BoundRegion {
|
||||||
var: ty::BoundVar::from_u32(counter),
|
var: ty::BoundVar::from_u32(counter),
|
||||||
kind: ty::BrAnon(counter),
|
kind: ty::BrAnon(counter),
|
||||||
|
@ -393,7 +393,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn ct_infer(&self, ty: Ty<'tcx>, _: Option<&ty::GenericParamDef>, span: Span) -> Const<'tcx> {
|
fn ct_infer(&self, ty: Ty<'tcx>, _: Option<&ty::GenericParamDef>, span: Span) -> Const<'tcx> {
|
||||||
let ty = self.tcx.fold_regions(ty, &mut false, |r, _| match *r {
|
let ty = self.tcx.fold_regions(ty, |r, _| match *r {
|
||||||
ty::ReErased => self.tcx.lifetimes.re_static,
|
ty::ReErased => self.tcx.lifetimes.re_static,
|
||||||
_ => r,
|
_ => r,
|
||||||
});
|
});
|
||||||
@ -1917,7 +1917,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
|
|||||||
Some(ty) => {
|
Some(ty) => {
|
||||||
let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id];
|
let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id];
|
||||||
// Typeck doesn't expect erased regions to be returned from `type_of`.
|
// Typeck doesn't expect erased regions to be returned from `type_of`.
|
||||||
let fn_sig = tcx.fold_regions(fn_sig, &mut false, |r, _| match *r {
|
let fn_sig = tcx.fold_regions(fn_sig, |r, _| match *r {
|
||||||
ty::ReErased => tcx.lifetimes.re_static,
|
ty::ReErased => tcx.lifetimes.re_static,
|
||||||
_ => r,
|
_ => r,
|
||||||
});
|
});
|
||||||
|
@ -772,7 +772,7 @@ fn infer_placeholder_type<'a>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Typeck doesn't expect erased regions to be returned from `type_of`.
|
// Typeck doesn't expect erased regions to be returned from `type_of`.
|
||||||
tcx.fold_regions(ty, &mut false, |r, _| match *r {
|
tcx.fold_regions(ty, |r, _| match *r {
|
||||||
ty::ReErased => tcx.lifetimes.re_static,
|
ty::ReErased => tcx.lifetimes.re_static,
|
||||||
_ => r,
|
_ => r,
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user