1
Fork 0

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:
Nicholas Nethercote 2023-02-16 11:47:50 +11:00
parent 9556b56dbd
commit bcf0ec0191
20 changed files with 37 additions and 42 deletions

View file

@ -813,21 +813,18 @@ fn transform_substs<'tcx>(
substs: SubstsRef<'tcx>,
options: TransformTyOptions,
) -> SubstsRef<'tcx> {
let substs: Vec<GenericArg<'tcx>> = substs
.iter()
.map(|subst| {
if let GenericArgKind::Type(ty) = subst.unpack() {
if is_c_void_ty(tcx, ty) {
tcx.mk_unit().into()
} else {
transform_ty(tcx, ty, options).into()
}
let substs = substs.iter().map(|subst| {
if let GenericArgKind::Type(ty) = subst.unpack() {
if is_c_void_ty(tcx, ty) {
tcx.mk_unit().into()
} else {
subst
transform_ty(tcx, ty, options).into()
}
})
.collect();
tcx.mk_substs(substs.iter())
} else {
subst
}
});
tcx.mk_substs(substs)
}
/// Returns a type metadata identifier for the specified FnAbi using the Itanium C++ ABI with vendor