1
Fork 0

Replace more mk_foo calls with infer_foo.

This commit is contained in:
Nicholas Nethercote 2023-02-16 16:27:05 +11:00
parent 2017aeff88
commit 107f14d2ca
9 changed files with 18 additions and 24 deletions

View file

@ -1608,7 +1608,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.collect::<SmallVec<[_; 8]>>(); .collect::<SmallVec<[_; 8]>>();
v.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder())); v.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder()));
v.dedup(); 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. // Use explicitly-specified region bound.
let region_bound = if !lifetime.is_elided() { let region_bound = if !lifetime.is_elided() {

View file

@ -1936,7 +1936,7 @@ pub(super) fn check_type_bounds<'tcx>(
.into() .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 impl_ty_substs = tcx.intern_substs(&substs);
let container_id = impl_ty.container_id(tcx); let container_id = impl_ty.container_id(tcx);

View file

@ -137,14 +137,10 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
let intrinsic_name = tcx.item_name(intrinsic_id); let intrinsic_name = tcx.item_name(intrinsic_id);
let name_str = intrinsic_name.as_str(); let name_str = intrinsic_name.as_str();
let bound_vars = tcx.mk_bound_variable_kinds( let bound_vars = tcx.intern_bound_variable_kinds(&[
[
ty::BoundVariableKind::Region(ty::BrAnon(0, None)), ty::BoundVariableKind::Region(ty::BrAnon(0, None)),
ty::BoundVariableKind::Region(ty::BrEnv), ty::BoundVariableKind::Region(ty::BrEnv),
] ]);
.iter()
.copied(),
);
let mk_va_list_ty = |mutbl| { let mk_va_list_ty = |mutbl| {
tcx.lang_items().va_list().map(|did| { tcx.lang_items().va_list().map(|did| {
let region = tcx.mk_re_late_bound( let region = tcx.mk_re_late_bound(

View file

@ -312,7 +312,7 @@ pub fn resolve_interior<'a, 'tcx>(
// Extract type components to build the witness type. // Extract type components to build the witness type.
let type_list = fcx.tcx.mk_type_list(type_causes.iter().map(|cause| cause.ty)); 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 = let witness =
fcx.tcx.mk_generator_witness(ty::Binder::bind_with_vars(type_list, bound_vars.clone())); fcx.tcx.mk_generator_witness(ty::Binder::bind_with_vars(type_list, bound_vars.clone()));

View file

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

View file

@ -133,9 +133,9 @@ impl<'tcx> Cx<'tcx> {
bug!("closure expr does not have closure type: {:?}", closure_ty); bug!("closure expr does not have closure type: {:?}", closure_ty);
}; };
let bound_vars = self.tcx.mk_bound_variable_kinds(std::iter::once( let bound_vars = self
ty::BoundVariableKind::Region(ty::BrEnv), .tcx
)); .intern_bound_variable_kinds(&[ty::BoundVariableKind::Region(ty::BrEnv)]);
let br = ty::BoundRegion { let br = ty::BoundRegion {
var: ty::BoundVar::from_usize(bound_vars.len() - 1), var: ty::BoundVar::from_usize(bound_vars.len() - 1),
kind: ty::BrEnv, kind: ty::BrEnv,

View file

@ -564,10 +564,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.into() .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 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 = let bound =
bound.map_bound(|b| b.kind().skip_binder()).subst(tcx, assoc_ty_substs); bound.map_bound(|b| b.kind().skip_binder()).subst(tcx, assoc_ty_substs);
tcx.mk_predicate(ty::Binder::bind_with_vars(bound, bound_vars)) tcx.mk_predicate(ty::Binder::bind_with_vars(bound, bound_vars))

View file

@ -11,8 +11,6 @@ use rustc_middle::ty::adjustment::{Adjust, AutoBorrow, AutoBorrowMutability};
use rustc_middle::ty::subst::GenericArg; use rustc_middle::ty::subst::GenericArg;
use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_session::{declare_lint_pass, declare_tool_lint};
use std::iter;
declare_clippy_lint! { declare_clippy_lint! {
/// ### What it does /// ### What it does
/// Checks for redundant slicing expressions which use the full range, and /// Checks for redundant slicing expressions which use the full range, and
@ -136,7 +134,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing {
} else if let Some(target_id) = cx.tcx.lang_items().deref_target() { } else if let Some(target_id) = cx.tcx.lang_items().deref_target() {
if let Ok(deref_ty) = cx.tcx.try_normalize_erasing_regions( if let Ok(deref_ty) = cx.tcx.try_normalize_erasing_regions(
cx.param_env, 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 { if deref_ty == expr_ty {
let snip = snippet_with_context(cx, indexed.span, ctxt, "..", &mut app).0; let snip = snippet_with_context(cx, indexed.span, ctxt, "..", &mut app).0;

View file

@ -363,7 +363,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
tcx, tcx,
ty::ParamEnv::reveal_all(), ty::ParamEnv::reveal_all(),
start_id, 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()
.unwrap(); .unwrap();