Skip to content

Commit bcf0ec0

Browse files
committed
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
1 parent 9556b56 commit bcf0ec0

File tree

20 files changed

+37
-42
lines changed

20 files changed

+37
-42
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2589,7 +2589,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25892589
DefKind::InlineConst => substs.as_inline_const().parent_substs(),
25902590
other => bug!("unexpected item {:?}", other),
25912591
};
2592-
let parent_substs = tcx.mk_substs(parent_substs.iter());
2592+
let parent_substs = tcx.intern_substs(parent_substs);
25932593

25942594
assert_eq!(typeck_root_substs.len(), parent_substs.len());
25952595
if let Err(_) = self.eq_substs(

compiler/rustc_codegen_cranelift/src/codegen_i128.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub(crate) fn maybe_codegen<'tcx>(
5656
Some(fx.easy_call("__multi3", &[lhs, rhs], val_ty))
5757
}
5858
} else {
59-
let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter());
59+
let out_ty = fx.tcx.intern_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
6060
let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
6161
let lhs = lhs.load_scalar(fx);
6262
let rhs = rhs.load_scalar(fx);
@@ -78,7 +78,7 @@ pub(crate) fn maybe_codegen<'tcx>(
7878
}
7979
BinOp::Add | BinOp::Sub | BinOp::Mul => {
8080
assert!(checked);
81-
let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter());
81+
let out_ty = fx.tcx.intern_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
8282
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
8383
let (param_types, args) = if fx.tcx.sess.target.is_like_windows {
8484
let (lhs_ptr, lhs_extra) = lhs.force_stack(fx);

compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ fn llvm_add_sub<'tcx>(
191191
// carry0 | carry1 -> carry or borrow respectively
192192
let cb_out = fx.bcx.ins().bor(cb0, cb1);
193193

194-
let layout = fx.layout_of(fx.tcx.mk_tup([fx.tcx.types.u8, fx.tcx.types.u64].iter()));
194+
let layout = fx.layout_of(fx.tcx.intern_tup(&[fx.tcx.types.u8, fx.tcx.types.u64]));
195195
let val = CValue::by_val_pair(cb_out, c, layout);
196196
ret.write_cvalue(fx, val);
197197
}

compiler/rustc_codegen_cranelift/src/main_shim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub(crate) fn maybe_create_entry_wrapper(
119119
tcx,
120120
ParamEnv::reveal_all(),
121121
report.def_id,
122-
tcx.mk_substs([GenericArg::from(main_ret_ty)].iter()),
122+
tcx.intern_substs(&[GenericArg::from(main_ret_ty)]),
123123
)
124124
.unwrap()
125125
.unwrap()

compiler/rustc_codegen_cranelift/src/num.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
289289
_ => bug!("binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", bin_op, in_lhs, in_rhs),
290290
};
291291

292-
let out_layout = fx.layout_of(fx.tcx.mk_tup([in_lhs.layout().ty, fx.tcx.types.bool].iter()));
292+
let out_layout = fx.layout_of(fx.tcx.intern_tup(&[in_lhs.layout().ty, fx.tcx.types.bool]));
293293
CValue::by_val_pair(res, has_overflow, out_layout)
294294
}
295295

compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
9696
let loc_ty = self
9797
.tcx
9898
.type_of(self.tcx.require_lang_item(LangItem::PanicLocation, None))
99-
.subst(*self.tcx, self.tcx.mk_substs([self.tcx.lifetimes.re_erased.into()].iter()));
99+
.subst(*self.tcx, self.tcx.intern_substs(&[self.tcx.lifetimes.re_erased.into()]));
100100
let loc_layout = self.layout_of(loc_ty).unwrap();
101101
let location = self.allocate(loc_layout, MemoryKind::CallerLocation).unwrap();
102102

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
378378
(
379379
1,
380380
vec![tcx.mk_imm_ref(tcx.mk_re_late_bound(ty::INNERMOST, br), param(0))],
381-
tcx.mk_projection(discriminant_def_id, tcx.mk_substs([param(0).into()].iter())),
381+
tcx.mk_projection(discriminant_def_id, tcx.intern_substs(&[param(0).into()])),
382382
)
383383
}
384384

compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
301301

302302
// Build a tuple (U0..Un) of the final upvar types U0..Un
303303
// and unify the upvar tuple type in the closure with it:
304-
let final_tupled_upvars_type = self.tcx.mk_tup(final_upvar_tys.iter());
304+
let final_tupled_upvars_type = self.tcx.intern_tup(&final_upvar_tys);
305305
self.demand_suptype(span, substs.tupled_upvars_ty(), final_tupled_upvars_type);
306306

307307
let fake_reads = delegate
@@ -315,8 +315,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
315315
self.typeck_results.borrow_mut().closure_size_eval.insert(
316316
closure_def_id,
317317
ClosureSizeProfileData {
318-
before_feature_tys: self.tcx.mk_tup(before_feature_tys.into_iter()),
319-
after_feature_tys: self.tcx.mk_tup(after_feature_tys.into_iter()),
318+
before_feature_tys: self.tcx.intern_tup(&before_feature_tys),
319+
after_feature_tys: self.tcx.intern_tup(&after_feature_tys),
320320
},
321321
);
322322
}

compiler/rustc_metadata/src/native_libs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl<'tcx> Collector<'tcx> {
502502
.subst_identity()
503503
.fn_sig(self.tcx)
504504
.inputs()
505-
.map_bound(|slice| self.tcx.mk_type_list(slice.iter())),
505+
.map_bound(|slice| self.tcx.intern_type_list(slice)),
506506
);
507507

508508
argument_types

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,14 +2525,12 @@ impl<'tcx> ConstantKind<'tcx> {
25252525
}
25262526

25272527
let hir_id = tcx.hir().local_def_id_to_hir_id(def.did);
2528-
let parent_substs = if let Some(parent_hir_id) = tcx.hir().opt_parent_id(hir_id) {
2529-
if let Some(parent_did) = parent_hir_id.as_owner() {
2530-
InternalSubsts::identity_for_item(tcx, parent_did.to_def_id())
2531-
} else {
2532-
tcx.mk_substs(Vec::<GenericArg<'tcx>>::new().into_iter())
2533-
}
2528+
let parent_substs = if let Some(parent_hir_id) = tcx.hir().opt_parent_id(hir_id)
2529+
&& let Some(parent_did) = parent_hir_id.as_owner()
2530+
{
2531+
InternalSubsts::identity_for_item(tcx, parent_did.to_def_id())
25342532
} else {
2535-
tcx.mk_substs(Vec::<GenericArg<'tcx>>::new().into_iter())
2533+
tcx.intern_substs(&[])
25362534
};
25372535
debug!(?parent_substs);
25382536

0 commit comments

Comments
 (0)