Skip to content

Commit 107f14d

Browse files
committed
Replace more mk_foo calls with infer_foo.
1 parent 2017aef commit 107f14d

File tree

9 files changed

+18
-24
lines changed

9 files changed

+18
-24
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-1
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() {

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+1-1
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

compiler/rustc_hir_analysis/src/check/intrinsic.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,10 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
137137
let intrinsic_name = tcx.item_name(intrinsic_id);
138138
let name_str = intrinsic_name.as_str();
139139

140-
let bound_vars = tcx.mk_bound_variable_kinds(
141-
[
142-
ty::BoundVariableKind::Region(ty::BrAnon(0, None)),
143-
ty::BoundVariableKind::Region(ty::BrEnv),
144-
]
145-
.iter()
146-
.copied(),
147-
);
140+
let bound_vars = tcx.intern_bound_variable_kinds(&[
141+
ty::BoundVariableKind::Region(ty::BrAnon(0, None)),
142+
ty::BoundVariableKind::Region(ty::BrEnv),
143+
]);
148144
let mk_va_list_ty = |mutbl| {
149145
tcx.lang_items().va_list().map(|did| {
150146
let region = tcx.mk_re_late_bound(

compiler/rustc_hir_typeck/src/generator_interior/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ pub fn resolve_interior<'a, 'tcx>(
312312

313313
// Extract type components to build the witness type.
314314
let type_list = fcx.tcx.mk_type_list(type_causes.iter().map(|cause| cause.ty));
315-
let bound_vars = fcx.tcx.mk_bound_variable_kinds(bound_vars.into_iter());
315+
let bound_vars = fcx.tcx.intern_bound_variable_kinds(&bound_vars);
316316
let witness =
317317
fcx.tcx.mk_generator_witness(ty::Binder::bind_with_vars(type_list, bound_vars.clone()));
318318

compiler/rustc_middle/src/ty/context.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2399,13 +2399,13 @@ impl<'tcx> TyCtxt<'tcx> {
23992399
}
24002400

24012401
pub fn late_bound_vars(self, id: HirId) -> &'tcx List<ty::BoundVariableKind> {
2402-
self.mk_bound_variable_kinds(
2403-
self.late_bound_vars_map(id.owner)
2402+
self.intern_bound_variable_kinds(
2403+
&self
2404+
.late_bound_vars_map(id.owner)
24042405
.and_then(|map| map.get(&id.local_id).cloned())
24052406
.unwrap_or_else(|| {
24062407
bug!("No bound vars found for {}", self.hir().node_to_string(id))
2407-
})
2408-
.into_iter(),
2408+
}),
24092409
)
24102410
}
24112411

compiler/rustc_mir_build/src/thir/cx/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ impl<'tcx> Cx<'tcx> {
133133
bug!("closure expr does not have closure type: {:?}", closure_ty);
134134
};
135135

136-
let bound_vars = self.tcx.mk_bound_variable_kinds(std::iter::once(
137-
ty::BoundVariableKind::Region(ty::BrEnv),
138-
));
136+
let bound_vars = self
137+
.tcx
138+
.intern_bound_variable_kinds(&[ty::BoundVariableKind::Region(ty::BrEnv)]);
139139
let br = ty::BoundRegion {
140140
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
141141
kind: ty::BrEnv,

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -564,10 +564,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
564564
.into()
565565
}
566566
});
567-
let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.into_iter());
567+
let bound_vars = tcx.intern_bound_variable_kinds(&bound_vars);
568568
let assoc_ty_substs = tcx.intern_substs(&substs);
569569

570-
let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.into_iter());
570+
let bound_vars = tcx.intern_bound_variable_kinds(&bound_vars);
571571
let bound =
572572
bound.map_bound(|b| b.kind().skip_binder()).subst(tcx, assoc_ty_substs);
573573
tcx.mk_predicate(ty::Binder::bind_with_vars(bound, bound_vars))

src/tools/clippy/clippy_lints/src/redundant_slicing.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ use rustc_middle::ty::adjustment::{Adjust, AutoBorrow, AutoBorrowMutability};
1111
use rustc_middle::ty::subst::GenericArg;
1212
use rustc_session::{declare_lint_pass, declare_tool_lint};
1313

14-
use std::iter;
15-
1614
declare_clippy_lint! {
1715
/// ### What it does
1816
/// Checks for redundant slicing expressions which use the full range, and
@@ -136,7 +134,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing {
136134
} else if let Some(target_id) = cx.tcx.lang_items().deref_target() {
137135
if let Ok(deref_ty) = cx.tcx.try_normalize_erasing_regions(
138136
cx.param_env,
139-
cx.tcx.mk_projection(target_id, cx.tcx.mk_substs(iter::once(GenericArg::from(indexed_ty)))),
137+
cx.tcx.mk_projection(target_id, cx.tcx.intern_substs(&[GenericArg::from(indexed_ty)])),
140138
) {
141139
if deref_ty == expr_ty {
142140
let snip = snippet_with_context(cx, indexed.span, ctxt, "..", &mut app).0;

src/tools/miri/src/eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
363363
tcx,
364364
ty::ParamEnv::reveal_all(),
365365
start_id,
366-
tcx.mk_substs(::std::iter::once(ty::subst::GenericArg::from(main_ret_ty))),
366+
tcx.intern_substs(&[ty::subst::GenericArg::from(main_ret_ty)]),
367367
)
368368
.unwrap()
369369
.unwrap();

0 commit comments

Comments
 (0)