uplift fold_regions to rustc_type_ir

This commit is contained in:
lcnr 2024-11-27 18:37:39 +01:00
parent f005c7437d
commit 9fe7750bcd
24 changed files with 129 additions and 115 deletions

View file

@ -3,6 +3,7 @@
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::fold::fold_regions;
use rustc_middle::ty::{self, Binder, Region, Ty, TyCtxt, TypeFoldable};
use rustc_span::Span;
use tracing::instrument;
@ -83,7 +84,7 @@ pub fn find_param_with_region<'tcx>(
// May return None; sometimes the tables are not yet populated.
let ty = fn_sig.inputs()[index];
let mut found_anon_region = false;
let new_param_ty = tcx.fold_regions(ty, |r, _| {
let new_param_ty = fold_regions(tcx, ty, |r, _| {
if r == anon_region {
found_anon_region = true;
replace_region

View file

@ -25,6 +25,7 @@ use rustc_middle::dep_graph::{DepNodeIndex, dep_kinds};
pub use rustc_middle::traits::select::*;
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::error::TypeErrorToStringExt;
use rustc_middle::ty::fold::fold_regions;
use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths};
use rustc_middle::ty::{
self, GenericArgsRef, PolyProjectionPredicate, Ty, TyCtxt, TypeFoldable, TypeVisitableExt,
@ -3209,7 +3210,7 @@ fn bind_coroutine_hidden_types_above<'tcx>(
// Only remap erased regions if we use them.
if considering_regions {
bty = bty.map_bound(|ty| {
tcx.fold_regions(ty, |r, current_depth| match r.kind() {
fold_regions(tcx, ty, |r, current_depth| match r.kind() {
ty::ReErased => {
let br = ty::BoundRegion {
var: ty::BoundVar::from_u32(counter),