Skip to content

Commit a9842c7

Browse files
committed
Auto merge of #108112 - nnethercote:clarify-iterator-interners, r=oli-obk,compiler-errors
Clarify iterator interners I found the iterator interners very confusing. This PR clarifies things. r? `@compiler-errors`
2 parents 231bcd1 + af32411 commit a9842c7

File tree

36 files changed

+173
-186
lines changed

36 files changed

+173
-186
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_codegen_llvm/src/coverageinfo/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ use rustc_middle::ty::Instance;
2727
use std::cell::RefCell;
2828
use std::ffi::CString;
2929

30-
use std::iter;
31-
3230
pub mod mapgen;
3331

3432
const UNUSED_FUNCTION_COUNTER_ID: CounterValueReference = CounterValueReference::START;
@@ -201,7 +199,7 @@ fn declare_unused_fn<'tcx>(cx: &CodegenCx<'_, 'tcx>, def_id: DefId) -> Instance<
201199
tcx.symbol_name(instance).name,
202200
cx.fn_abi_of_fn_ptr(
203201
ty::Binder::dummy(tcx.mk_fn_sig(
204-
iter::once(tcx.mk_unit()),
202+
[tcx.mk_unit()],
205203
tcx.mk_unit(),
206204
false,
207205
hir::Unsafety::Unsafe,

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use rustc_target::abi::{self, Align, HasDataLayout, Primitive};
2222
use rustc_target::spec::{HasTargetSpec, PanicStrategy};
2323

2424
use std::cmp::Ordering;
25-
use std::iter;
2625

2726
fn get_simple_intrinsic<'ll>(
2827
cx: &CodegenCx<'ll, '_>,
@@ -798,23 +797,23 @@ fn get_rust_try_fn<'ll, 'tcx>(
798797
let i8p = tcx.mk_mut_ptr(tcx.types.i8);
799798
// `unsafe fn(*mut i8) -> ()`
800799
let try_fn_ty = tcx.mk_fn_ptr(ty::Binder::dummy(tcx.mk_fn_sig(
801-
iter::once(i8p),
800+
[i8p],
802801
tcx.mk_unit(),
803802
false,
804803
hir::Unsafety::Unsafe,
805804
Abi::Rust,
806805
)));
807806
// `unsafe fn(*mut i8, *mut i8) -> ()`
808807
let catch_fn_ty = tcx.mk_fn_ptr(ty::Binder::dummy(tcx.mk_fn_sig(
809-
[i8p, i8p].iter().cloned(),
808+
[i8p, i8p],
810809
tcx.mk_unit(),
811810
false,
812811
hir::Unsafety::Unsafe,
813812
Abi::Rust,
814813
)));
815814
// `unsafe fn(unsafe fn(*mut i8) -> (), *mut i8, unsafe fn(*mut i8, *mut i8) -> ()) -> i32`
816815
let rust_fn_sig = ty::Binder::dummy(cx.tcx.mk_fn_sig(
817-
[try_fn_ty, i8p, catch_fn_ty].into_iter(),
816+
[try_fn_ty, i8p, catch_fn_ty],
818817
tcx.types.i32,
819818
false,
820819
hir::Unsafety::Unsafe,

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/astconv/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16081608
.collect::<SmallVec<[_; 8]>>();
16091609
v.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder()));
16101610
v.dedup();
1611-
let existential_predicates = tcx.mk_poly_existential_predicates(v.into_iter());
1611+
let existential_predicates = tcx.intern_poly_existential_predicates(&v);
16121612

16131613
// Use explicitly-specified region bound.
16141614
let region_bound = if !lifetime.is_elided() {
@@ -3109,7 +3109,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
31093109

31103110
debug!(?output_ty);
31113111

3112-
let fn_ty = tcx.mk_fn_sig(input_tys.into_iter(), output_ty, decl.c_variadic, unsafety, abi);
3112+
let fn_ty = tcx.mk_fn_sig(input_tys, output_ty, decl.c_variadic, unsafety, abi);
31133113
let bare_fn_ty = ty::Binder::bind_with_vars(fn_ty, bound_vars);
31143114

31153115
if !self.allow_ty_infer() && !(visitor.0.is_empty() && infer_replacements.is_empty()) {

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ pub(super) fn check_type_bounds<'tcx>(
19361936
.into()
19371937
}
19381938
});
1939-
let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.into_iter());
1939+
let bound_vars = tcx.intern_bound_variable_kinds(&bound_vars);
19401940
let impl_ty_substs = tcx.intern_substs(&substs);
19411941
let container_id = impl_ty.container_id(tcx);
19421942

0 commit comments

Comments
 (0)