Replace mk_foo
calls with infer_foo
where possible.
There are several `mk_foo`/`intern_foo` pairs, where the former takes an iterator and the latter takes a slice. (This naming convention is bad, but that's a fix for another PR.) This commit changes several `mk_foo` occurrences into `intern_foo`, avoiding the need for some `.iter()`/`.into_iter()` calls. Affected cases: - mk_type_list - mk_tup - mk_substs - mk_const_list
This commit is contained in:
parent
9556b56dbd
commit
bcf0ec0191
20 changed files with 37 additions and 42 deletions
|
@ -2525,14 +2525,12 @@ impl<'tcx> ConstantKind<'tcx> {
|
|||
}
|
||||
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def.did);
|
||||
let parent_substs = if let Some(parent_hir_id) = tcx.hir().opt_parent_id(hir_id) {
|
||||
if let Some(parent_did) = parent_hir_id.as_owner() {
|
||||
InternalSubsts::identity_for_item(tcx, parent_did.to_def_id())
|
||||
} else {
|
||||
tcx.mk_substs(Vec::<GenericArg<'tcx>>::new().into_iter())
|
||||
}
|
||||
let parent_substs = if let Some(parent_hir_id) = tcx.hir().opt_parent_id(hir_id)
|
||||
&& let Some(parent_did) = parent_hir_id.as_owner()
|
||||
{
|
||||
InternalSubsts::identity_for_item(tcx, parent_did.to_def_id())
|
||||
} else {
|
||||
tcx.mk_substs(Vec::<GenericArg<'tcx>>::new().into_iter())
|
||||
tcx.intern_substs(&[])
|
||||
};
|
||||
debug!(?parent_substs);
|
||||
|
||||
|
|
|
@ -1190,7 +1190,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
self.mk_imm_ref(
|
||||
self.lifetimes.re_static,
|
||||
self.type_of(self.require_lang_item(LangItem::PanicLocation, None))
|
||||
.subst(self, self.mk_substs([self.lifetimes.re_static.into()].iter())),
|
||||
.subst(self, self.intern_substs(&[self.lifetimes.re_static.into()])),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -686,7 +686,7 @@ where
|
|||
Increase this counter if you tried to implement this but
|
||||
failed to do it without duplicating a lot of code from
|
||||
other places in the compiler: 2
|
||||
tcx.mk_tup(&[
|
||||
tcx.intern_tup(&[
|
||||
tcx.mk_array(tcx.types.usize, 3),
|
||||
tcx.mk_array(Option<fn()>),
|
||||
])
|
||||
|
|
|
@ -673,7 +673,7 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
|
|||
for (a_arg, b_arg) in aa.iter().zip(ba.iter()) {
|
||||
related_args.push(r.consts(a_arg, b_arg)?);
|
||||
}
|
||||
let related_args = tcx.mk_const_list(related_args.iter());
|
||||
let related_args = tcx.intern_const_list(&related_args);
|
||||
Expr::FunctionCall(func, related_args)
|
||||
}
|
||||
_ => return Err(TypeError::ConstMismatch(expected_found(r, a, b))),
|
||||
|
|
|
@ -418,7 +418,7 @@ impl<'tcx> ir::TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<ty::PolyExistential
|
|||
|
||||
impl<'tcx> ir::TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<ty::Const<'tcx>> {
|
||||
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
|
||||
ty::util::fold_list(self, folder, |tcx, v| tcx.mk_const_list(v.iter()))
|
||||
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_const_list(v))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue