Skip to content

Commit

Permalink
Replace more mk_foo calls with infer_foo.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Feb 17, 2023
1 parent 2017aef commit 107f14d
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.collect::<SmallVec<[_; 8]>>();
v.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder()));
v.dedup();
let existential_predicates = tcx.mk_poly_existential_predicates(v.into_iter());
let existential_predicates = tcx.intern_poly_existential_predicates(&v);

// Use explicitly-specified region bound.
let region_bound = if !lifetime.is_elided() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@ pub(super) fn check_type_bounds<'tcx>(
.into()
}
});
let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.into_iter());
let bound_vars = tcx.intern_bound_variable_kinds(&bound_vars);
let impl_ty_substs = tcx.intern_substs(&substs);
let container_id = impl_ty.container_id(tcx);

Expand Down
12 changes: 4 additions & 8 deletions compiler/rustc_hir_analysis/src/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,10 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
let intrinsic_name = tcx.item_name(intrinsic_id);
let name_str = intrinsic_name.as_str();

let bound_vars = tcx.mk_bound_variable_kinds(
[
ty::BoundVariableKind::Region(ty::BrAnon(0, None)),
ty::BoundVariableKind::Region(ty::BrEnv),
]
.iter()
.copied(),
);
let bound_vars = tcx.intern_bound_variable_kinds(&[
ty::BoundVariableKind::Region(ty::BrAnon(0, None)),
ty::BoundVariableKind::Region(ty::BrEnv),
]);
let mk_va_list_ty = |mutbl| {
tcx.lang_items().va_list().map(|did| {
let region = tcx.mk_re_late_bound(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/generator_interior/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ pub fn resolve_interior<'a, 'tcx>(

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

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2399,13 +2399,13 @@ impl<'tcx> TyCtxt<'tcx> {
}

pub fn late_bound_vars(self, id: HirId) -> &'tcx List<ty::BoundVariableKind> {
self.mk_bound_variable_kinds(
self.late_bound_vars_map(id.owner)
self.intern_bound_variable_kinds(
&self
.late_bound_vars_map(id.owner)
.and_then(|map| map.get(&id.local_id).cloned())
.unwrap_or_else(|| {
bug!("No bound vars found for {}", self.hir().node_to_string(id))
})
.into_iter(),
}),
)
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_build/src/thir/cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ impl<'tcx> Cx<'tcx> {
bug!("closure expr does not have closure type: {:?}", closure_ty);
};

let bound_vars = self.tcx.mk_bound_variable_kinds(std::iter::once(
ty::BoundVariableKind::Region(ty::BrEnv),
));
let bound_vars = self
.tcx
.intern_bound_variable_kinds(&[ty::BoundVariableKind::Region(ty::BrEnv)]);
let br = ty::BoundRegion {
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
kind: ty::BrEnv,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.into()
}
});
let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.into_iter());
let bound_vars = tcx.intern_bound_variable_kinds(&bound_vars);
let assoc_ty_substs = tcx.intern_substs(&substs);

let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.into_iter());
let bound_vars = tcx.intern_bound_variable_kinds(&bound_vars);
let bound =
bound.map_bound(|b| b.kind().skip_binder()).subst(tcx, assoc_ty_substs);
tcx.mk_predicate(ty::Binder::bind_with_vars(bound, bound_vars))
Expand Down
4 changes: 1 addition & 3 deletions src/tools/clippy/clippy_lints/src/redundant_slicing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use rustc_middle::ty::adjustment::{Adjust, AutoBorrow, AutoBorrowMutability};
use rustc_middle::ty::subst::GenericArg;
use rustc_session::{declare_lint_pass, declare_tool_lint};

use std::iter;

declare_clippy_lint! {
/// ### What it does
/// Checks for redundant slicing expressions which use the full range, and
Expand Down Expand Up @@ -136,7 +134,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing {
} else if let Some(target_id) = cx.tcx.lang_items().deref_target() {
if let Ok(deref_ty) = cx.tcx.try_normalize_erasing_regions(
cx.param_env,
cx.tcx.mk_projection(target_id, cx.tcx.mk_substs(iter::once(GenericArg::from(indexed_ty)))),
cx.tcx.mk_projection(target_id, cx.tcx.intern_substs(&[GenericArg::from(indexed_ty)])),
) {
if deref_ty == expr_ty {
let snip = snippet_with_context(cx, indexed.span, ctxt, "..", &mut app).0;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
tcx,
ty::ParamEnv::reveal_all(),
start_id,
tcx.mk_substs(::std::iter::once(ty::subst::GenericArg::from(main_ret_ty))),
tcx.intern_substs(&[ty::subst::GenericArg::from(main_ret_ty)]),
)
.unwrap()
.unwrap();
Expand Down

0 comments on commit 107f14d

Please sign in to comment.