Introduce subst_iter and subst_iter_copied on EarlyBinder
This commit is contained in:
@@ -795,8 +795,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
let mut fn_traits = FxIndexMap::default();
|
||||
let mut is_sized = false;
|
||||
|
||||
for predicate in bounds.transpose_iter().map(|e| e.map_bound(|(p, _)| *p)) {
|
||||
let predicate = predicate.subst(tcx, substs);
|
||||
for (predicate, _) in bounds.subst_iter_copied(tcx, substs) {
|
||||
let bound_predicate = predicate.kind();
|
||||
|
||||
match bound_predicate.skip_binder() {
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::ty::sty::{ClosureSubsts, GeneratorSubsts, InlineConstSubsts};
|
||||
use crate::ty::visit::{TypeVisitable, TypeVisitor};
|
||||
use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt};
|
||||
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::intern::{Interned, WithStableHash};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_macros::HashStable;
|
||||
@@ -550,6 +551,28 @@ impl<T, U> EarlyBinder<(T, U)> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, 's, T: IntoIterator<Item = I>, I: TypeFoldable<'tcx>> EarlyBinder<T> {
|
||||
pub fn subst_iter(
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
substs: &'s [GenericArg<'tcx>],
|
||||
) -> impl Iterator<Item = I> + Captures<'s> + Captures<'tcx> {
|
||||
self.0.into_iter().map(move |t| EarlyBinder(t).subst(tcx, substs))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, 's, 'a, T: IntoIterator<Item = &'a I>, I: Copy + TypeFoldable<'tcx> + 'a>
|
||||
EarlyBinder<T>
|
||||
{
|
||||
pub fn subst_iter_copied(
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
substs: &'s [GenericArg<'tcx>],
|
||||
) -> impl Iterator<Item = I> + Captures<'s> + Captures<'tcx> + Captures<'a> {
|
||||
self.0.into_iter().map(move |t| EarlyBinder(*t).subst(tcx, substs))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct EarlyBinderIter<T> {
|
||||
t: T,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user