Auto merge of #108250 - nnethercote:rename-interner-funcs, r=compiler-errors

Rename interner funcs

This PR cleans up some inconsistencies in interner naming.

Best reviewed one commit at a time.

r? `@compiler-errors`
This commit is contained in:
bors 2023-02-25 13:55:26 +00:00
commit dcca6a375b
111 changed files with 448 additions and 469 deletions

View file

@ -1494,7 +1494,7 @@ pub(crate) fn report_borrowed_value_does_not_live_long_enough(
assert!(root_place.projection.is_empty());
let proper_span = self.body.local_decls[root_place.local].source_info.span;
let root_place_projection = self.infcx.tcx.intern_place_elems(root_place.projection);
let root_place_projection = self.infcx.tcx.mk_place_elems(root_place.projection);
if self.access_place_error_reported.contains(&(
Place { local: root_place.local, projection: root_place_projection },

View file

@ -2633,7 +2633,7 @@ fn prove_closure_bounds(
DefKind::InlineConst => substs.as_inline_const().parent_substs(),
other => bug!("unexpected item {:?}", other),
};
let parent_substs = tcx.intern_substs(parent_substs);
let parent_substs = tcx.mk_substs(parent_substs);
assert_eq!(typeck_root_substs.len(), parent_substs.len());
if let Err(_) = self.eq_substs(

View file

@ -516,7 +516,7 @@ fn build(self) -> UniversalRegions<'tcx> {
let va_list_ty =
self.infcx.tcx.type_of(va_list_did).subst(self.infcx.tcx, &[region.into()]);
unnormalized_input_tys = self.infcx.tcx.mk_type_list(
unnormalized_input_tys = self.infcx.tcx.mk_type_list_from_iter(
unnormalized_input_tys.iter().copied().chain(iter::once(va_list_ty)),
);
}
@ -656,7 +656,7 @@ fn compute_inputs_and_output(
assert_eq!(self.mir_def.did.to_def_id(), def_id);
let closure_sig = substs.as_closure().sig();
let inputs_and_output = closure_sig.inputs_and_output();
let bound_vars = tcx.mk_bound_variable_kinds(
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
inputs_and_output
.bound_vars()
.iter()
@ -680,7 +680,7 @@ fn compute_inputs_and_output(
};
ty::Binder::bind_with_vars(
tcx.mk_type_list(
tcx.mk_type_list_from_iter(
iter::once(closure_ty).chain(inputs).chain(iter::once(output)),
),
bound_vars,
@ -693,7 +693,7 @@ fn compute_inputs_and_output(
let output = substs.as_generator().return_ty();
let generator_ty = tcx.mk_generator(def_id, substs, movability);
let inputs_and_output =
self.infcx.tcx.intern_type_list(&[generator_ty, resume_ty, output]);
self.infcx.tcx.mk_type_list(&[generator_ty, resume_ty, output]);
ty::Binder::dummy(inputs_and_output)
}
@ -709,13 +709,13 @@ fn compute_inputs_and_output(
assert_eq!(self.mir_def.did.to_def_id(), def_id);
let ty = tcx.type_of(self.mir_def.def_id_for_type_of()).subst_identity();
let ty = indices.fold_to_region_vids(tcx, ty);
ty::Binder::dummy(tcx.intern_type_list(&[ty]))
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
}
DefiningTy::InlineConst(def_id, substs) => {
assert_eq!(self.mir_def.did.to_def_id(), def_id);
let ty = substs.as_inline_const().ty();
ty::Binder::dummy(tcx.intern_type_list(&[ty]))
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
}
}
}

View file

@ -405,9 +405,9 @@ pub(crate) fn codegen_terminator_call<'tcx>(
};
let extra_args = &args[fn_sig.inputs().skip_binder().len()..];
let extra_args = fx
.tcx
.mk_type_list(extra_args.iter().map(|op_arg| fx.monomorphize(op_arg.ty(fx.mir, fx.tcx))));
let extra_args = fx.tcx.mk_type_list_from_iter(
extra_args.iter().map(|op_arg| fx.monomorphize(op_arg.ty(fx.mir, fx.tcx))),
);
let fn_abi = if let Some(instance) = instance {
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(instance, extra_args)
} else {

View file

@ -56,7 +56,7 @@ pub(crate) fn maybe_codegen<'tcx>(
Some(fx.easy_call("__multi3", &[lhs, rhs], val_ty))
}
} else {
let out_ty = fx.tcx.intern_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
let lhs = lhs.load_scalar(fx);
let rhs = rhs.load_scalar(fx);
@ -78,7 +78,7 @@ pub(crate) fn maybe_codegen<'tcx>(
}
BinOp::Add | BinOp::Sub | BinOp::Mul => {
assert!(checked);
let out_ty = fx.tcx.intern_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
let (param_types, args) = if fx.tcx.sess.target.is_like_windows {
let (lhs_ptr, lhs_extra) = lhs.force_stack(fx);

View file

@ -191,7 +191,7 @@ fn llvm_add_sub<'tcx>(
// carry0 | carry1 -> carry or borrow respectively
let cb_out = fx.bcx.ins().bor(cb0, cb1);
let layout = fx.layout_of(fx.tcx.intern_tup(&[fx.tcx.types.u8, fx.tcx.types.u64]));
let layout = fx.layout_of(fx.tcx.mk_tup(&[fx.tcx.types.u8, fx.tcx.types.u64]));
let val = CValue::by_val_pair(cb_out, c, layout);
ret.write_cvalue(fx, val);
}

View file

@ -119,7 +119,7 @@ fn create_entry_fn(
tcx,
ParamEnv::reveal_all(),
report.def_id,
tcx.intern_substs(&[GenericArg::from(main_ret_ty)]),
tcx.mk_substs(&[GenericArg::from(main_ret_ty)]),
)
.unwrap()
.unwrap()
@ -146,7 +146,7 @@ fn create_entry_fn(
tcx,
ParamEnv::reveal_all(),
start_def_id,
tcx.intern_substs(&[main_ret_ty.into()]),
tcx.mk_substs(&[main_ret_ty.into()]),
)
.unwrap()
.unwrap()

View file

@ -289,7 +289,7 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
_ => bug!("binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", bin_op, in_lhs, in_rhs),
};
let out_layout = fx.layout_of(fx.tcx.intern_tup(&[in_lhs.layout().ty, fx.tcx.types.bool]));
let out_layout = fx.layout_of(fx.tcx.mk_tup(&[in_lhs.layout().ty, fx.tcx.types.bool]));
CValue::by_val_pair(res, has_overflow, out_layout)
}

View file

@ -383,7 +383,7 @@ fn eh_personality(&self) -> RValue<'gcc> {
tcx,
ty::ParamEnv::reveal_all(),
def_id,
tcx.intern_substs(&[]),
ty::List::empty(),
)
.unwrap().unwrap(),
),

View file

@ -520,14 +520,9 @@ fn eh_personality(&self) -> &'ll Value {
let tcx = self.tcx;
let llfn = match tcx.lang_items().eh_personality() {
Some(def_id) if !wants_msvc_seh(self.sess()) => self.get_fn_addr(
ty::Instance::resolve(
tcx,
ty::ParamEnv::reveal_all(),
def_id,
tcx.intern_substs(&[]),
)
.unwrap()
.unwrap(),
ty::Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, ty::List::empty())
.unwrap()
.unwrap(),
),
_ => {
let name = if wants_msvc_seh(self.sess()) {

View file

@ -373,7 +373,7 @@ fn upstream_monomorphizations_provider(
ExportedSymbol::Generic(def_id, substs) => (def_id, substs),
ExportedSymbol::DropGlue(ty) => {
if let Some(drop_in_place_fn_def_id) = drop_in_place_fn_def_id {
(drop_in_place_fn_def_id, tcx.intern_substs(&[ty.into()]))
(drop_in_place_fn_def_id, tcx.mk_substs(&[ty.into()]))
} else {
// `drop_in_place` in place does not exist, don't try
// to use it.

View file

@ -476,7 +476,7 @@ fn create_entry_fn<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
cx.tcx(),
ty::ParamEnv::reveal_all(),
start_def_id,
cx.tcx().intern_substs(&[main_ret_ty.into()]),
cx.tcx().mk_substs(&[main_ret_ty.into()]),
)
.unwrap()
.unwrap(),

View file

@ -783,7 +783,7 @@ fn codegen_call_terminator(
};
let extra_args = &args[sig.inputs().skip_binder().len()..];
let extra_args = bx.tcx().mk_type_list(extra_args.iter().map(|op_arg| {
let extra_args = bx.tcx().mk_type_list_from_iter(extra_args.iter().map(|op_arg| {
let op_ty = op_arg.ty(self.mir, bx.tcx());
self.monomorphize(op_ty)
}));
@ -1547,7 +1547,7 @@ fn get_personality_slot(&mut self, bx: &mut Bx) -> PlaceRef<'tcx, Bx::Value> {
slot
} else {
let layout = cx.layout_of(
cx.tcx().intern_tup(&[cx.tcx().mk_mut_ptr(cx.tcx().types.u8), cx.tcx().types.i32]),
cx.tcx().mk_tup(&[cx.tcx().mk_mut_ptr(cx.tcx().types.u8), cx.tcx().types.i32]),
);
let slot = PlaceRef::alloca(bx, layout);
self.personality_slot = Some(slot);

View file

@ -413,7 +413,7 @@ pub fn codegen_rvalue_operand(
lhs.layout.ty,
);
let val_ty = op.ty(bx.tcx(), lhs.layout.ty, rhs.layout.ty);
let operand_ty = bx.tcx().intern_tup(&[val_ty, bx.tcx().types.bool]);
let operand_ty = bx.tcx().mk_tup(&[val_ty, bx.tcx().types.bool]);
OperandRef { val: result, layout: bx.cx().layout_of(operand_ty) }
}

View file

@ -180,7 +180,7 @@ pub(super) fn op_to_const<'tcx>(
(ecx.tcx.global_alloc(alloc_id).unwrap_memory(), offset.bytes())
}
(None, _offset) => (
ecx.tcx.intern_const_alloc(Allocation::from_bytes_byte_aligned_immutable(
ecx.tcx.mk_const_alloc(Allocation::from_bytes_byte_aligned_immutable(
b"" as &[u8],
)),
0,

View file

@ -135,7 +135,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval:
};
// link the alloc id to the actual allocation
leftover_allocations.extend(alloc.provenance().ptrs().iter().map(|&(_, alloc_id)| alloc_id));
let alloc = tcx.intern_const_alloc(alloc);
let alloc = tcx.mk_const_alloc(alloc);
tcx.set_alloc_id_memory(alloc_id, alloc);
None
}
@ -437,7 +437,7 @@ pub fn intern_const_alloc_recursive<
alloc.mutability = Mutability::Not;
}
}
let alloc = tcx.intern_const_alloc(alloc);
let alloc = tcx.mk_const_alloc(alloc);
tcx.set_alloc_id_memory(alloc_id, alloc);
for &(_, alloc_id) in alloc.inner().provenance().ptrs().iter() {
if leftover_allocations.insert(alloc_id) {
@ -479,6 +479,6 @@ pub fn intern_with_temp_alloc(
f(self, &dest.into())?;
let mut alloc = self.memory.alloc_map.remove(&dest.ptr.provenance.unwrap()).unwrap().1;
alloc.mutability = Mutability::Not;
Ok(self.tcx.intern_const_alloc(alloc))
Ok(self.tcx.mk_const_alloc(alloc))
}
}

View file

@ -45,7 +45,7 @@ fn numeric_intrinsic<Prov>(name: Symbol, bits: u128, kind: Primitive) -> Scalar<
pub(crate) fn alloc_type_name<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ConstAllocation<'tcx> {
let path = crate::util::type_name(tcx, ty);
let alloc = Allocation::from_bytes_byte_aligned_immutable(path.into_bytes());
tcx.intern_const_alloc(alloc)
tcx.mk_const_alloc(alloc)
}
/// The logic for all nullary intrinsics is implemented here. These intrinsics don't get evaluated

View file

@ -96,7 +96,7 @@ pub(crate) fn alloc_caller_location(
let loc_ty = self
.tcx
.type_of(self.tcx.require_lang_item(LangItem::PanicLocation, None))
.subst(*self.tcx, self.tcx.intern_substs(&[self.tcx.lifetimes.re_erased.into()]));
.subst(*self.tcx, self.tcx.mk_substs(&[self.tcx.lifetimes.re_erased.into()]));
let loc_layout = self.layout_of(loc_ty).unwrap();
let location = self.allocate(loc_layout, MemoryKind::CallerLocation).unwrap();

View file

@ -19,7 +19,7 @@ pub fn binop_with_overflow(
) -> InterpResult<'tcx> {
let (val, overflowed, ty) = self.overflowing_binary_op(op, &left, &right)?;
debug_assert_eq!(
self.tcx.intern_tup(&[ty, self.tcx.types.bool]),
self.tcx.mk_tup(&[ty, self.tcx.types.bool]),
dest.layout.ty,
"type mismatch for result of {:?}",
op,

View file

@ -73,7 +73,8 @@ pub(super) fn eval_terminator(
let fn_sig =
self.tcx.normalize_erasing_late_bound_regions(self.param_env, fn_sig_binder);
let extra_args = &args[fn_sig.inputs().len()..];
let extra_args = self.tcx.mk_type_list(extra_args.iter().map(|arg| arg.layout.ty));
let extra_args =
self.tcx.mk_type_list_from_iter(extra_args.iter().map(|arg| arg.layout.ty));
let (fn_val, fn_abi, with_caller_location) = match *func.layout.ty.kind() {
ty::FnPtr(_sig) => {

View file

@ -866,7 +866,7 @@ fn promote_candidate(mut self, candidate: Candidate, next_promoted_id: usize) ->
let mut projection = vec![PlaceElem::Deref];
projection.extend(place.projection);
place.projection = tcx.intern_place_elems(&projection);
place.projection = tcx.mk_place_elems(&projection);
// Create a temp to hold the promoted reference.
// This is because `*r` requires `r` to be a local,

View file

@ -315,7 +315,7 @@ fn visit_projection_elem(
}
}
ProjectionElem::Field(f, ty) => {
let parent = Place { local, projection: self.tcx.intern_place_elems(proj_base) };
let parent = Place { local, projection: self.tcx.mk_place_elems(proj_base) };
let parent_ty = parent.ty(&self.body.local_decls, self.tcx);
let fail_out_of_bounds = |this: &Self, location| {
this.fail(location, format!("Out of bounds field {:?} for {:?}", f, parent_ty));

View file

@ -377,7 +377,7 @@ pub(crate) fn complain_about_inherent_assoc_type_not_found(
// `<Foo as Iterator>::Item = String`.
let projection_ty = pred.skip_binder().projection_ty;
let substs_with_infer_self = tcx.mk_substs(
let substs_with_infer_self = tcx.mk_substs_from_iter(
std::iter::once(tcx.mk_ty_var(ty::TyVid::from_u32(0)).into())
.chain(projection_ty.substs.iter().skip(1)),
);

View file

@ -370,7 +370,7 @@ pub fn create_substs_for_generic_args<'tcx, 'a>(
}
}
tcx.intern_substs(&substs)
tcx.mk_substs(&substs)
}
/// Checks that the correct number of generic arguments have been provided.

View file

@ -381,7 +381,7 @@ fn create_substs_for_ast_path<'a>(
// here and so associated type bindings will be handled regardless of whether there are any
// non-`Self` generic parameters.
if generics.params.is_empty() {
return (tcx.intern_substs(parent_substs), arg_count);
return (tcx.mk_substs(parent_substs), arg_count);
}
struct SubstsForAstPathCtxt<'a, 'tcx> {
@ -1529,7 +1529,7 @@ trait here instead: `trait NewTrait: {} {{}}`",
arg
})
.collect();
let substs = tcx.intern_substs(&substs[..]);
let substs = tcx.mk_substs(&substs);
let span = i.bottom().1;
let empty_generic_args = hir_trait_bounds.iter().any(|hir_bound| {
@ -1591,7 +1591,7 @@ trait here instead: `trait NewTrait: {} {{}}`",
arg
})
.collect();
b.projection_ty.substs = tcx.intern_substs(&substs[..]);
b.projection_ty.substs = tcx.mk_substs(&substs);
}
ty::ExistentialProjection::erase_self_ty(tcx, b)
@ -1613,7 +1613,7 @@ trait here instead: `trait NewTrait: {} {{}}`",
.collect::<SmallVec<[_; 8]>>();
v.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder()));
v.dedup();
let existential_predicates = tcx.intern_poly_existential_predicates(&v);
let existential_predicates = tcx.mk_poly_existential_predicates(&v);
// Use explicitly-specified region bound.
let region_bound = if !lifetime.is_elided() {
@ -2810,7 +2810,7 @@ pub fn res_to_ty(
var: ty::BoundVar::from_u32(index),
kind: ty::BoundTyKind::Param(def_id, name),
};
tcx.mk_ty(ty::Bound(debruijn, br))
tcx.mk_bound(debruijn, br)
}
Some(rbv::ResolvedArg::EarlyBound(_)) => {
let def_id = def_id.expect_local();
@ -3020,7 +3020,9 @@ fn ast_ty_to_ty_inner(&self, ast_ty: &hir::Ty<'_>, borrowed: bool, in_path: bool
tcx.mk_ref(r, ty::TypeAndMut { ty: t, mutbl: mt.mutbl })
}
hir::TyKind::Never => tcx.types.never,
hir::TyKind::Tup(fields) => tcx.mk_tup(fields.iter().map(|t| self.ast_ty_to_ty(t))),
hir::TyKind::Tup(fields) => {
tcx.mk_tup_from_iter(fields.iter().map(|t| self.ast_ty_to_ty(t)))
}
hir::TyKind::BareFn(bf) => {
require_c_abi_if_c_variadic(tcx, bf.decl, bf.abi, ast_ty.span);

View file

@ -196,7 +196,7 @@ fn compare_method_predicate_entailment<'tcx>(
// the new hybrid bounds we computed.
let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_def_id);
let param_env = ty::ParamEnv::new(
tcx.intern_predicates(&hybrid_preds.predicates),
tcx.mk_predicates(&hybrid_preds.predicates),
Reveal::UserFacing,
hir::Constness::NotConst,
);
@ -1795,7 +1795,7 @@ fn compare_type_predicate_entailment<'tcx>(
let impl_ty_span = tcx.def_span(impl_ty_def_id);
let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_def_id);
let param_env = ty::ParamEnv::new(
tcx.intern_predicates(&hybrid_preds.predicates),
tcx.mk_predicates(&hybrid_preds.predicates),
Reveal::UserFacing,
hir::Constness::NotConst,
);
@ -1937,8 +1937,8 @@ pub(super) fn check_type_bounds<'tcx>(
.into()
}
});
let bound_vars = tcx.intern_bound_variable_kinds(&bound_vars);
let impl_ty_substs = tcx.intern_substs(&substs);
let bound_vars = tcx.mk_bound_variable_kinds(&bound_vars);
let impl_ty_substs = tcx.mk_substs(&substs);
let container_id = impl_ty.container_id(tcx);
let rebased_substs = impl_ty_substs.rebase_onto(tcx, container_id, impl_trait_ref.substs);
@ -1978,11 +1978,7 @@ pub(super) fn check_type_bounds<'tcx>(
.to_predicate(tcx),
),
};
ty::ParamEnv::new(
tcx.intern_predicates(&predicates),
Reveal::UserFacing,
param_env.constness(),
)
ty::ParamEnv::new(tcx.mk_predicates(&predicates), Reveal::UserFacing, param_env.constness())
};
debug!(?normalize_param_env);

View file

@ -137,7 +137,7 @@ 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.intern_bound_variable_kinds(&[
let bound_vars = tcx.mk_bound_variable_kinds(&[
ty::BoundVariableKind::Region(ty::BrAnon(0, None)),
ty::BoundVariableKind::Region(ty::BrEnv),
]);
@ -165,7 +165,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
"cxchg" | "cxchgweak" => (
1,
vec![tcx.mk_mut_ptr(param(0)), param(0), param(0)],
tcx.intern_tup(&[param(0), tcx.types.bool]),
tcx.mk_tup(&[param(0), tcx.types.bool]),
),
"load" => (1, vec![tcx.mk_imm_ptr(param(0))], param(0)),
"store" => (1, vec![tcx.mk_mut_ptr(param(0)), param(0)], tcx.mk_unit()),
@ -317,7 +317,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
| sym::bitreverse => (1, vec![param(0)], param(0)),
sym::add_with_overflow | sym::sub_with_overflow | sym::mul_with_overflow => {
(1, vec![param(0), param(0)], tcx.intern_tup(&[param(0), tcx.types.bool]))
(1, vec![param(0), param(0)], tcx.mk_tup(&[param(0), tcx.types.bool]))
}
sym::ptr_guaranteed_cmp => {
@ -372,7 +372,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
(
1,
vec![tcx.mk_imm_ref(tcx.mk_re_late_bound(ty::INNERMOST, br), param(0))],
tcx.mk_projection(discriminant_def_id, tcx.intern_substs(&[param(0).into()])),
tcx.mk_projection(discriminant_def_id, tcx.mk_substs(&[param(0).into()])),
)
}

View file

@ -493,8 +493,9 @@ fn augment_param_env<'tcx>(
return param_env;
}
let bounds =
tcx.mk_predicates(param_env.caller_bounds().iter().chain(new_predicates.iter().cloned()));
let bounds = tcx.mk_predicates_from_iter(
param_env.caller_bounds().iter().chain(new_predicates.iter().cloned()),
);
// FIXME(compiler-errors): Perhaps there is a case where we need to normalize this
// i.e. traits::normalize_param_env_or_error
ty::ParamEnv::new(bounds, param_env.reveal(), param_env.constness())
@ -1476,7 +1477,7 @@ fn check_fn_or_method<'tcx>(
|idx| hir_decl.inputs.get(idx).map_or(hir_decl.output.span(), |arg: &hir::Ty<'_>| arg.span);
sig.inputs_and_output =
tcx.mk_type_list(sig.inputs_and_output.iter().enumerate().map(|(idx, ty)| {
tcx.mk_type_list_from_iter(sig.inputs_and_output.iter().enumerate().map(|(idx, ty)| {
wfcx.normalize(
arg_span(idx),
Some(WellFormedLoc::Param {

View file

@ -905,7 +905,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AdtDef<'_> {
}
_ => bug!(),
};
tcx.alloc_adt_def(def_id.to_def_id(), kind, variants, repr)
tcx.mk_adt_def(def_id.to_def_id(), kind, variants, repr)
}
fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {

View file

@ -103,7 +103,7 @@ pub(super) fn item_bounds(
tcx: TyCtxt<'_>,
def_id: DefId,
) -> ty::EarlyBinder<&'_ ty::List<ty::Predicate<'_>>> {
let bounds = tcx.mk_predicates(
let bounds = tcx.mk_predicates_from_iter(
util::elaborate_predicates(
tcx,
tcx.explicit_item_bounds(def_id).iter().map(|&(bound, _span)| bound),

View file

@ -232,7 +232,7 @@ fn try_overloaded_call_traits(
let Some(trait_def_id) = opt_trait_def_id else { continue };
let opt_input_type = opt_arg_exprs.map(|arg_exprs| {
self.tcx.mk_tup(arg_exprs.iter().map(|e| {
self.tcx.mk_tup_from_iter(arg_exprs.iter().map(|e| {
self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: e.span,

View file

@ -127,7 +127,7 @@ fn check_closure(
// the `closures` table.
let sig = bound_sig.map_bound(|sig| {
self.tcx.mk_fn_sig(
[self.tcx.intern_tup(sig.inputs())],
[self.tcx.mk_tup(sig.inputs())],
sig.output(),
sig.c_variadic,
sig.unsafety,

View file

@ -1492,7 +1492,7 @@ fn check_expr_tuple(
}
_ => self.check_expr_with_expectation(&e, NoExpectation),
});
let tuple = self.tcx.mk_tup(elt_ts_iter);
let tuple = self.tcx.mk_tup_from_iter(elt_ts_iter);
if let Err(guar) = tuple.error_reported() {
self.tcx.ty_error(guar)
} else {

View file

@ -102,7 +102,7 @@ pub(in super::super) fn check_method_argument_types(
let err_inputs = match tuple_arguments {
DontTupleArguments => err_inputs,
TupleArguments => vec![self.tcx.intern_tup(&err_inputs)],
TupleArguments => vec![self.tcx.mk_tup(&err_inputs)],
};
self.check_argument_types(
@ -642,7 +642,7 @@ fn has_error_or_infer<'tcx>(tys: impl IntoIterator<Item = Ty<'tcx>>) -> bool {
&& provided_arg_tys.len() == formal_and_expected_inputs.len() - 1 + tys.len()
{
// Wrap up the N provided arguments starting at this position in a tuple.
let provided_as_tuple = tcx.mk_tup(
let provided_as_tuple = tcx.mk_tup_from_iter(
provided_arg_tys.iter().map(|(ty, _)| *ty).skip(mismatch_idx).take(tys.len()),
);

View file

@ -311,8 +311,8 @@ 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.intern_bound_variable_kinds(&bound_vars);
let type_list = fcx.tcx.mk_type_list_from_iter(type_causes.iter().map(|cause| cause.ty));
let bound_vars = fcx.tcx.mk_bound_variable_kinds(&bound_vars);
let witness =
fcx.tcx.mk_generator_witness(ty::Binder::bind_with_vars(type_list, bound_vars.clone()));

View file

@ -574,7 +574,7 @@ pub fn report_no_match_method_error(
// `<Foo as Iterator>::Item = String`.
let projection_ty = pred.skip_binder().projection_ty;
let substs_with_infer_self = tcx.mk_substs(
let substs_with_infer_self = tcx.mk_substs_from_iter(
iter::once(tcx.mk_ty_var(ty::TyVid::from_u32(0)).into())
.chain(projection_ty.substs.iter().skip(1)),
);
@ -1252,7 +1252,7 @@ fn suggest_associated_call_syntax(
if let ty::Adt(def, substs) = target_ty.kind() {
// If there are any inferred arguments, (`{integer}`), we should replace
// them with underscores to allow the compiler to infer them
let infer_substs = self.tcx.mk_substs(substs.into_iter().map(|arg| {
let infer_substs = self.tcx.mk_substs_from_iter(substs.into_iter().map(|arg| {
if !arg.is_suggestable(self.tcx, true) {
has_unsuggestable_args = true;
match arg.unpack() {

View file

@ -1302,8 +1302,8 @@ fn check_pat_tuple(
TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span },
)
});
let element_tys = tcx.mk_type_list(element_tys_iter);
let pat_ty = tcx.intern_tup(element_tys);
let element_tys = tcx.mk_type_list_from_iter(element_tys_iter);
let pat_ty = tcx.mk_tup(element_tys);
if let Some(mut err) = self.demand_eqtype_pat_diag(span, expected, pat_ty, ti) {
let reported = err.emit();
// Walk subpatterns with an expected type of `err` in this case to silence
@ -1312,7 +1312,7 @@ fn check_pat_tuple(
for (_, elem) in elements.iter().enumerate_and_adjust(max_len, ddpos) {
self.check_pat(elem, tcx.ty_error(reported), def_bm, ti);
}
tcx.mk_tup(element_tys_iter)
tcx.mk_tup_from_iter(element_tys_iter)
} else {
for (i, elem) in elements.iter().enumerate_and_adjust(max_len, ddpos) {
self.check_pat(elem, element_tys[i], def_bm, ti);

View file

@ -301,7 +301,7 @@ fn analyze_closure(
// Build a tuple (U0..Un) of the final upvar types U0..Un
// and unify the upvar tuple type in the closure with it:
let final_tupled_upvars_type = self.tcx.intern_tup(&final_upvar_tys);
let final_tupled_upvars_type = self.tcx.mk_tup(&final_upvar_tys);
self.demand_suptype(span, substs.tupled_upvars_ty(), final_tupled_upvars_type);
let fake_reads = delegate
@ -315,8 +315,8 @@ fn analyze_closure(
self.typeck_results.borrow_mut().closure_size_eval.insert(
closure_def_id,
ClosureSizeProfileData {
before_feature_tys: self.tcx.intern_tup(&before_feature_tys),
after_feature_tys: self.tcx.intern_tup(&after_feature_tys),
before_feature_tys: self.tcx.mk_tup(&before_feature_tys),
after_feature_tys: self.tcx.mk_tup(&after_feature_tys),
},
);
}

View file

@ -572,7 +572,7 @@ fn canonicalize<V>(
debug_assert!(!out_value.needs_infer() && !out_value.has_placeholders());
let canonical_variables =
tcx.intern_canonical_var_infos(&canonicalizer.universe_canonicalized_variables());
tcx.mk_canonical_var_infos(&canonicalizer.universe_canonicalized_variables());
let max_universe = canonical_variables
.iter()

View file

@ -88,7 +88,7 @@ fn instantiate_canonical_vars(
universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
) -> CanonicalVarValues<'tcx> {
CanonicalVarValues {
var_values: self.tcx.mk_substs(
var_values: self.tcx.mk_substs_from_iter(
variables
.iter()
.map(|info| self.instantiate_canonical_var(span, info, &universe_map)),

View file

@ -474,8 +474,8 @@ fn query_response_substitution_guess<R>(
// given variable in the loop above, use that. Otherwise, use
// a fresh inference variable.
let result_subst = CanonicalVarValues {
var_values: self.tcx.mk_substs(query_response.variables.iter().enumerate().map(
|(index, info)| {
var_values: self.tcx.mk_substs_from_iter(
query_response.variables.iter().enumerate().map(|(index, info)| {
if info.is_existential() {
match opt_values[BoundVar::new(index)] {
Some(k) => k,
@ -488,8 +488,8 @@ fn query_response_substitution_guess<R>(
universe_map[u.as_usize()]
})
}
},
)),
}),
),
};
let mut obligations = vec![];

View file

@ -925,7 +925,7 @@ fn cmp_type_arg(
) -> Option<()> {
// FIXME/HACK: Go back to `SubstsRef` to use its inherent methods,
// ideally that shouldn't be necessary.
let sub = self.tcx.intern_substs(sub);
let sub = self.tcx.mk_substs(sub);
for (i, ta) in sub.types().enumerate() {
if ta == other_ty {
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, other_ty);

View file

@ -677,21 +677,21 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
return;
}
let def = cx.tcx.adt_def(item.owner_id);
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
(def, cx.tcx.mk_adt(def, ty::List::empty()))
}
hir::ItemKind::Union(_, ref ast_generics) => {
if !ast_generics.params.is_empty() {
return;
}
let def = cx.tcx.adt_def(item.owner_id);
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
(def, cx.tcx.mk_adt(def, ty::List::empty()))
}
hir::ItemKind::Enum(_, ref ast_generics) => {
if !ast_generics.params.is_empty() {
return;
}
let def = cx.tcx.adt_def(item.owner_id);
(def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[])))
(def, cx.tcx.mk_adt(def, ty::List::empty()))
}
_ => return,
};

View file

@ -502,7 +502,7 @@ fn i686_arg_list_size(&self, item: &hir::ForeignItemRef) -> usize {
.subst_identity()
.fn_sig(self.tcx)
.inputs()
.map_bound(|slice| self.tcx.intern_type_list(slice)),
.map_bound(|slice| self.tcx.mk_type_list(slice)),
);
argument_types

View file

@ -910,7 +910,7 @@ fn get_adt_def(self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::AdtDef<'tcx> {
std::iter::once(self.get_variant(&kind, item_id, did)).collect()
};
tcx.alloc_adt_def(did, adt_kind, variants, repr)
tcx.mk_adt_def(did, adt_kind, variants, repr)
}
fn get_generics(self, item_id: DefIndex, sess: &Session) -> ty::Generics {

View file

@ -47,7 +47,7 @@ fn try_fold_with<F: ty::FallibleTypeFolder<TyCtxt<'tcx>>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_canonical_var_infos(v))
ty::util::fold_list(self, folder, |tcx, v| tcx.mk_canonical_var_infos(v))
}
}
@ -342,7 +342,7 @@ pub fn make_identity(
infos: CanonicalVarInfos<'tcx>,
) -> CanonicalVarValues<'tcx> {
CanonicalVarValues {
var_values: tcx.mk_substs(infos.iter().enumerate().map(
var_values: tcx.mk_substs_from_iter(infos.iter().enumerate().map(
|(i, info)| -> ty::GenericArg<'tcx> {
match info.kind {
CanonicalVarKind::Ty(_) | CanonicalVarKind::PlaceholderTy(_) => {

View file

@ -1620,7 +1620,7 @@ pub fn project_deeper(self, more_projections: &[PlaceElem<'tcx>], tcx: TyCtxt<'t
&v
};
Place { local: self.local, projection: tcx.intern_place_elems(new_projections) }
Place { local: self.local, projection: tcx.mk_place_elems(new_projections) }
}
}
@ -2530,13 +2530,14 @@ fn from_opt_const_arg_anon_const(
{
InternalSubsts::identity_for_item(tcx, parent_did.to_def_id())
} else {
tcx.intern_substs(&[])
List::empty()
};
debug!(?parent_substs);
let did = def.did.to_def_id();
let child_substs = InternalSubsts::identity_for_item(tcx, did);
let substs = tcx.mk_substs(parent_substs.into_iter().chain(child_substs.into_iter()));
let substs =
tcx.mk_substs_from_iter(parent_substs.into_iter().chain(child_substs.into_iter()));
debug!(?substs);
let hir_id = tcx.hir().local_def_id_to_hir_id(def.did);

View file

@ -194,14 +194,16 @@ pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
let lhs_ty = lhs.ty(local_decls, tcx);
let rhs_ty = rhs.ty(local_decls, tcx);
let ty = op.ty(tcx, lhs_ty, rhs_ty);
tcx.intern_tup(&[ty, tcx.types.bool])
tcx.mk_tup(&[ty, tcx.types.bool])
}
Rvalue::UnaryOp(UnOp::Not | UnOp::Neg, ref operand) => operand.ty(local_decls, tcx),
Rvalue::Discriminant(ref place) => place.ty(local_decls, tcx).ty.discriminant_ty(tcx),
Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, _) => tcx.types.usize,
Rvalue::Aggregate(ref ak, ref ops) => match **ak {
AggregateKind::Array(ty) => tcx.mk_array(ty, ops.len() as u64),
AggregateKind::Tuple => tcx.mk_tup(ops.iter().map(|op| op.ty(local_decls, tcx))),
AggregateKind::Tuple => {
tcx.mk_tup_from_iter(ops.iter().map(|op| op.ty(local_decls, tcx)))
}
AggregateKind::Adt(did, _, substs, _, _) => tcx.type_of(did).subst(tcx, substs),
AggregateKind::Closure(did, substs) => tcx.mk_closure(did, substs),
AggregateKind::Generator(did, substs, movability) => {

View file

@ -53,6 +53,6 @@ fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_place_elems(v))
ty::util::fold_list(self, folder, |tcx, v| tcx.mk_place_elems(v))
}
}

View file

@ -1045,7 +1045,7 @@ fn super_place(
self.visit_local(&mut place.local, context, location);
if let Some(new_projection) = self.process_projection(&place.projection, location) {
place.projection = self.tcx().intern_place_elems(&new_projection);
place.projection = self.tcx().mk_place_elems(&new_projection);
}
}

View file

@ -30,20 +30,18 @@ fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Ok(FallibleTypeFolder::interner(folder).intern_external_constraints(
ExternalConstraintsData {
regions: (),
opaque_types: self
.opaque_types
.iter()
.map(|opaque| opaque.try_fold_with(folder))
.collect::<Result<_, F::Error>>()?,
},
))
Ok(FallibleTypeFolder::interner(folder).mk_external_constraints(ExternalConstraintsData {
regions: (),
opaque_types: self
.opaque_types
.iter()
.map(|opaque| opaque.try_fold_with(folder))
.collect::<Result<_, F::Error>>()?,
}))
}
fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
TypeFolder::interner(folder).intern_external_constraints(ExternalConstraintsData {
TypeFolder::interner(folder).mk_external_constraints(ExternalConstraintsData {
regions: (),
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
})

View file

@ -54,7 +54,7 @@ pub struct AdtFlags: u32 {
/// The definition of a user-defined type, e.g., a `struct`, `enum`, or `union`.
///
/// These are all interned (by `alloc_adt_def`) into the global arena.
/// These are all interned (by `mk_adt_def`) into the global arena.
///
/// The initialism *ADT* stands for an [*algebraic data type (ADT)*][adt].
/// This is slightly wrong because `union`s are not ADTs.

View file

@ -207,7 +207,7 @@ fn decode(decoder: &mut D) -> Ty<'tcx> {
})
} else {
let tcx = decoder.interner();
tcx.mk_ty(rustc_type_ir::TyKind::decode(decoder))
tcx.mk_ty_from_kind(rustc_type_ir::TyKind::decode(decoder))
}
}
}
@ -244,7 +244,7 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for SubstsRef<'tcx> {
fn decode(decoder: &mut D) -> Self {
let len = decoder.read_usize();
let tcx = decoder.interner();
tcx.mk_substs(
tcx.mk_substs_from_iter(
(0..len).map::<ty::subst::GenericArg<'tcx>, _>(|_| Decodable::decode(decoder)),
)
}
@ -254,7 +254,7 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for mir::Place<'tcx> {
fn decode(decoder: &mut D) -> Self {
let local: mir::Local = Decodable::decode(decoder);
let len = decoder.read_usize();
let projection = decoder.interner().mk_place_elems(
let projection = decoder.interner().mk_place_elems_from_iter(
(0..len).map::<mir::PlaceElem<'tcx>, _>(|_| Decodable::decode(decoder)),
);
mir::Place { local, projection }
@ -263,16 +263,16 @@ fn decode(decoder: &mut D) -> Self {
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for ty::Region<'tcx> {
fn decode(decoder: &mut D) -> Self {
decoder.interner().mk_region(Decodable::decode(decoder))
decoder.interner().mk_region_from_kind(Decodable::decode(decoder))
}
}
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for CanonicalVarInfos<'tcx> {
fn decode(decoder: &mut D) -> Self {
let len = decoder.read_usize();
let interned: Vec<CanonicalVarInfo<'tcx>> =
(0..len).map(|_| Decodable::decode(decoder)).collect();
decoder.interner().intern_canonical_var_infos(interned.as_slice())
decoder.interner().mk_canonical_var_infos_from_iter(
(0..len).map::<CanonicalVarInfo<'tcx>, _>(|_| Decodable::decode(decoder)),
)
}
}
@ -310,7 +310,9 @@ fn decode(decoder: &mut D) -> Self {
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<Ty<'tcx>> {
fn decode(decoder: &mut D) -> &'tcx Self {
let len = decoder.read_usize();
decoder.interner().mk_type_list((0..len).map::<Ty<'tcx>, _>(|_| Decodable::decode(decoder)))
decoder
.interner()
.mk_type_list_from_iter((0..len).map::<Ty<'tcx>, _>(|_| Decodable::decode(decoder)))
}
}
@ -319,7 +321,7 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D>
{
fn decode(decoder: &mut D) -> &'tcx Self {
let len = decoder.read_usize();
decoder.interner().mk_poly_existential_predicates(
decoder.interner().mk_poly_existential_predicates_from_iter(
(0..len).map::<ty::Binder<'tcx, _>, _>(|_| Decodable::decode(decoder)),
)
}
@ -342,13 +344,13 @@ fn decode(decoder: &mut D) -> &'tcx Self {
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for ConstAllocation<'tcx> {
fn decode(decoder: &mut D) -> Self {
decoder.interner().intern_const_alloc(Decodable::decode(decoder))
decoder.interner().mk_const_alloc(Decodable::decode(decoder))
}
}
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for AdtDef<'tcx> {
fn decode(decoder: &mut D) -> Self {
decoder.interner().intern_adt_def(Decodable::decode(decoder))
decoder.interner().mk_adt_def_from_data(Decodable::decode(decoder))
}
}
@ -375,7 +377,7 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D>
{
fn decode(decoder: &mut D) -> &'tcx Self {
let len = decoder.read_usize();
decoder.interner().mk_bound_variable_kinds(
decoder.interner().mk_bound_variable_kinds_from_iter(
(0..len).map::<ty::BoundVariableKind, _>(|_| Decodable::decode(decoder)),
)
}
@ -384,18 +386,18 @@ fn decode(decoder: &mut D) -> &'tcx Self {
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<ty::Const<'tcx>> {
fn decode(decoder: &mut D) -> &'tcx Self {
let len = decoder.read_usize();
decoder
.interner()
.mk_const_list((0..len).map::<ty::Const<'tcx>, _>(|_| Decodable::decode(decoder)))
decoder.interner().mk_const_list_from_iter(
(0..len).map::<ty::Const<'tcx>, _>(|_| Decodable::decode(decoder)),
)
}
}
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<ty::Predicate<'tcx>> {
fn decode(decoder: &mut D) -> &'tcx Self {
let len = decoder.read_usize();
let predicates: Vec<_> =
(0..len).map::<ty::Predicate<'tcx>, _>(|_| Decodable::decode(decoder)).collect();
decoder.interner().intern_predicates(&predicates)
decoder.interner().mk_predicates_from_iter(
(0..len).map::<ty::Predicate<'tcx>, _>(|_| Decodable::decode(decoder)),
)
}
}

View file

@ -6,7 +6,7 @@
use crate::arena::Arena;
use crate::dep_graph::{DepGraph, DepKindStruct};
use crate::infer::canonical::{CanonicalVarInfo, CanonicalVarInfos};
use crate::infer::canonical::CanonicalVarInfo;
use crate::lint::struct_lint_level;
use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
use crate::middle::resolve_bound_vars;
@ -177,7 +177,7 @@ fn new(arena: &'tcx WorkerLocal<Arena<'tcx>>) -> CtxtInterners<'tcx> {
}
}
/// Interns a type.
/// Interns a type. (Use `mk_*` functions instead, where possible.)
#[allow(rustc::usage_of_ty_tykind)]
#[inline(never)]
fn intern_ty(&self, kind: TyKind<'tcx>, sess: &Session, untracked: &Untracked) -> Ty<'tcx> {
@ -217,6 +217,7 @@ fn stable_hash<'a, T: HashStable<StableHashingContext<'a>>>(
}
}
/// Interns a predicate. (Use `mk_predicate` instead, where possible.)
#[inline(never)]
fn intern_predicate(
&self,
@ -615,21 +616,21 @@ pub fn alloc_steal_promoted(
self.arena.alloc(Steal::new(promoted))
}
pub fn alloc_adt_def(
pub fn mk_adt_def(
self,
did: DefId,
kind: AdtKind,
variants: IndexVec<VariantIdx, ty::VariantDef>,
repr: ReprOptions,
) -> ty::AdtDef<'tcx> {
self.intern_adt_def(ty::AdtDefData::new(self, did, kind, variants, repr))
self.mk_adt_def_from_data(ty::AdtDefData::new(self, did, kind, variants, repr))
}
/// Allocates a read-only byte or string literal for `mir::interpret`.
pub fn allocate_bytes(self, bytes: &[u8]) -> interpret::AllocId {
// Create an allocation that just contains these bytes.
let alloc = interpret::Allocation::from_bytes_byte_aligned_immutable(bytes);
let alloc = self.intern_const_alloc(alloc);
let alloc = self.mk_const_alloc(alloc);
self.create_memory_alloc(alloc)
}
@ -719,7 +720,7 @@ pub fn create_global_ctxt(
/// Constructs a `TyKind::Error` type with current `ErrorGuaranteed`
#[track_caller]
pub fn ty_error(self, reported: ErrorGuaranteed) -> Ty<'tcx> {
self.mk_ty(Error(reported))
self.mk_ty_from_kind(Error(reported))
}
/// Constructs a `TyKind::Error` type and registers a `delay_span_bug` to ensure it gets used.
@ -733,7 +734,7 @@ pub fn ty_error_misc(self) -> Ty<'tcx> {
#[track_caller]
pub fn ty_error_with_message<S: Into<MultiSpan>>(self, span: S, msg: &str) -> Ty<'tcx> {
let reported = self.sess.delay_span_bug(span, msg);
self.mk_ty(Error(reported))
self.mk_ty_from_kind(Error(reported))
}
/// Constructs a `RegionKind::ReError` lifetime.
@ -1194,7 +1195,7 @@ pub fn caller_location_ty(self) -> Ty<'tcx> {
self.mk_imm_ref(
self.lifetimes.re_static,
self.type_of(self.require_lang_item(LangItem::PanicLocation, None))
.subst(self, self.intern_substs(&[self.lifetimes.re_static.into()])),
.subst(self, self.mk_substs(&[self.lifetimes.re_static.into()])),
)
}
@ -1276,7 +1277,7 @@ fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
// Can't use the macros as we have reuse the `substs` here.
//
// See `intern_type_list` for more info.
// See `mk_type_list` for more info.
impl<'a, 'tcx> Lift<'tcx> for &'a List<Ty<'a>> {
type Lifted = &'tcx List<Ty<'tcx>>;
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
@ -1517,7 +1518,7 @@ fn hash<H: Hasher>(&self, s: &mut H) {
}
macro_rules! direct_interners {
($($name:ident: $method:ident($ty:ty): $ret_ctor:ident -> $ret_ty:ty,)+) => {
($($name:ident: $vis:vis $method:ident($ty:ty): $ret_ctor:ident -> $ret_ty:ty,)+) => {
$(impl<'tcx> Borrow<$ty> for InternedInSet<'tcx, $ty> {
fn borrow<'a>(&'a self) -> &'a $ty {
&self.0
@ -1543,7 +1544,7 @@ fn hash<H: Hasher>(&self, s: &mut H) {
}
impl<'tcx> TyCtxt<'tcx> {
pub fn $method(self, v: $ty) -> $ret_ty {
$vis fn $method(self, v: $ty) -> $ret_ty {
$ret_ctor(Interned::new_unchecked(self.interners.$name.intern(v, |v| {
InternedInSet(self.interners.arena.alloc(v))
}).0))
@ -1552,37 +1553,47 @@ pub fn $method(self, v: $ty) -> $ret_ty {
}
}
// Functions with a `mk_` prefix are intended for use outside this file and
// crate. Functions with an `intern_` prefix are intended for use within this
// file only, and have a corresponding `mk_` function.
direct_interners! {
region: intern_region(RegionKind<'tcx>): Region -> Region<'tcx>,
const_: mk_const_internal(ConstData<'tcx>): Const -> Const<'tcx>,
const_allocation: intern_const_alloc(Allocation): ConstAllocation -> ConstAllocation<'tcx>,
layout: intern_layout(LayoutS): Layout -> Layout<'tcx>,
adt_def: intern_adt_def(AdtDefData): AdtDef -> AdtDef<'tcx>,
external_constraints: intern_external_constraints(ExternalConstraintsData<'tcx>): ExternalConstraints -> ExternalConstraints<'tcx>,
const_: intern_const(ConstData<'tcx>): Const -> Const<'tcx>,
const_allocation: pub mk_const_alloc(Allocation): ConstAllocation -> ConstAllocation<'tcx>,
layout: pub mk_layout(LayoutS): Layout -> Layout<'tcx>,
adt_def: pub mk_adt_def_from_data(AdtDefData): AdtDef -> AdtDef<'tcx>,
external_constraints: pub mk_external_constraints(ExternalConstraintsData<'tcx>):
ExternalConstraints -> ExternalConstraints<'tcx>,
}
macro_rules! slice_interners {
($($field:ident: $method:ident($ty:ty)),+ $(,)?) => (
($($field:ident: $vis:vis $method:ident($ty:ty)),+ $(,)?) => (
impl<'tcx> TyCtxt<'tcx> {
$(pub fn $method(self, v: &[$ty]) -> &'tcx List<$ty> {
self.interners.$field.intern_ref(v, || {
InternedInSet(List::from_arena(&*self.arena, v))
}).0
$($vis fn $method(self, v: &[$ty]) -> &'tcx List<$ty> {
if v.is_empty() {
List::empty()
} else {
self.interners.$field.intern_ref(v, || {
InternedInSet(List::from_arena(&*self.arena, v))
}).0
}
})+
}
);
}
// These functions intern slices. They all have a corresponding
// `mk_foo_from_iter` function that interns an iterator. The slice version
// should be used when possible, because it's faster.
slice_interners!(
const_lists: _intern_const_list(Const<'tcx>),
substs: _intern_substs(GenericArg<'tcx>),
canonical_var_infos: _intern_canonical_var_infos(CanonicalVarInfo<'tcx>),
poly_existential_predicates:
_intern_poly_existential_predicates(PolyExistentialPredicate<'tcx>),
predicates: _intern_predicates(Predicate<'tcx>),
projs: _intern_projs(ProjectionKind),
place_elems: _intern_place_elems(PlaceElem<'tcx>),
bound_variable_kinds: _intern_bound_variable_kinds(ty::BoundVariableKind),
const_lists: pub mk_const_list(Const<'tcx>),
substs: pub mk_substs(GenericArg<'tcx>),
canonical_var_infos: pub mk_canonical_var_infos(CanonicalVarInfo<'tcx>),
poly_existential_predicates: intern_poly_existential_predicates(PolyExistentialPredicate<'tcx>),
predicates: intern_predicates(Predicate<'tcx>),
projs: pub mk_projs(ProjectionKind),
place_elems: pub mk_place_elems(PlaceElem<'tcx>),
bound_variable_kinds: pub mk_bound_variable_kinds(ty::BoundVariableKind),
);
impl<'tcx> TyCtxt<'tcx> {
@ -1670,7 +1681,7 @@ pub fn signature_unclosure(
// Avoid this in favour of more specific `mk_*` methods, where possible.
#[allow(rustc::usage_of_ty_tykind)]
#[inline]
pub fn mk_ty(self, st: TyKind<'tcx>) -> Ty<'tcx> {
pub fn mk_ty_from_kind(self, st: TyKind<'tcx>) -> Ty<'tcx> {
self.interners.intern_ty(
st,
self.sess,
@ -1735,12 +1746,12 @@ pub fn mk_static_str(self) -> Ty<'tcx> {
#[inline]
pub fn mk_adt(self, def: AdtDef<'tcx>, substs: SubstsRef<'tcx>) -> Ty<'tcx> {
// Take a copy of substs so that we own the vectors inside.
self.mk_ty(Adt(def, substs))
self.mk_ty_from_kind(Adt(def, substs))
}
#[inline]
pub fn mk_foreign(self, def_id: DefId) -> Ty<'tcx> {
self.mk_ty(Foreign(def_id))
self.mk_ty_from_kind(Foreign(def_id))
}
fn mk_generic_adt(self, wrapper_def_id: DefId, ty_param: Ty<'tcx>) -> Ty<'tcx> {
@ -1757,7 +1768,7 @@ fn mk_generic_adt(self, wrapper_def_id: DefId, ty_param: Ty<'tcx>) -> Ty<'tcx> {
}
}
});
self.mk_ty(Adt(adt_def, substs))
self.mk_ty_from_kind(Adt(adt_def, substs))
}
#[inline]
@ -1786,12 +1797,12 @@ pub fn mk_maybe_uninit(self, ty: Ty<'tcx>) -> Ty<'tcx> {
#[inline]
pub fn mk_ptr(self, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
self.mk_ty(RawPtr(tm))
self.mk_ty_from_kind(RawPtr(tm))
}
#[inline]
pub fn mk_ref(self, r: Region<'tcx>, tm: TypeAndMut<'tcx>) -> Ty<'tcx> {
self.mk_ty(Ref(r, tm.ty, tm.mutbl))
self.mk_ty_from_kind(Ref(r, tm.ty, tm.mutbl))
}
#[inline]
@ -1816,30 +1827,34 @@ pub fn mk_imm_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx> {
#[inline]
pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> {
self.mk_ty(Array(ty, ty::Const::from_target_usize(self, n)))
self.mk_ty_from_kind(Array(ty, ty::Const::from_target_usize(self, n)))
}
#[inline]
pub fn mk_array_with_const_len(self, ty: Ty<'tcx>, ct: Const<'tcx>) -> Ty<'tcx> {
self.mk_ty(Array(ty, ct))
self.mk_ty_from_kind(Array(ty, ct))
}
#[inline]
pub fn mk_slice(self, ty: Ty<'tcx>) -> Ty<'tcx> {
self.mk_ty(Slice(ty))
self.mk_ty_from_kind(Slice(ty))
}
#[inline]
pub fn intern_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx> {
if ts.is_empty() { self.types.unit } else { self.mk_ty(Tuple(self.intern_type_list(&ts))) }
pub fn mk_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx> {
if ts.is_empty() {
self.types.unit
} else {
self.mk_ty_from_kind(Tuple(self.mk_type_list(&ts)))
}
}
pub fn mk_tup<I, T>(self, iter: I) -> T::Output
pub fn mk_tup_from_iter<I, T>(self, iter: I) -> T::Output
where
I: Iterator<Item = T>,
T: CollectAndApply<Ty<'tcx>, Ty<'tcx>>,
{
T::collect_and_apply(iter, |ts| self.intern_tup(ts))
T::collect_and_apply(iter, |ts| self.mk_tup(ts))
}
#[inline]
@ -1858,12 +1873,12 @@ pub fn mk_fn_def(
def_id: DefId,
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
) -> Ty<'tcx> {
let substs = self.check_substs(def_id, substs);
self.mk_ty(FnDef(def_id, substs))
let substs = self.check_and_mk_substs(def_id, substs);
self.mk_ty_from_kind(FnDef(def_id, substs))
}
#[inline(always)]
fn check_substs(
fn check_and_mk_substs(
self,
_def_id: DefId,
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
@ -1879,12 +1894,12 @@ fn check_substs(
substs.collect::<Vec<_>>(),
);
}
self.mk_substs(substs)
self.mk_substs_from_iter(substs)
}
#[inline]
pub fn mk_fn_ptr(self, fty: PolyFnSig<'tcx>) -> Ty<'tcx> {
self.mk_ty(FnPtr(fty))
self.mk_ty_from_kind(FnPtr(fty))
}
#[inline]
@ -1894,7 +1909,7 @@ pub fn mk_dynamic(
reg: ty::Region<'tcx>,
repr: DynKind,
) -> Ty<'tcx> {
self.mk_ty(Dynamic(obj, reg, repr))
self.mk_ty_from_kind(Dynamic(obj, reg, repr))
}
#[inline]
@ -1908,7 +1923,7 @@ pub fn mk_projection(
#[inline]
pub fn mk_closure(self, closure_id: DefId, closure_substs: SubstsRef<'tcx>) -> Ty<'tcx> {
self.mk_ty(Closure(closure_id, closure_substs))
self.mk_ty_from_kind(Closure(closure_id, closure_substs))
}
#[inline]
@ -1918,47 +1933,51 @@ pub fn mk_generator(
generator_substs: SubstsRef<'tcx>,
movability: hir::Movability,
) -> Ty<'tcx> {
self.mk_ty(Generator(id, generator_substs, movability))
self.mk_ty_from_kind(Generator(id, generator_substs, movability))
}
#[inline]
pub fn mk_generator_witness(self, types: ty::Binder<'tcx, &'tcx List<Ty<'tcx>>>) -> Ty<'tcx> {
self.mk_ty(GeneratorWitness(types))
self.mk_ty_from_kind(GeneratorWitness(types))
}
/// Creates a `&mut Context<'_>` [`Ty`] with erased lifetimes.
pub fn mk_task_context(self) -> Ty<'tcx> {
let context_did = self.require_lang_item(LangItem::Context, None);
let context_adt_ref = self.adt_def(context_did);
let context_substs = self.intern_substs(&[self.lifetimes.re_erased.into()]);
let context_substs = self.mk_substs(&[self.lifetimes.re_erased.into()]);
let context_ty = self.mk_adt(context_adt_ref, context_substs);
self.mk_mut_ref(self.lifetimes.re_erased, context_ty)
}
#[inline]
pub fn mk_generator_witness_mir(self, id: DefId, substs: SubstsRef<'tcx>) -> Ty<'tcx> {
self.mk_ty(GeneratorWitnessMIR(id, substs))
self.mk_ty_from_kind(GeneratorWitnessMIR(id, substs))
}
#[inline]
pub fn mk_const(self, kind: impl Into<ty::ConstKind<'tcx>>, ty: Ty<'tcx>) -> Const<'tcx> {
self.mk_const_internal(ty::ConstData { kind: kind.into(), ty })
self.intern_const(ty::ConstData { kind: kind.into(), ty })
}
#[inline]
pub fn mk_ty_var(self, v: TyVid) -> Ty<'tcx> {
// Use a pre-interned one when possible.
self.types.ty_vars.get(v.as_usize()).copied().unwrap_or_else(|| self.mk_ty(Infer(TyVar(v))))
self.types
.ty_vars
.get(v.as_usize())
.copied()
.unwrap_or_else(|| self.mk_ty_from_kind(Infer(TyVar(v))))
}
#[inline]
pub fn mk_int_var(self, v: IntVid) -> Ty<'tcx> {
self.mk_ty(Infer(IntVar(v)))
self.mk_ty_from_kind(Infer(IntVar(v)))
}
#[inline]
pub fn mk_float_var(self, v: FloatVid) -> Ty<'tcx> {
self.mk_ty(Infer(FloatVar(v)))
self.mk_ty_from_kind(Infer(FloatVar(v)))
}
#[inline]
@ -1968,7 +1987,7 @@ pub fn mk_fresh_ty(self, n: u32) -> Ty<'tcx> {
.fresh_tys
.get(n as usize)
.copied()
.unwrap_or_else(|| self.mk_ty(Infer(ty::FreshTy(n))))
.unwrap_or_else(|| self.mk_ty_from_kind(Infer(ty::FreshTy(n))))
}
#[inline]
@ -1978,7 +1997,7 @@ pub fn mk_fresh_int_ty(self, n: u32) -> Ty<'tcx> {
.fresh_int_tys
.get(n as usize)
.copied()
.unwrap_or_else(|| self.mk_ty(Infer(ty::FreshIntTy(n))))
.unwrap_or_else(|| self.mk_ty_from_kind(Infer(ty::FreshIntTy(n))))
}
#[inline]
@ -1988,12 +2007,12 @@ pub fn mk_fresh_float_ty(self, n: u32) -> Ty<'tcx> {
.fresh_float_tys
.get(n as usize)
.copied()
.unwrap_or_else(|| self.mk_ty(Infer(ty::FreshFloatTy(n))))
.unwrap_or_else(|| self.mk_ty_from_kind(Infer(ty::FreshFloatTy(n))))
}
#[inline]
pub fn mk_ty_param(self, index: u32, name: Symbol) -> Ty<'tcx> {
self.mk_ty(Param(ParamTy { index, name }))
self.mk_ty_from_kind(Param(ParamTy { index, name }))
}
pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> GenericArg<'tcx> {
@ -2015,17 +2034,17 @@ pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> GenericArg<'tcx>
#[inline]
pub fn mk_bound(self, index: ty::DebruijnIndex, bound_ty: ty::BoundTy) -> Ty<'tcx> {
self.mk_ty(Bound(index, bound_ty))
self.mk_ty_from_kind(Bound(index, bound_ty))
}
#[inline]
pub fn mk_placeholder(self, placeholder: ty::PlaceholderType) -> Ty<'tcx> {
self.mk_ty(Placeholder(placeholder))
self.mk_ty_from_kind(Placeholder(placeholder))
}
#[inline]
pub fn mk_alias(self, kind: ty::AliasKind, alias_ty: ty::AliasTy<'tcx>) -> Ty<'tcx> {
self.mk_ty(Alias(kind, alias_ty))
self.mk_ty_from_kind(Alias(kind, alias_ty))
}
#[inline]
@ -2078,7 +2097,7 @@ pub fn mk_re_placeholder(self, placeholder: ty::PlaceholderRegion) -> Region<'tc
// Avoid this in favour of more specific `mk_re_*` methods, where possible,
// to avoid the cost of the `match`.
pub fn mk_region(self, kind: ty::RegionKind<'tcx>) -> Region<'tcx> {
pub fn mk_region_from_kind(self, kind: ty::RegionKind<'tcx>) -> Region<'tcx> {
match kind {
ty::ReEarlyBound(region) => self.mk_re_early_bound(region),
ty::ReLateBound(debruijn, region) => self.mk_re_late_bound(debruijn, region),
@ -2132,10 +2151,10 @@ pub fn mk_place_elem(self, place: Place<'tcx>, elem: PlaceElem<'tcx>) -> Place<'
let mut projection = place.projection.to_vec();
projection.push(elem);
Place { local: place.local, projection: self.intern_place_elems(&projection) }
Place { local: place.local, projection: self.mk_place_elems(&projection) }
}
pub fn intern_poly_existential_predicates(
pub fn mk_poly_existential_predicates(
self,
eps: &[PolyExistentialPredicate<'tcx>],
) -> &'tcx List<PolyExistentialPredicate<'tcx>> {
@ -2145,80 +2164,40 @@ pub fn intern_poly_existential_predicates(
.all(|[a, b]| a.skip_binder().stable_cmp(self, &b.skip_binder())
!= Ordering::Greater)
);
self._intern_poly_existential_predicates(eps)
self.intern_poly_existential_predicates(eps)
}
pub fn intern_predicates(self, preds: &[Predicate<'tcx>]) -> &'tcx List<Predicate<'tcx>> {
pub fn mk_predicates(self, preds: &[Predicate<'tcx>]) -> &'tcx List<Predicate<'tcx>> {
// FIXME consider asking the input slice to be sorted to avoid
// re-interning permutations, in which case that would be asserted
// here.
if preds.is_empty() {
// The macro-generated method below asserts we don't intern an empty slice.
List::empty()
} else {
self._intern_predicates(preds)
}
self.intern_predicates(preds)
}
pub fn mk_const_list<I, T>(self, iter: I) -> T::Output
pub fn mk_const_list_from_iter<I, T>(self, iter: I) -> T::Output
where
I: Iterator<Item = T>,
T: CollectAndApply<ty::Const<'tcx>, &'tcx List<ty::Const<'tcx>>>,
{
T::collect_and_apply(iter, |xs| self.intern_const_list(xs))
T::collect_and_apply(iter, |xs| self.mk_const_list(xs))
}
pub fn intern_const_list(self, cs: &[ty::Const<'tcx>]) -> &'tcx List<ty::Const<'tcx>> {
if cs.is_empty() { List::empty() } else { self._intern_const_list(cs) }
pub fn mk_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx List<Ty<'tcx>> {
// Actually intern type lists as lists of `GenericArg`s.
//
// Transmuting from `Ty<'tcx>` to `GenericArg<'tcx>` is sound
// as explained in ty_slice_as_generic_arg`. With this,
// we guarantee that even when transmuting between `List<Ty<'tcx>>`
// and `List<GenericArg<'tcx>>`, the uniqueness requirement for
// lists is upheld.
let substs = self.mk_substs(ty::subst::ty_slice_as_generic_args(ts));
substs.try_as_type_list().unwrap()
}
pub fn intern_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx List<Ty<'tcx>> {
if ts.is_empty() {
List::empty()
} else {
// Actually intern type lists as lists of `GenericArg`s.
//
// Transmuting from `Ty<'tcx>` to `GenericArg<'tcx>` is sound
// as explained in ty_slice_as_generic_arg`. With this,
// we guarantee that even when transmuting between `List<Ty<'tcx>>`
// and `List<GenericArg<'tcx>>`, the uniqueness requirement for
// lists is upheld.
let substs = self._intern_substs(ty::subst::ty_slice_as_generic_args(ts));
substs.try_as_type_list().unwrap()
}
}
pub fn intern_substs(self, ts: &[GenericArg<'tcx>]) -> &'tcx List<GenericArg<'tcx>> {
if ts.is_empty() { List::empty() } else { self._intern_substs(ts) }
}
pub fn intern_projs(self, ps: &[ProjectionKind]) -> &'tcx List<ProjectionKind> {
if ps.is_empty() { List::empty() } else { self._intern_projs(ps) }
}
pub fn intern_place_elems(self, ts: &[PlaceElem<'tcx>]) -> &'tcx List<PlaceElem<'tcx>> {
if ts.is_empty() { List::empty() } else { self._intern_place_elems(ts) }
}
pub fn intern_canonical_var_infos(
self,
ts: &[CanonicalVarInfo<'tcx>],
) -> CanonicalVarInfos<'tcx> {
if ts.is_empty() { List::empty() } else { self._intern_canonical_var_infos(ts) }
}
pub fn intern_bound_variable_kinds(
self,
ts: &[ty::BoundVariableKind],
) -> &'tcx List<ty::BoundVariableKind> {
if ts.is_empty() { List::empty() } else { self._intern_bound_variable_kinds(ts) }
}
// Unlike various other `mk_*` functions, this one uses `I: IntoIterator`
// instead of `I: Iterator`. Unlike those other functions, this one doesn't
// have a `intern_fn_sig` variant that can be used for cases where `I` is
// something like a `Vec`. That's because of the need to combine `inputs`
// and `output`.
// Unlike various other `mk_*_from_iter` functions, this one uses `I:
// IntoIterator` instead of `I: Iterator`, and it doesn't have a slice
// variant, because of the need to combine `inputs` and `output`. This
// explains the lack of `_from_iter` suffix.
pub fn mk_fn_sig<I, T>(
self,
inputs: I,
@ -2232,14 +2211,14 @@ pub fn mk_fn_sig<I, T>(
T: CollectAndApply<Ty<'tcx>, ty::FnSig<'tcx>>,
{
T::collect_and_apply(inputs.into_iter().chain(iter::once(output)), |xs| ty::FnSig {
inputs_and_output: self.intern_type_list(xs),
inputs_and_output: self.mk_type_list(xs),
c_variadic,
unsafety,
abi,
})
}
pub fn mk_poly_existential_predicates<I, T>(self, iter: I) -> T::Output
pub fn mk_poly_existential_predicates_from_iter<I, T>(self, iter: I) -> T::Output
where
I: Iterator<Item = T>,
T: CollectAndApply<
@ -2247,39 +2226,47 @@ pub fn mk_poly_existential_predicates<I, T>(self, iter: I) -> T::Output
&'tcx List<PolyExistentialPredicate<'tcx>>,
>,
{
T::collect_and_apply(iter, |xs| self.intern_poly_existential_predicates(xs))
T::collect_and_apply(iter, |xs| self.mk_poly_existential_predicates(xs))
}
pub fn mk_predicates<I, T>(self, iter: I) -> T::Output
pub fn mk_predicates_from_iter<I, T>(self, iter: I) -> T::Output
where
I: Iterator<Item = T>,
T: CollectAndApply<Predicate<'tcx>, &'tcx List<Predicate<'tcx>>>,
{
T::collect_and_apply(iter, |xs| self.intern_predicates(xs))
T::collect_and_apply(iter, |xs| self.mk_predicates(xs))
}
pub fn mk_type_list<I, T>(self, iter: I) -> T::Output
pub fn mk_type_list_from_iter<I, T>(self, iter: I) -> T::Output
where
I: Iterator<Item = T>,
T: CollectAndApply<Ty<'tcx>, &'tcx List<Ty<'tcx>>>,
{
T::collect_and_apply(iter, |xs| self.intern_type_list(xs))
T::collect_and_apply(iter, |xs| self.mk_type_list(xs))
}
pub fn mk_substs<I, T>(self, iter: I) -> T::Output
pub fn mk_substs_from_iter<I, T>(self, iter: I) -> T::Output
where
I: Iterator<Item = T>,
T: CollectAndApply<GenericArg<'tcx>, &'tcx List<GenericArg<'tcx>>>,
{
T::collect_and_apply(iter, |xs| self.intern_substs(xs))
T::collect_and_apply(iter, |xs| self.mk_substs(xs))
}
pub fn mk_place_elems<I, T>(self, iter: I) -> T::Output
pub fn mk_canonical_var_infos_from_iter<I, T>(self, iter: I) -> T::Output
where
I: Iterator<Item = T>,
T: CollectAndApply<CanonicalVarInfo<'tcx>, &'tcx List<CanonicalVarInfo<'tcx>>>,
{
T::collect_and_apply(iter, |xs| self.mk_canonical_var_infos(xs))
}
pub fn mk_place_elems_from_iter<I, T>(self, iter: I) -> T::Output
where
I: Iterator<Item = T>,
T: CollectAndApply<PlaceElem<'tcx>, &'tcx List<PlaceElem<'tcx>>>,
{
T::collect_and_apply(iter, |xs| self.intern_place_elems(xs))
T::collect_and_apply(iter, |xs| self.mk_place_elems(xs))
}
pub fn mk_substs_trait(
@ -2287,7 +2274,7 @@ pub fn mk_substs_trait(
self_ty: Ty<'tcx>,
rest: impl IntoIterator<Item = GenericArg<'tcx>>,
) -> SubstsRef<'tcx> {
self.mk_substs(iter::once(self_ty.into()).chain(rest))
self.mk_substs_from_iter(iter::once(self_ty.into()).chain(rest))
}
pub fn mk_trait_ref(
@ -2295,7 +2282,7 @@ pub fn mk_trait_ref(
trait_def_id: DefId,
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
) -> ty::TraitRef<'tcx> {
let substs = self.check_substs(trait_def_id, substs);
let substs = self.check_and_mk_substs(trait_def_id, substs);
ty::TraitRef { def_id: trait_def_id, substs, _use_mk_trait_ref_instead: () }
}
@ -2304,16 +2291,16 @@ pub fn mk_alias_ty(
def_id: DefId,
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
) -> ty::AliasTy<'tcx> {
let substs = self.check_substs(def_id, substs);
let substs = self.check_and_mk_substs(def_id, substs);
ty::AliasTy { def_id, substs, _use_mk_alias_ty_instead: () }
}
pub fn mk_bound_variable_kinds<I, T>(self, iter: I) -> T::Output
pub fn mk_bound_variable_kinds_from_iter<I, T>(self, iter: I) -> T::Output
where
I: Iterator<Item = T>,
T: CollectAndApply<ty::BoundVariableKind, &'tcx List<ty::BoundVariableKind>>,
{
T::collect_and_apply(iter, |xs| self.intern_bound_variable_kinds(xs))
T::collect_and_apply(iter, |xs| self.mk_bound_variable_kinds(xs))
}
/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
@ -2398,7 +2385,7 @@ pub fn is_late_bound(self, id: HirId) -> bool {
}
pub fn late_bound_vars(self, id: HirId) -> &'tcx List<ty::BoundVariableKind> {
self.intern_bound_variable_kinds(
self.mk_bound_variable_kinds(
&self
.late_bound_vars_map(id.owner)
.and_then(|map| map.get(&id.local_id).cloned())

View file

@ -422,7 +422,7 @@ fn replace_const(&mut self, bv: ty::BoundVar, ty: Ty<'tcx>) -> ty::Const<'tcx> {
let mut map = Default::default();
let delegate = Anonymize { tcx: self, map: &mut map };
let inner = self.replace_escaping_bound_vars_uncached(value.skip_binder(), delegate);
let bound_vars = self.mk_bound_variable_kinds(map.into_values());
let bound_vars = self.mk_bound_variable_kinds_from_iter(map.into_values());
Binder::bind_with_vars(inner, bound_vars)
}
}

View file

@ -79,7 +79,7 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
// WARNING: We dedup cache the `HashStable` results for `List`
// while ignoring types and freely transmute
// between `List<Ty<'tcx>>` and `List<GenericArg<'tcx>>`.
// See `fn intern_type_list` for more details.
// See `fn mk_type_list` for more details.
//
// We therefore hash types without adding a hash for their discriminant.
//

View file

@ -540,7 +540,7 @@ pub fn resolve_closure(
pub fn resolve_drop_in_place(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> {
let def_id = tcx.require_lang_item(LangItem::DropInPlace, None);
let substs = tcx.intern_substs(&[ty.into()]);
let substs = tcx.mk_substs(&[ty.into()]);
Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs)
}

View file

@ -596,7 +596,7 @@ fn ty_and_layout_for_variant(
ty::Adt(def, _) => def.variant(variant_index).fields.len(),
_ => bug!(),
};
tcx.intern_layout(LayoutS {
tcx.mk_layout(LayoutS {
variants: Variants::Single { index: variant_index },
fields: match NonZeroUsize::new(fields) {
Some(fields) => FieldsShape::Union(fields),
@ -609,7 +609,7 @@ fn ty_and_layout_for_variant(
})
}
Variants::Multiple { ref variants, .. } => cx.tcx().intern_layout(variants[variant_index].clone()),
Variants::Multiple { ref variants, .. } => cx.tcx().mk_layout(variants[variant_index].clone()),
};
assert_eq!(*layout.variants(), Variants::Single { index: variant_index });
@ -631,7 +631,7 @@ fn field_ty_or_layout<'tcx>(
let tcx = cx.tcx();
let tag_layout = |tag: Scalar| -> TyAndLayout<'tcx> {
TyAndLayout {
layout: tcx.intern_layout(LayoutS::scalar(cx, tag)),
layout: tcx.mk_layout(LayoutS::scalar(cx, tag)),
ty: tag.primitive().to_ty(tcx),
}
};
@ -687,7 +687,7 @@ fn field_ty_or_layout<'tcx>(
Increase this counter if you tried to implement this but
failed to do it without duplicating a lot of code from
other places in the compiler: 2
tcx.intern_tup(&[
tcx.mk_tup(&[
tcx.mk_array(tcx.types.usize, 3),
tcx.mk_array(Option<fn()>),
])

View file

@ -757,7 +757,7 @@ pub fn subst_supertrait(
let new = EarlyBinder(shifted_pred).subst(tcx, trait_ref.skip_binder().substs);
// 3) ['x] + ['b] -> ['x, 'b]
let bound_vars =
tcx.mk_bound_variable_kinds(trait_bound_vars.iter().chain(pred_bound_vars));
tcx.mk_bound_variable_kinds_from_iter(trait_bound_vars.iter().chain(pred_bound_vars));
tcx.reuse_or_mk_predicate(self, ty::Binder::bind_with_vars(new, bound_vars))
}
}

View file

@ -79,7 +79,7 @@ fn fold_closure_substs(
// during codegen.
let generics = self.tcx.generics_of(def_id);
self.tcx.mk_substs(substs.iter().enumerate().map(|(index, kind)| {
self.tcx.mk_substs_from_iter(substs.iter().enumerate().map(|(index, kind)| {
if index < generics.parent_count {
// Accommodate missing regions in the parent kinds...
self.fold_kind_no_missing_regions_error(kind)

View file

@ -144,7 +144,7 @@ pub fn relate_substs<'tcx, R: TypeRelation<'tcx>>(
a_subst: SubstsRef<'tcx>,
b_subst: SubstsRef<'tcx>,
) -> RelateResult<'tcx, SubstsRef<'tcx>> {
relation.tcx().mk_substs(iter::zip(a_subst, b_subst).map(|(a, b)| {
relation.tcx().mk_substs_from_iter(iter::zip(a_subst, b_subst).map(|(a, b)| {
relation.relate_with_variance(ty::Invariant, ty::VarianceDiagInfo::default(), a, b)
}))
}
@ -171,7 +171,7 @@ pub fn relate_substs_with_variances<'tcx, R: TypeRelation<'tcx>>(
relation.relate_with_variance(variance, variance_info, a, b)
});
tcx.mk_substs(params)
tcx.mk_substs_from_iter(params)
}
impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
@ -222,7 +222,7 @@ fn relate<R: TypeRelation<'tcx>>(
r => r,
});
Ok(ty::FnSig {
inputs_and_output: tcx.mk_type_list(inputs_and_output)?,
inputs_and_output: tcx.mk_type_list_from_iter(inputs_and_output)?,
c_variadic: a.c_variadic,
unsafety,
abi,
@ -352,7 +352,8 @@ fn relate<R: TypeRelation<'tcx>>(
) -> RelateResult<'tcx, GeneratorWitness<'tcx>> {
assert_eq!(a.0.len(), b.0.len());
let tcx = relation.tcx();
let types = tcx.mk_type_list(iter::zip(a.0, b.0).map(|(a, b)| relation.relate(a, b)))?;
let types =
tcx.mk_type_list_from_iter(iter::zip(a.0, b.0).map(|(a, b)| relation.relate(a, b)))?;
Ok(GeneratorWitness(types))
}
}
@ -528,7 +529,7 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
(&ty::Tuple(as_), &ty::Tuple(bs)) => {
if as_.len() == bs.len() {
Ok(tcx.mk_tup(iter::zip(as_, bs).map(|(a, b)| relation.relate(a, b)))?)
Ok(tcx.mk_tup_from_iter(iter::zip(as_, bs).map(|(a, b)| relation.relate(a, b)))?)
} else if !(as_.is_empty() || bs.is_empty()) {
Err(TypeError::TupleSize(expected_found(relation, as_.len(), bs.len())))
} else {
@ -673,7 +674,7 @@ pub fn super_relate_consts<'tcx, R: TypeRelation<'tcx>>(
for (a_arg, b_arg) in aa.iter().zip(ba.iter()) {
related_args.push(r.consts(a_arg, b_arg)?);
}
let related_args = tcx.intern_const_list(&related_args);
let related_args = tcx.mk_const_list(&related_args);
Expr::FunctionCall(func, related_args)
}
_ => return Err(TypeError::ConstMismatch(expected_found(r, a, b))),
@ -720,7 +721,7 @@ fn relate<R: TypeRelation<'tcx>>(
_ => Err(TypeError::ExistentialMismatch(expected_found(relation, a, b))),
}
});
tcx.mk_poly_existential_predicates(v)
tcx.mk_poly_existential_predicates_from_iter(v)
}
}

View file

@ -430,7 +430,7 @@ fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_poly_existential_predicates(v))
ty::util::fold_list(self, folder, |tcx, v| tcx.mk_poly_existential_predicates(v))
}
}
@ -439,7 +439,7 @@ fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_const_list(v))
ty::util::fold_list(self, folder, |tcx, v| tcx.mk_const_list(v))
}
}
@ -448,7 +448,7 @@ fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_projs(v))
ty::util::fold_list(self, folder, |tcx, v| tcx.mk_projs(v))
}
}
@ -513,7 +513,7 @@ fn try_super_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
| ty::Foreign(..) => return Ok(self),
};
Ok(if *self.kind() == kind { self } else { folder.interner().mk_ty(kind) })
Ok(if *self.kind() == kind { self } else { folder.interner().mk_ty_from_kind(kind) })
}
}
@ -636,7 +636,7 @@ fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_predicates(v))
ty::util::fold_list(self, folder, |tcx, v| tcx.mk_predicates(v))
}
}

View file

@ -250,7 +250,7 @@ pub fn new(
parts: ClosureSubstsParts<'tcx, Ty<'tcx>>,
) -> ClosureSubsts<'tcx> {
ClosureSubsts {
substs: tcx.mk_substs(
substs: tcx.mk_substs_from_iter(
parts.parent_substs.iter().copied().chain(
[parts.closure_kind_ty, parts.closure_sig_as_fn_ptr_ty, parts.tupled_upvars_ty]
.iter()
@ -377,7 +377,7 @@ pub fn new(
parts: GeneratorSubstsParts<'tcx, Ty<'tcx>>,
) -> GeneratorSubsts<'tcx> {
GeneratorSubsts {
substs: tcx.mk_substs(
substs: tcx.mk_substs_from_iter(
parts.parent_substs.iter().copied().chain(
[
parts.resume_ty,
@ -655,7 +655,7 @@ pub fn new(
parts: InlineConstSubstsParts<'tcx, Ty<'tcx>>,
) -> InlineConstSubsts<'tcx> {
InlineConstSubsts {
substs: tcx.mk_substs(
substs: tcx.mk_substs_from_iter(
parts.parent_substs.iter().copied().chain(std::iter::once(parts.ty.into())),
),
}
@ -853,7 +853,7 @@ pub fn from_method(
substs: SubstsRef<'tcx>,
) -> ty::TraitRef<'tcx> {
let defs = tcx.generics_of(trait_id);
tcx.mk_trait_ref(trait_id, tcx.intern_substs(&substs[..defs.params.len()]))
tcx.mk_trait_ref(trait_id, tcx.mk_substs(&substs[..defs.params.len()]))
}
}
@ -899,7 +899,7 @@ pub fn erase_self_ty(
ty::ExistentialTraitRef {
def_id: trait_ref.def_id,
substs: tcx.intern_substs(&trait_ref.substs[1..]),
substs: tcx.mk_substs(&trait_ref.substs[1..]),
}
}
@ -1551,7 +1551,7 @@ impl<'tcx> ExistentialProjection<'tcx> {
pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::ExistentialTraitRef<'tcx> {
let def_id = tcx.parent(self.def_id);
let subst_count = tcx.generics_of(def_id).count() - 1;
let substs = tcx.intern_substs(&self.substs[..subst_count]);
let substs = tcx.mk_substs(&self.substs[..subst_count]);
ty::ExistentialTraitRef { def_id, substs }
}
@ -1579,7 +1579,7 @@ pub fn erase_self_ty(
Self {
def_id: projection_predicate.projection_ty.def_id,
substs: tcx.intern_substs(&projection_predicate.projection_ty.substs[1..]),
substs: tcx.mk_substs(&projection_predicate.projection_ty.substs[1..]),
term: projection_predicate.term,
}
}
@ -2209,7 +2209,7 @@ pub fn discriminant_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
let assoc_items = tcx.associated_item_def_ids(
tcx.require_lang_item(hir::LangItem::DiscriminantKind, None),
);
tcx.mk_projection(assoc_items[0], tcx.intern_substs(&[self.into()]))
tcx.mk_projection(assoc_items[0], tcx.mk_substs(&[self.into()]))
}
ty::Bool

View file

@ -71,7 +71,7 @@ impl<'tcx> List<Ty<'tcx>> {
/// Allows to freely switch between `List<Ty<'tcx>>` and `List<GenericArg<'tcx>>`.
///
/// As lists are interned, `List<Ty<'tcx>>` and `List<GenericArg<'tcx>>` have
/// be interned together, see `intern_type_list` for more details.
/// be interned together, see `mk_type_list` for more details.
#[inline]
pub fn as_substs(&'tcx self) -> SubstsRef<'tcx> {
assert_eq!(TYPE_TAG, 0);
@ -319,7 +319,7 @@ pub fn for_item<F>(tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRe
let count = defs.count();
let mut substs = SmallVec::with_capacity(count);
Self::fill_item(&mut substs, tcx, defs, &mut mk_kind);
tcx.intern_substs(&substs)
tcx.mk_substs(&substs)
}
pub fn extend_to<F>(&self, tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx>
@ -468,11 +468,11 @@ pub fn rebase_onto(
target_substs: SubstsRef<'tcx>,
) -> SubstsRef<'tcx> {
let defs = tcx.generics_of(source_ancestor);
tcx.mk_substs(target_substs.iter().chain(self.iter().skip(defs.params.len())))
tcx.mk_substs_from_iter(target_substs.iter().chain(self.iter().skip(defs.params.len())))
}
pub fn truncate_to(&self, tcx: TyCtxt<'tcx>, generics: &ty::Generics) -> SubstsRef<'tcx> {
tcx.mk_substs(self.iter().take(generics.count()))
tcx.mk_substs_from_iter(self.iter().take(generics.count()))
}
}
@ -486,14 +486,14 @@ fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
// The match arms are in order of frequency. The 1, 2, and 0 cases are
// typically hit in 90--99.99% of cases. When folding doesn't change
// the substs, it's faster to reuse the existing substs rather than
// calling `intern_substs`.
// calling `mk_substs`.
match self.len() {
1 => {
let param0 = self[0].try_fold_with(folder)?;
if param0 == self[0] {
Ok(self)
} else {
Ok(folder.interner().intern_substs(&[param0]))
Ok(folder.interner().mk_substs(&[param0]))
}
}
2 => {
@ -502,11 +502,11 @@ fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
if param0 == self[0] && param1 == self[1] {
Ok(self)
} else {
Ok(folder.interner().intern_substs(&[param0, param1]))
Ok(folder.interner().mk_substs(&[param0, param1]))
}
}
0 => Ok(self),
_ => ty::util::fold_list(self, folder, |tcx, v| tcx.intern_substs(v)),
_ => ty::util::fold_list(self, folder, |tcx, v| tcx.mk_substs(v)),
}
}
}
@ -538,10 +538,10 @@ fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
if param0 == self[0] && param1 == self[1] {
Ok(self)
} else {
Ok(folder.interner().intern_type_list(&[param0, param1]))
Ok(folder.interner().mk_type_list(&[param0, param1]))
}
}
_ => ty::util::fold_list(self, folder, |tcx, v| tcx.intern_type_list(v)),
_ => ty::util::fold_list(self, folder, |tcx, v| tcx.mk_type_list(v)),
}
}
}

View file

@ -112,5 +112,5 @@ pub(super) fn vtable_allocation_provider<'tcx>(
}
vtable.mutability = Mutability::Not;
tcx.create_memory_alloc(tcx.intern_const_alloc(vtable))
tcx.create_memory_alloc(tcx.mk_const_alloc(vtable))
}

View file

@ -132,14 +132,14 @@ pub(crate) fn lit_to_mir_constant<'tcx>(
(ast::LitKind::Str(s, _), ty::Ref(_, inner_ty, _)) if inner_ty.is_str() => {
let s = s.as_str();
let allocation = Allocation::from_bytes_byte_aligned_immutable(s.as_bytes());
let allocation = tcx.intern_const_alloc(allocation);
let allocation = tcx.mk_const_alloc(allocation);
ConstValue::Slice { data: allocation, start: 0, end: s.len() }
}
(ast::LitKind::ByteStr(data, _), ty::Ref(_, inner_ty, _))
if matches!(inner_ty.kind(), ty::Slice(_)) =>
{
let allocation = Allocation::from_bytes_byte_aligned_immutable(data as &[u8]);
let allocation = tcx.intern_const_alloc(allocation);
let allocation = tcx.mk_const_alloc(allocation);
ConstValue::Slice { data: allocation, start: 0, end: data.len() }
}
(ast::LitKind::ByteStr(data, _), ty::Ref(_, inner_ty, _)) if inner_ty.is_array() => {

View file

@ -170,7 +170,7 @@ pub(crate) fn as_call_operand(
// Return the operand *tmp0 to be used as the call argument
let place = Place {
local: operand,
projection: tcx.intern_place_elems(&[PlaceElem::Deref]),
projection: tcx.mk_place_elems(&[PlaceElem::Deref]),
};
return block.and(Operand::Move(place));

View file

@ -263,7 +263,7 @@ pub(in crate::build) fn try_to_place(&self, cx: &Builder<'_, 'tcx>) -> Option<Pl
let resolved = self.resolve_upvar(cx);
let builder = resolved.as_ref().unwrap_or(self);
let PlaceBase::Local(local) = builder.base else { return None };
let projection = cx.tcx.intern_place_elems(&builder.projection);
let projection = cx.tcx.mk_place_elems(&builder.projection);
Some(Place { local, projection })
}
@ -692,7 +692,7 @@ fn add_fake_borrows_of_base(
tcx.mk_imm_ref(tcx.lifetimes.re_erased, fake_borrow_deref_ty);
let fake_borrow_temp =
self.local_decls.push(LocalDecl::new(fake_borrow_ty, expr_span));
let projection = tcx.intern_place_elems(&base_place.projection[..idx]);
let projection = tcx.mk_place_elems(&base_place.projection[..idx]);
self.cfg.push_assign(
block,
source_info,

View file

@ -520,7 +520,7 @@ pub(crate) fn build_binary_op(
let source_info = self.source_info(span);
let bool_ty = self.tcx.types.bool;
if self.check_overflow && op.is_checkable() && ty.is_integral() {
let result_tup = self.tcx.intern_tup(&[ty, bool_ty]);
let result_tup = self.tcx.mk_tup(&[ty, bool_ty]);
let result_value = self.temp(result_tup, span);
self.cfg.push_assign(

View file

@ -1206,7 +1206,7 @@ fn select_matched_candidates(
fake_borrows.insert(Place {
local: source.local,
projection: self.tcx.intern_place_elems(proj_base),
projection: self.tcx.mk_place_elems(proj_base),
});
}
}
@ -1743,7 +1743,7 @@ fn calculate_fake_borrows<'b>(
.map(|matched_place_ref| {
let matched_place = Place {
local: matched_place_ref.local,
projection: tcx.intern_place_elems(matched_place_ref.projection),
projection: tcx.mk_place_elems(matched_place_ref.projection),
};
let fake_borrow_deref_ty = matched_place.ty(&self.local_decls, tcx).ty;
let fake_borrow_ty = tcx.mk_imm_ref(tcx.lifetimes.re_erased, fake_borrow_deref_ty);

View file

@ -859,7 +859,7 @@ fn args_and_body(
let use_place = Place {
local: ty::CAPTURE_STRUCT_LOCAL,
projection: tcx.intern_place_elems(&projs),
projection: tcx.mk_place_elems(&projs),
};
self.var_debug_info.push(VarDebugInfo {
name: *sym,

View file

@ -307,7 +307,7 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx>
let arg_tys = args.iter().map(|e| self.typeck_results().expr_ty_adjusted(e));
let tupled_args = Expr {
ty: tcx.mk_tup(arg_tys),
ty: tcx.mk_tup_from_iter(arg_tys),
temp_lifetime,
span: expr.span,
kind: ExprKind::Tuple { fields: self.mirror_exprs(args) },

View file

@ -133,9 +133,8 @@ fn closure_env_param(&self, owner_def: LocalDefId, owner_id: HirId) -> Option<Pa
bug!("closure expr does not have closure type: {:?}", closure_ty);
};
let bound_vars = self
.tcx
.intern_bound_variable_kinds(&[ty::BoundVariableKind::Region(ty::BrEnv)]);
let bound_vars =
self.tcx.mk_bound_variable_kinds(&[ty::BoundVariableKind::Region(ty::BrEnv)]);
let br = ty::BoundRegion {
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
kind: ty::BrEnv,

View file

@ -126,7 +126,7 @@ fn move_path_for(&mut self, place: Place<'tcx>) -> Result<MovePathIndex, MoveErr
BorrowedContent {
target_place: Place {
local: place.local,
projection: tcx.intern_place_elems(proj),
projection: tcx.mk_place_elems(proj),
},
},
));
@ -165,7 +165,7 @@ fn move_path_for(&mut self, place: Place<'tcx>) -> Result<MovePathIndex, MoveErr
if union_path.is_none() {
base = self.add_move_path(base, elem, |tcx| Place {
local: place.local,
projection: tcx.intern_place_elems(&place.projection[..i + 1]),
projection: tcx.mk_place_elems(&place.projection[..i + 1]),
});
}
}
@ -476,7 +476,7 @@ fn gather_move(&mut self, place: Place<'tcx>) {
// `ConstIndex` patterns. This is done to ensure that all move paths
// are disjoint, which is expected by drop elaboration.
let base_place =
Place { local: place.local, projection: self.builder.tcx.intern_place_elems(base) };
Place { local: place.local, projection: self.builder.tcx.mk_place_elems(base) };
let base_path = match self.move_path_for(base_place) {
Ok(path) => path,
Err(MoveError::UnionMove { path }) => {

View file

@ -124,7 +124,7 @@ fn visit_local(&mut self, local: &mut Local, ctxt: PlaceContext, _: Location) {
fn visit_place(&mut self, place: &mut Place<'tcx>, ctxt: PlaceContext, loc: Location) {
if let Some(new_projection) = self.process_projection(&place.projection, loc) {
place.projection = self.tcx().intern_place_elems(&new_projection);
place.projection = self.tcx().mk_place_elems(&new_projection);
}
let observes_address = match ctxt {

View file

@ -17,7 +17,7 @@ pub fn build_ptr_tys<'tcx>(
unique_did: DefId,
nonnull_did: DefId,
) -> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>) {
let substs = tcx.intern_substs(&[pointee.into()]);
let substs = tcx.mk_substs(&[pointee.into()]);
let unique_ty = tcx.type_of(unique_did).subst(tcx, substs);
let nonnull_ty = tcx.type_of(nonnull_did).subst(tcx, substs);
let ptr_ty = tcx.mk_imm_ptr(pointee);
@ -138,7 +138,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
if let Some(mut new_projections) = new_projections {
new_projections.extend_from_slice(&place.projection[last_deref..]);
place.projection = tcx.intern_place_elems(&new_projections);
place.projection = tcx.mk_place_elems(&new_projections);
}
}
}

View file

@ -126,7 +126,7 @@ fn visit_place(&mut self, place: &mut Place<'tcx>, context: PlaceContext, locati
place,
Place {
local: SELF_ARG,
projection: self.tcx().intern_place_elems(&[ProjectionElem::Deref]),
projection: self.tcx().mk_place_elems(&[ProjectionElem::Deref]),
},
self.tcx,
);
@ -162,10 +162,9 @@ fn visit_place(&mut self, place: &mut Place<'tcx>, context: PlaceContext, locati
place,
Place {
local: SELF_ARG,
projection: self.tcx().intern_place_elems(&[ProjectionElem::Field(
Field::new(0),
self.ref_gen_ty,
)]),
projection: self
.tcx()
.mk_place_elems(&[ProjectionElem::Field(Field::new(0), self.ref_gen_ty)]),
},
self.tcx,
);
@ -187,7 +186,7 @@ fn replace_base<'tcx>(place: &mut Place<'tcx>, new_base: Place<'tcx>, tcx: TyCtx
let mut new_projection = new_base.projection.to_vec();
new_projection.append(&mut place.projection.to_vec());
place.projection = tcx.intern_place_elems(&new_projection);
place.projection = tcx.mk_place_elems(&new_projection);
}
const SELF_ARG: Local = Local::from_u32(1);
@ -300,7 +299,7 @@ fn make_field(&self, variant_index: VariantIdx, idx: usize, ty: Ty<'tcx>) -> Pla
let mut projection = base.projection.to_vec();
projection.push(ProjectionElem::Field(Field::new(idx), ty));
Place { local: base.local, projection: self.tcx.intern_place_elems(&projection) }
Place { local: base.local, projection: self.tcx.mk_place_elems(&projection) }
}
// Create a statement which changes the discriminant
@ -427,7 +426,7 @@ fn make_generator_state_argument_pinned<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body
let pin_did = tcx.require_lang_item(LangItem::Pin, Some(body.span));
let pin_adt_ref = tcx.adt_def(pin_did);
let substs = tcx.intern_substs(&[ref_gen_ty.into()]);
let substs = tcx.mk_substs(&[ref_gen_ty.into()]);
let pin_ref_gen_ty = tcx.mk_adt(pin_adt_ref, substs);
// Replace the by ref generator argument
@ -1450,13 +1449,13 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// Compute Poll<return_ty>
let poll_did = tcx.require_lang_item(LangItem::Poll, None);
let poll_adt_ref = tcx.adt_def(poll_did);
let poll_substs = tcx.intern_substs(&[body.return_ty().into()]);
let poll_substs = tcx.mk_substs(&[body.return_ty().into()]);
(poll_adt_ref, poll_substs)
} else {
// Compute GeneratorState<yield_ty, return_ty>
let state_did = tcx.require_lang_item(LangItem::GeneratorState, None);
let state_adt_ref = tcx.adt_def(state_did);
let state_substs = tcx.intern_substs(&[yield_ty.into(), body.return_ty().into()]);
let state_substs = tcx.mk_substs(&[yield_ty.into(), body.return_ty().into()]);
(state_adt_ref, state_substs)
};
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);

View file

@ -888,7 +888,7 @@ fn visit_projection_elem(
location: Location,
) {
if let ProjectionElem::Field(f, ty) = elem {
let parent = Place { local, projection: self.tcx.intern_place_elems(proj_base) };
let parent = Place { local, projection: self.tcx.mk_place_elems(proj_base) };
let parent_ty = parent.ty(&self.callee_body.local_decls, self.tcx);
let check_equal = |this: &mut Self, f_ty| {
if !util::is_equal_up_to_subtyping(this.tcx, this.param_env, ty, f_ty) {

View file

@ -121,7 +121,7 @@ fn combine_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>)
*rvalue = Rvalue::Use(Operand::Copy(Place {
local: base.local,
projection: self.tcx.intern_place_elems(base.projection),
projection: self.tcx.mk_place_elems(base.projection),
}));
}
}

View file

@ -114,7 +114,7 @@ macro_rules! encode_store {
tcx.data_layout.ptr_sized_integer().align(&tcx.data_layout).abi,
Mutability::Not,
);
let alloc = tcx.create_memory_alloc(tcx.intern_const_alloc(alloc));
let alloc = tcx.create_memory_alloc(tcx.mk_const_alloc(alloc));
Some((*adt_def, num_discrs, *alloc_cache.entry(ty).or_insert(alloc)))
}
fn optim<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
@ -197,9 +197,8 @@ fn optim<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
size_place,
Rvalue::Use(Operand::Copy(Place {
local: size_array_local,
projection: tcx.intern_place_elems(&[PlaceElem::Index(
discr_cast_place.local,
)]),
projection: tcx
.mk_place_elems(&[PlaceElem::Index(discr_cast_place.local)]),
})),
)),
};

View file

@ -192,7 +192,7 @@ fn remap_mir_for_const_eval_select<'tcx>(
let arguments = (0..num_args).map(|x| {
let mut place_elems = place_elems.to_vec();
place_elems.push(ProjectionElem::Field(x.into(), fields[x]));
let projection = tcx.intern_place_elems(&place_elems);
let projection = tcx.mk_place_elems(&place_elems);
let place = Place {
local: place.local,
projection,

View file

@ -147,7 +147,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
assert!(!matches!(ty, Some(ty) if ty.is_generator()));
let substs = if let Some(ty) = ty {
tcx.intern_substs(&[ty.into()])
tcx.mk_substs(&[ty.into()])
} else {
InternalSubsts::identity_for_item(tcx, def_id)
};
@ -597,7 +597,7 @@ fn build_call_shim<'tcx>(
let untuple_args = sig.inputs();
// Create substitutions for the `Self` and `Args` generic parameters of the shim body.
let arg_tup = tcx.intern_tup(untuple_args);
let arg_tup = tcx.mk_tup(untuple_args);
(Some([ty.into(), arg_tup.into()]), Some(untuple_args))
} else {
@ -632,7 +632,7 @@ fn build_call_shim<'tcx>(
Adjustment::Deref => tcx.mk_imm_ptr(fnty),
Adjustment::RefMut => tcx.mk_mut_ptr(fnty),
};
sig.inputs_and_output = tcx.intern_type_list(&inputs_and_output);
sig.inputs_and_output = tcx.mk_type_list(&inputs_and_output);
}
// FIXME(eddyb) avoid having this snippet both here and in
@ -643,7 +643,7 @@ fn build_call_shim<'tcx>(
let self_arg = &mut inputs_and_output[0];
debug_assert!(tcx.generics_of(def_id).has_self && *self_arg == tcx.types.self_param);
*self_arg = tcx.mk_mut_ptr(*self_arg);
sig.inputs_and_output = tcx.intern_type_list(&inputs_and_output);
sig.inputs_and_output = tcx.mk_type_list(&inputs_and_output);
}
let span = tcx.def_span(def_id);

View file

@ -122,7 +122,7 @@ fn replace_place(&self, tcx: TyCtxt<'tcx>, place: PlaceRef<'tcx>) -> Option<Plac
let &[PlaceElem::Field(f, _), ref rest @ ..] = place.projection else { return None; };
let fields = self.fragments[place.local].as_ref()?;
let (_, new_local) = fields[f]?;
Some(Place { local: new_local, projection: tcx.intern_place_elems(&rest) })
Some(Place { local: new_local, projection: tcx.mk_place_elems(&rest) })
}
fn place_fragments(

View file

@ -1298,7 +1298,7 @@ fn push_extra_entry_roots(&mut self) {
self.tcx,
ty::ParamEnv::reveal_all(),
start_def_id,
self.tcx.intern_substs(&[main_ret_ty.into()]),
self.tcx.mk_substs(&[main_ret_ty.into()]),
)
.unwrap()
.unwrap();

View file

@ -675,7 +675,7 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
_ if ty.is_unit() => {}
ty::Tuple(tys) => {
ty = tcx.mk_tup(tys.iter().map(|ty| transform_ty(tcx, ty, options)));
ty = tcx.mk_tup_from_iter(tys.iter().map(|ty| transform_ty(tcx, ty, options)));
}
ty::Array(ty0, len) => {
@ -825,7 +825,7 @@ fn transform_substs<'tcx>(
subst
}
});
tcx.mk_substs(substs)
tcx.mk_substs_from_iter(substs)
}
/// Returns a type metadata identifier for the specified FnAbi using the Itanium C++ ABI with vendor

View file

@ -567,7 +567,7 @@ fn compute_external_query_constraints<'tcx>(
) -> Result<ExternalConstraints<'tcx>, NoSolution> {
let region_obligations = infcx.take_registered_region_obligations();
let opaque_types = infcx.take_opaque_types_for_query_response();
Ok(infcx.tcx.intern_external_constraints(ExternalConstraintsData {
Ok(infcx.tcx.mk_external_constraints(ExternalConstraintsData {
// FIXME: Now that's definitely wrong :)
//
// Should also do the leak check here I think
@ -616,8 +616,7 @@ pub(super) fn response_no_constraints<'tcx>(
var_values: CanonicalVarValues::make_identity(tcx, goal.variables),
// FIXME: maybe we should store the "no response" version in tcx, like
// we do for tcx.types and stuff.
external_constraints: tcx
.intern_external_constraints(ExternalConstraintsData::default()),
external_constraints: tcx.mk_external_constraints(ExternalConstraintsData::default()),
certainty,
},
})

View file

@ -343,9 +343,10 @@ fn consider_builtin_unsize_candidate(
// Substitute just the unsizing params from B into A. The type after
// this substitution must be equal to B. This is so we don't unsize
// unrelated type parameters.
let new_a_substs = tcx.mk_substs(a_substs.iter().enumerate().map(|(i, a)| {
if unsizing_params.contains(i as u32) { b_substs[i] } else { a }
}));
let new_a_substs =
tcx.mk_substs_from_iter(a_substs.iter().enumerate().map(|(i, a)| {
if unsizing_params.contains(i as u32) { b_substs[i] } else { a }
}));
let unsized_a_ty = tcx.mk_adt(a_def, new_a_substs);
// Finally, we require that `TailA: Unsize<TailB>` for the tail field
@ -368,7 +369,8 @@ fn consider_builtin_unsize_candidate(
let b_last_ty = b_tys.last().unwrap();
// Substitute just the tail field of B., and require that they're equal.
let unsized_a_ty = tcx.mk_tup(a_rest_tys.iter().chain([b_last_ty]).copied());
let unsized_a_ty =
tcx.mk_tup_from_iter(a_rest_tys.iter().chain([b_last_ty]).copied());
let mut nested_goals = ecx.eq(goal.param_env, unsized_a_ty, b_ty)?;
// Similar to ADTs, require that the rest of the fields are equal.
@ -425,7 +427,7 @@ fn consider_builtin_dyn_upcast_candidates(
.map(ty::ExistentialPredicate::AutoTrait)
.map(ty::Binder::dummy),
);
let new_a_data = tcx.mk_poly_existential_predicates(new_a_data);
let new_a_data = tcx.mk_poly_existential_predicates_from_iter(new_a_data);
let new_a_ty = tcx.mk_dynamic(new_a_data, b_region, ty::Dyn);
// We also require that A's lifetime outlives B's lifetime.

View file

@ -189,11 +189,9 @@ pub(crate) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
ty::FnDef(def_id, substs) => Ok(Some(
tcx.fn_sig(def_id)
.subst(tcx, substs)
.map_bound(|sig| (tcx.intern_tup(sig.inputs()), sig.output())),
.map_bound(|sig| (tcx.mk_tup(sig.inputs()), sig.output())),
)),
ty::FnPtr(sig) => {
Ok(Some(sig.map_bound(|sig| (tcx.intern_tup(sig.inputs()), sig.output()))))
}
ty::FnPtr(sig) => Ok(Some(sig.map_bound(|sig| (tcx.mk_tup(sig.inputs()), sig.output())))),
ty::Closure(_, substs) => {
let closure_substs = substs.as_closure();
match closure_substs.kind_ty().to_opt_closure_kind() {

View file

@ -350,14 +350,14 @@ fn evaluate_predicates(
)
.map(|o| o.predicate);
new_env = ty::ParamEnv::new(
tcx.mk_predicates(normalized_preds),
tcx.mk_predicates_from_iter(normalized_preds),
param_env.reveal(),
param_env.constness(),
);
}
let final_user_env = ty::ParamEnv::new(
tcx.mk_predicates(user_computed_preds.into_iter()),
tcx.mk_predicates_from_iter(user_computed_preds.into_iter()),
user_env.reveal(),
user_env.constness(),
);

View file

@ -281,7 +281,7 @@ pub fn normalize_param_env_or_error<'tcx>(
debug!("normalize_param_env_or_error: elaborated-predicates={:?}", predicates);
let elaborated_env = ty::ParamEnv::new(
tcx.intern_predicates(&predicates),
tcx.mk_predicates(&predicates),
unnormalized_env.reveal(),
unnormalized_env.constness(),
);
@ -333,10 +333,9 @@ pub fn normalize_param_env_or_error<'tcx>(
// Not sure whether it is better to include the unnormalized TypeOutlives predicates
// here. I believe they should not matter, because we are ignoring TypeOutlives param-env
// predicates here anyway. Keeping them here anyway because it seems safer.
let outlives_env: Vec<_> =
non_outlives_predicates.iter().chain(&outlives_predicates).cloned().collect();
let outlives_env = non_outlives_predicates.iter().chain(&outlives_predicates).cloned();
let outlives_env = ty::ParamEnv::new(
tcx.intern_predicates(&outlives_env),
tcx.mk_predicates_from_iter(outlives_env),
unnormalized_env.reveal(),
unnormalized_env.constness(),
);
@ -356,7 +355,7 @@ pub fn normalize_param_env_or_error<'tcx>(
predicates.extend(outlives_predicates);
debug!("normalize_param_env_or_error: final predicates={:?}", predicates);
ty::ParamEnv::new(
tcx.intern_predicates(&predicates),
tcx.mk_predicates(&predicates),
unnormalized_env.reveal(),
unnormalized_env.constness(),
)

View file

@ -18,10 +18,10 @@
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::subst::{GenericArg, InternalSubsts};
use rustc_middle::ty::ToPredicate;
use rustc_middle::ty::{
self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor,
};
use rustc_middle::ty::{Predicate, ToPredicate};
use rustc_session::lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY;
use rustc_span::symbol::Symbol;
use rustc_span::Span;
@ -666,8 +666,9 @@ fn object_ty_for_trait<'tcx>(
elaborated_predicates.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder()));
elaborated_predicates.dedup();
let existential_predicates = tcx
.mk_poly_existential_predicates(iter::once(trait_predicate).chain(elaborated_predicates));
let existential_predicates = tcx.mk_poly_existential_predicates_from_iter(
iter::once(trait_predicate).chain(elaborated_predicates),
);
debug!(?existential_predicates);
tcx.mk_dynamic(existential_predicates, lifetime, ty::Dyn)
@ -766,11 +767,11 @@ fn receiver_is_dispatchable<'tcx>(
ty::Binder::dummy(tcx.mk_trait_ref(trait_def_id, substs)).to_predicate(tcx)
};
let caller_bounds: Vec<Predicate<'tcx>> =
param_env.caller_bounds().iter().chain([unsize_predicate, trait_predicate]).collect();
let caller_bounds =
param_env.caller_bounds().iter().chain([unsize_predicate, trait_predicate]);
ty::ParamEnv::new(
tcx.intern_predicates(&caller_bounds),
tcx.mk_predicates_from_iter(caller_bounds),
param_env.reveal(),
param_env.constness(),
)

View file

@ -1906,7 +1906,7 @@ fn confirm_builtin_candidate<'cx, 'tcx>(
) -> Progress<'tcx> {
let tcx = selcx.tcx();
let self_ty = obligation.predicate.self_ty();
let substs = tcx.intern_substs(&[self_ty.into()]);
let substs = tcx.mk_substs(&[self_ty.into()]);
let lang_items = tcx.lang_items();
let item_def_id = obligation.predicate.def_id;
let trait_def_id = tcx.trait_of_item(item_def_id).unwrap();

View file

@ -564,8 +564,8 @@ fn confirm_object_candidate(
.into()
}
});
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);
let assoc_ty_substs = tcx.mk_substs(&substs);
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))
@ -880,7 +880,7 @@ fn confirm_trait_upcasting_unsize_candidate(
.map(ty::ExistentialPredicate::AutoTrait)
.map(ty::Binder::dummy),
);
let existential_predicates = tcx.mk_poly_existential_predicates(iter);
let existential_predicates = tcx.mk_poly_existential_predicates_from_iter(iter);
let source_trait = tcx.mk_dynamic(existential_predicates, r_b, repr_a);
// Require that the traits involved in this upcast are **equal**;
@ -979,7 +979,7 @@ fn confirm_builtin_unsize_candidate(
.map(ty::ExistentialPredicate::AutoTrait)
.map(ty::Binder::dummy),
);
let existential_predicates = tcx.mk_poly_existential_predicates(iter);
let existential_predicates = tcx.mk_poly_existential_predicates_from_iter(iter);
let source_trait = tcx.mk_dynamic(existential_predicates, r_b, dyn_a);
// Require that the traits involved in this upcast are **equal**;
@ -1099,7 +1099,7 @@ fn confirm_builtin_unsize_candidate(
// Check that the source struct with the target's
// unsizing parameters is equal to the target.
let substs = tcx.mk_substs(substs_a.iter().enumerate().map(|(i, k)| {
let substs = tcx.mk_substs_from_iter(substs_a.iter().enumerate().map(|(i, k)| {
if unsizing_params.contains(i as u32) { substs_b[i] } else { k }
}));
let new_struct = tcx.mk_adt(def, substs);
@ -1131,7 +1131,8 @@ fn confirm_builtin_unsize_candidate(
// Check that the source tuple with the target's
// last element is equal to the target.
let new_tuple = tcx.mk_tup(a_mid.iter().copied().chain(iter::once(b_last)));
let new_tuple =
tcx.mk_tup_from_iter(a_mid.iter().copied().chain(iter::once(b_last)));
let InferOk { obligations, .. } = self
.infcx
.at(&obligation.cause, obligation.param_env)

View file

@ -2230,7 +2230,7 @@ fn copy_clone_conditions(
}
}
// (*) binder moved here
let all_vars = self.tcx().mk_bound_variable_kinds(
let all_vars = self.tcx().mk_bound_variable_kinds_from_iter(
obligation.predicate.bound_vars().iter().chain(binder.bound_vars().iter()),
);
Where(ty::Binder::bind_with_vars(witness_tys.to_vec(), all_vars))
@ -3034,7 +3034,7 @@ fn bind_generator_hidden_types_above<'tcx>(
if considering_regions {
debug_assert!(!hidden_types.has_erased_regions());
}
let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.iter().chain(
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(bound_vars.iter().chain(
(num_bound_variables..counter).map(|i| ty::BoundVariableKind::Region(ty::BrAnon(i, None))),
));
ty::Binder::bind_with_vars(hidden_types, bound_vars)

View file

@ -292,7 +292,7 @@ pub fn closure_trait_ref_and_return_type<'tcx>(
assert!(!self_ty.has_escaping_bound_vars());
let arguments_tuple = match tuple_arguments {
TupleArgumentsFlag::No => sig.skip_binder().inputs()[0],
TupleArgumentsFlag::Yes => tcx.intern_tup(sig.skip_binder().inputs()),
TupleArgumentsFlag::Yes => tcx.mk_tup(sig.skip_binder().inputs()),
};
let trait_ref = tcx.mk_trait_ref(fn_trait_def_id, [self_ty, arguments_tuple]);
sig.map_bound(|sig| (trait_ref, sig.output()))

View file

@ -62,7 +62,9 @@ fn lower_into(
impl<'tcx> LowerInto<'tcx, SubstsRef<'tcx>> for &chalk_ir::Substitution<RustInterner<'tcx>> {
fn lower_into(self, interner: RustInterner<'tcx>) -> SubstsRef<'tcx> {
interner.tcx.mk_substs(self.iter(interner).map(|subst| subst.lower_into(interner)))
interner
.tcx
.mk_substs_from_iter(self.iter(interner).map(|subst| subst.lower_into(interner)))
}
}
@ -487,7 +489,7 @@ fn lower_into(self, interner: RustInterner<'tcx>) -> Ty<'tcx> {
TyKind::InferenceVar(_, _) => unimplemented!(),
TyKind::Dyn(_) => unimplemented!(),
};
interner.tcx.mk_ty(kind)
interner.tcx.mk_ty_from_kind(kind)
}
}

View file

@ -96,37 +96,34 @@ pub(crate) fn evaluate_goal<'tcx>(
use rustc_middle::infer::canonical::CanonicalVarInfo;
let mut reverse_param_substitutor = ReverseParamsSubstitutor::new(tcx, params);
let var_values = tcx.mk_substs(
let var_values = tcx.mk_substs_from_iter(
subst
.as_slice(interner)
.iter()
.map(|p| p.lower_into(interner).fold_with(&mut reverse_param_substitutor)),
);
let variables: Vec<_> = binders
.iter(interner)
.map(|var| {
let kind = match var.kind {
chalk_ir::VariableKind::Ty(ty_kind) => CanonicalVarKind::Ty(match ty_kind {
chalk_ir::TyVariableKind::General => CanonicalTyVarKind::General(
ty::UniverseIndex::from_usize(var.skip_kind().counter),
),
chalk_ir::TyVariableKind::Integer => CanonicalTyVarKind::Int,
chalk_ir::TyVariableKind::Float => CanonicalTyVarKind::Float,
}),
chalk_ir::VariableKind::Lifetime => CanonicalVarKind::Region(
let variables = binders.iter(interner).map(|var| {
let kind = match var.kind {
chalk_ir::VariableKind::Ty(ty_kind) => CanonicalVarKind::Ty(match ty_kind {
chalk_ir::TyVariableKind::General => CanonicalTyVarKind::General(
ty::UniverseIndex::from_usize(var.skip_kind().counter),
),
// FIXME(compiler-errors): We don't currently have a way of turning
// a Chalk ty back into a rustc ty, right?
chalk_ir::VariableKind::Const(_) => todo!(),
};
CanonicalVarInfo { kind }
})
.collect();
chalk_ir::TyVariableKind::Integer => CanonicalTyVarKind::Int,
chalk_ir::TyVariableKind::Float => CanonicalTyVarKind::Float,
}),
chalk_ir::VariableKind::Lifetime => {
CanonicalVarKind::Region(ty::UniverseIndex::from_usize(var.skip_kind().counter))
}
// FIXME(compiler-errors): We don't currently have a way of turning
// a Chalk ty back into a rustc ty, right?
chalk_ir::VariableKind::Const(_) => todo!(),
};
CanonicalVarInfo { kind }
});
let max_universe = binders.iter(interner).map(|v| v.skip_kind().counter).max().unwrap_or(0);
let sol = Canonical {
max_universe: ty::UniverseIndex::from_usize(max_universe),
variables: tcx.intern_canonical_var_infos(&variables),
variables: tcx.mk_canonical_var_infos_from_iter(variables),
value: QueryResponse {
var_values: CanonicalVarValues { var_values },
region_constraints: QueryRegionConstraints::default(),

View file

@ -54,7 +54,7 @@ fn fn_sig_for_fn_abi<'tcx>(
sig = sig.map_bound(|mut sig| {
let mut inputs_and_output = sig.inputs_and_output.to_vec();
inputs_and_output[0] = tcx.mk_mut_ptr(inputs_and_output[0]);
sig.inputs_and_output = tcx.intern_type_list(&inputs_and_output);
sig.inputs_and_output = tcx.mk_type_list(&inputs_and_output);
sig
});
}
@ -63,7 +63,7 @@ fn fn_sig_for_fn_abi<'tcx>(
ty::Closure(def_id, substs) => {
let sig = substs.as_closure().sig();
let bound_vars = tcx.mk_bound_variable_kinds(
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
);
let br = ty::BoundRegion {
@ -88,7 +88,7 @@ fn fn_sig_for_fn_abi<'tcx>(
ty::Generator(did, substs, _) => {
let sig = substs.as_generator().poly_sig();
let bound_vars = tcx.mk_bound_variable_kinds(
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
);
let br = ty::BoundRegion {
@ -99,7 +99,7 @@ fn fn_sig_for_fn_abi<'tcx>(
let pin_did = tcx.require_lang_item(LangItem::Pin, None);
let pin_adt_ref = tcx.adt_def(pin_did);
let pin_substs = tcx.intern_substs(&[env_ty.into()]);
let pin_substs = tcx.mk_substs(&[env_ty.into()]);
let env_ty = tcx.mk_adt(pin_adt_ref, pin_substs);
let sig = sig.skip_binder();
@ -111,7 +111,7 @@ fn fn_sig_for_fn_abi<'tcx>(
// The signature should be `Future::poll(_, &mut Context<'_>) -> Poll<Output>`
let poll_did = tcx.require_lang_item(LangItem::Poll, None);
let poll_adt_ref = tcx.adt_def(poll_did);
let poll_substs = tcx.intern_substs(&[sig.return_ty.into()]);
let poll_substs = tcx.mk_substs(&[sig.return_ty.into()]);
let ret_ty = tcx.mk_adt(poll_adt_ref, poll_substs);
// We have to replace the `ResumeTy` that is used for type and borrow checking
@ -133,7 +133,7 @@ fn fn_sig_for_fn_abi<'tcx>(
// The signature should be `Generator::resume(_, Resume) -> GeneratorState<Yield, Return>`
let state_did = tcx.require_lang_item(LangItem::GeneratorState, None);
let state_adt_ref = tcx.adt_def(state_did);
let state_substs = tcx.intern_substs(&[sig.yield_ty.into(), sig.return_ty.into()]);
let state_substs = tcx.mk_substs(&[sig.yield_ty.into(), sig.return_ty.into()]);
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);
(sig.resume_ty, ret_ty)

View file

@ -144,7 +144,7 @@ fn recurse_build<'tcx>(
for &id in args.iter() {
new_args.push(recurse_build(tcx, body, id, root_span)?);
}
let new_args = tcx.intern_const_list(&new_args);
let new_args = tcx.mk_const_list(&new_args);
tcx.mk_const(Expr::FunctionCall(fun, new_args), node.ty)
}
&ExprKind::Binary { op, lhs, rhs } if check_binop(op) => {

View file

@ -19,16 +19,16 @@ fn assumed_wf_types(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List<Ty<'_>> {
let mut assumed_wf_types: Vec<_> =
tcx.assumed_wf_types(tcx.parent(def_id)).as_slice().into();
assumed_wf_types.extend(liberated_sig.inputs_and_output);
tcx.intern_type_list(&assumed_wf_types)
tcx.mk_type_list(&assumed_wf_types)
}
DefKind::Impl { .. } => {
match tcx.impl_trait_ref(def_id) {
Some(trait_ref) => {
let types: Vec<_> = trait_ref.skip_binder().substs.types().collect();
tcx.intern_type_list(&types)
tcx.mk_type_list(&types)
}
// Only the impl self type
None => tcx.intern_type_list(&[tcx.type_of(def_id).subst_identity()]),
None => tcx.mk_type_list(&[tcx.type_of(def_id).subst_identity()]),
}
}
DefKind::AssocConst | DefKind::AssocTy => tcx.assumed_wf_types(tcx.parent(def_id)),

Some files were not shown because too many files have changed in this diff Show more