mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Rename many interner functions.
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
This commit is contained in:
parent
29b51cdff3
commit
2200911616
@ -1494,7 +1494,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
assert!(root_place.projection.is_empty());
|
assert!(root_place.projection.is_empty());
|
||||||
let proper_span = self.body.local_decls[root_place.local].source_info.span;
|
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(&(
|
if self.access_place_error_reported.contains(&(
|
||||||
Place { local: root_place.local, projection: root_place_projection },
|
Place { local: root_place.local, projection: root_place_projection },
|
||||||
|
@ -2633,7 +2633,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||||||
DefKind::InlineConst => substs.as_inline_const().parent_substs(),
|
DefKind::InlineConst => substs.as_inline_const().parent_substs(),
|
||||||
other => bug!("unexpected item {:?}", other),
|
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());
|
assert_eq!(typeck_root_substs.len(), parent_substs.len());
|
||||||
if let Err(_) = self.eq_substs(
|
if let Err(_) = self.eq_substs(
|
||||||
|
@ -516,7 +516,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||||||
let va_list_ty =
|
let va_list_ty =
|
||||||
self.infcx.tcx.type_of(va_list_did).subst(self.infcx.tcx, &[region.into()]);
|
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)),
|
unnormalized_input_tys.iter().copied().chain(iter::once(va_list_ty)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -656,7 +656,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||||||
assert_eq!(self.mir_def.did.to_def_id(), def_id);
|
assert_eq!(self.mir_def.did.to_def_id(), def_id);
|
||||||
let closure_sig = substs.as_closure().sig();
|
let closure_sig = substs.as_closure().sig();
|
||||||
let inputs_and_output = closure_sig.inputs_and_output();
|
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
|
inputs_and_output
|
||||||
.bound_vars()
|
.bound_vars()
|
||||||
.iter()
|
.iter()
|
||||||
@ -680,7 +680,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ty::Binder::bind_with_vars(
|
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)),
|
iter::once(closure_ty).chain(inputs).chain(iter::once(output)),
|
||||||
),
|
),
|
||||||
bound_vars,
|
bound_vars,
|
||||||
@ -693,7 +693,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||||||
let output = substs.as_generator().return_ty();
|
let output = substs.as_generator().return_ty();
|
||||||
let generator_ty = tcx.mk_generator(def_id, substs, movability);
|
let generator_ty = tcx.mk_generator(def_id, substs, movability);
|
||||||
let inputs_and_output =
|
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)
|
ty::Binder::dummy(inputs_and_output)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,13 +709,13 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||||||
assert_eq!(self.mir_def.did.to_def_id(), def_id);
|
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 = tcx.type_of(self.mir_def.def_id_for_type_of()).subst_identity();
|
||||||
let ty = indices.fold_to_region_vids(tcx, ty);
|
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) => {
|
DefiningTy::InlineConst(def_id, substs) => {
|
||||||
assert_eq!(self.mir_def.did.to_def_id(), def_id);
|
assert_eq!(self.mir_def.did.to_def_id(), def_id);
|
||||||
let ty = substs.as_inline_const().ty();
|
let ty = substs.as_inline_const().ty();
|
||||||
ty::Binder::dummy(tcx.intern_type_list(&[ty]))
|
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,9 +405,9 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let extra_args = &args[fn_sig.inputs().skip_binder().len()..];
|
let extra_args = &args[fn_sig.inputs().skip_binder().len()..];
|
||||||
let extra_args = fx
|
let extra_args = fx.tcx.mk_type_list_from_iter(
|
||||||
.tcx
|
extra_args.iter().map(|op_arg| fx.monomorphize(op_arg.ty(fx.mir, fx.tcx))),
|
||||||
.mk_type_list(extra_args.iter().map(|op_arg| fx.monomorphize(op_arg.ty(fx.mir, fx.tcx))));
|
);
|
||||||
let fn_abi = if let Some(instance) = instance {
|
let fn_abi = if let Some(instance) = instance {
|
||||||
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(instance, extra_args)
|
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(instance, extra_args)
|
||||||
} else {
|
} else {
|
||||||
|
@ -56,7 +56,7 @@ pub(crate) fn maybe_codegen<'tcx>(
|
|||||||
Some(fx.easy_call("__multi3", &[lhs, rhs], val_ty))
|
Some(fx.easy_call("__multi3", &[lhs, rhs], val_ty))
|
||||||
}
|
}
|
||||||
} else {
|
} 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 oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
|
||||||
let lhs = lhs.load_scalar(fx);
|
let lhs = lhs.load_scalar(fx);
|
||||||
let rhs = rhs.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 => {
|
BinOp::Add | BinOp::Sub | BinOp::Mul => {
|
||||||
assert!(checked);
|
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 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 (param_types, args) = if fx.tcx.sess.target.is_like_windows {
|
||||||
let (lhs_ptr, lhs_extra) = lhs.force_stack(fx);
|
let (lhs_ptr, lhs_extra) = lhs.force_stack(fx);
|
||||||
|
@ -191,7 +191,7 @@ fn llvm_add_sub<'tcx>(
|
|||||||
// carry0 | carry1 -> carry or borrow respectively
|
// carry0 | carry1 -> carry or borrow respectively
|
||||||
let cb_out = fx.bcx.ins().bor(cb0, cb1);
|
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);
|
let val = CValue::by_val_pair(cb_out, c, layout);
|
||||||
ret.write_cvalue(fx, val);
|
ret.write_cvalue(fx, val);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
|||||||
tcx,
|
tcx,
|
||||||
ParamEnv::reveal_all(),
|
ParamEnv::reveal_all(),
|
||||||
report.def_id,
|
report.def_id,
|
||||||
tcx.intern_substs(&[GenericArg::from(main_ret_ty)]),
|
tcx.mk_substs(&[GenericArg::from(main_ret_ty)]),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -146,7 +146,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
|||||||
tcx,
|
tcx,
|
||||||
ParamEnv::reveal_all(),
|
ParamEnv::reveal_all(),
|
||||||
start_def_id,
|
start_def_id,
|
||||||
tcx.intern_substs(&[main_ret_ty.into()]),
|
tcx.mk_substs(&[main_ret_ty.into()]),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -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),
|
_ => 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)
|
CValue::by_val_pair(res, has_overflow, out_layout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
|||||||
tcx,
|
tcx,
|
||||||
ty::ParamEnv::reveal_all(),
|
ty::ParamEnv::reveal_all(),
|
||||||
def_id,
|
def_id,
|
||||||
tcx.intern_substs(&[]),
|
tcx.mk_substs(&[]),
|
||||||
)
|
)
|
||||||
.unwrap().unwrap(),
|
.unwrap().unwrap(),
|
||||||
),
|
),
|
||||||
|
@ -520,14 +520,9 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let llfn = match tcx.lang_items().eh_personality() {
|
let llfn = match tcx.lang_items().eh_personality() {
|
||||||
Some(def_id) if !wants_msvc_seh(self.sess()) => self.get_fn_addr(
|
Some(def_id) if !wants_msvc_seh(self.sess()) => self.get_fn_addr(
|
||||||
ty::Instance::resolve(
|
ty::Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, tcx.mk_substs(&[]))
|
||||||
tcx,
|
.unwrap()
|
||||||
ty::ParamEnv::reveal_all(),
|
.unwrap(),
|
||||||
def_id,
|
|
||||||
tcx.intern_substs(&[]),
|
|
||||||
)
|
|
||||||
.unwrap()
|
|
||||||
.unwrap(),
|
|
||||||
),
|
),
|
||||||
_ => {
|
_ => {
|
||||||
let name = if wants_msvc_seh(self.sess()) {
|
let name = if wants_msvc_seh(self.sess()) {
|
||||||
|
@ -373,7 +373,7 @@ fn upstream_monomorphizations_provider(
|
|||||||
ExportedSymbol::Generic(def_id, substs) => (def_id, substs),
|
ExportedSymbol::Generic(def_id, substs) => (def_id, substs),
|
||||||
ExportedSymbol::DropGlue(ty) => {
|
ExportedSymbol::DropGlue(ty) => {
|
||||||
if let Some(drop_in_place_fn_def_id) = drop_in_place_fn_def_id {
|
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 {
|
} else {
|
||||||
// `drop_in_place` in place does not exist, don't try
|
// `drop_in_place` in place does not exist, don't try
|
||||||
// to use it.
|
// to use it.
|
||||||
|
@ -476,7 +476,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||||||
cx.tcx(),
|
cx.tcx(),
|
||||||
ty::ParamEnv::reveal_all(),
|
ty::ParamEnv::reveal_all(),
|
||||||
start_def_id,
|
start_def_id,
|
||||||
cx.tcx().intern_substs(&[main_ret_ty.into()]),
|
cx.tcx().mk_substs(&[main_ret_ty.into()]),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -783,7 +783,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let extra_args = &args[sig.inputs().skip_binder().len()..];
|
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());
|
let op_ty = op_arg.ty(self.mir, bx.tcx());
|
||||||
self.monomorphize(op_ty)
|
self.monomorphize(op_ty)
|
||||||
}));
|
}));
|
||||||
@ -1547,7 +1547,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||||||
slot
|
slot
|
||||||
} else {
|
} else {
|
||||||
let layout = cx.layout_of(
|
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);
|
let slot = PlaceRef::alloca(bx, layout);
|
||||||
self.personality_slot = Some(slot);
|
self.personality_slot = Some(slot);
|
||||||
|
@ -413,7 +413,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||||||
lhs.layout.ty,
|
lhs.layout.ty,
|
||||||
);
|
);
|
||||||
let val_ty = op.ty(bx.tcx(), lhs.layout.ty, rhs.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) }
|
OperandRef { val: result, layout: bx.cx().layout_of(operand_ty) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ pub(super) fn op_to_const<'tcx>(
|
|||||||
(ecx.tcx.global_alloc(alloc_id).unwrap_memory(), offset.bytes())
|
(ecx.tcx.global_alloc(alloc_id).unwrap_memory(), offset.bytes())
|
||||||
}
|
}
|
||||||
(None, _offset) => (
|
(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],
|
b"" as &[u8],
|
||||||
)),
|
)),
|
||||||
0,
|
0,
|
||||||
|
@ -135,7 +135,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx, const_eval:
|
|||||||
};
|
};
|
||||||
// link the alloc id to the actual allocation
|
// link the alloc id to the actual allocation
|
||||||
leftover_allocations.extend(alloc.provenance().ptrs().iter().map(|&(_, alloc_id)| alloc_id));
|
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);
|
tcx.set_alloc_id_memory(alloc_id, alloc);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -437,7 +437,7 @@ pub fn intern_const_alloc_recursive<
|
|||||||
alloc.mutability = Mutability::Not;
|
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);
|
tcx.set_alloc_id_memory(alloc_id, alloc);
|
||||||
for &(_, alloc_id) in alloc.inner().provenance().ptrs().iter() {
|
for &(_, alloc_id) in alloc.inner().provenance().ptrs().iter() {
|
||||||
if leftover_allocations.insert(alloc_id) {
|
if leftover_allocations.insert(alloc_id) {
|
||||||
@ -479,6 +479,6 @@ impl<'mir, 'tcx: 'mir, M: super::intern::CompileTimeMachine<'mir, 'tcx, !>>
|
|||||||
f(self, &dest.into())?;
|
f(self, &dest.into())?;
|
||||||
let mut alloc = self.memory.alloc_map.remove(&dest.ptr.provenance.unwrap()).unwrap().1;
|
let mut alloc = self.memory.alloc_map.remove(&dest.ptr.provenance.unwrap()).unwrap().1;
|
||||||
alloc.mutability = Mutability::Not;
|
alloc.mutability = Mutability::Not;
|
||||||
Ok(self.tcx.intern_const_alloc(alloc))
|
Ok(self.tcx.mk_const_alloc(alloc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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> {
|
pub(crate) fn alloc_type_name<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ConstAllocation<'tcx> {
|
||||||
let path = crate::util::type_name(tcx, ty);
|
let path = crate::util::type_name(tcx, ty);
|
||||||
let alloc = Allocation::from_bytes_byte_aligned_immutable(path.into_bytes());
|
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
|
/// The logic for all nullary intrinsics is implemented here. These intrinsics don't get evaluated
|
||||||
|
@ -96,7 +96,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
let loc_ty = self
|
let loc_ty = self
|
||||||
.tcx
|
.tcx
|
||||||
.type_of(self.tcx.require_lang_item(LangItem::PanicLocation, None))
|
.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 loc_layout = self.layout_of(loc_ty).unwrap();
|
||||||
let location = self.allocate(loc_layout, MemoryKind::CallerLocation).unwrap();
|
let location = self.allocate(loc_layout, MemoryKind::CallerLocation).unwrap();
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
) -> InterpResult<'tcx> {
|
) -> InterpResult<'tcx> {
|
||||||
let (val, overflowed, ty) = self.overflowing_binary_op(op, &left, &right)?;
|
let (val, overflowed, ty) = self.overflowing_binary_op(op, &left, &right)?;
|
||||||
debug_assert_eq!(
|
debug_assert_eq!(
|
||||||
self.tcx.intern_tup(&[ty, self.tcx.types.bool]),
|
self.tcx.mk_tup(&[ty, self.tcx.types.bool]),
|
||||||
dest.layout.ty,
|
dest.layout.ty,
|
||||||
"type mismatch for result of {:?}",
|
"type mismatch for result of {:?}",
|
||||||
op,
|
op,
|
||||||
|
@ -73,7 +73,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
let fn_sig =
|
let fn_sig =
|
||||||
self.tcx.normalize_erasing_late_bound_regions(self.param_env, fn_sig_binder);
|
self.tcx.normalize_erasing_late_bound_regions(self.param_env, fn_sig_binder);
|
||||||
let extra_args = &args[fn_sig.inputs().len()..];
|
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() {
|
let (fn_val, fn_abi, with_caller_location) = match *func.layout.ty.kind() {
|
||||||
ty::FnPtr(_sig) => {
|
ty::FnPtr(_sig) => {
|
||||||
|
@ -866,7 +866,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
|||||||
|
|
||||||
let mut projection = vec![PlaceElem::Deref];
|
let mut projection = vec![PlaceElem::Deref];
|
||||||
projection.extend(place.projection);
|
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.
|
// Create a temp to hold the promoted reference.
|
||||||
// This is because `*r` requires `r` to be a local,
|
// This is because `*r` requires `r` to be a local,
|
||||||
|
@ -315,7 +315,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProjectionElem::Field(f, ty) => {
|
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 parent_ty = parent.ty(&self.body.local_decls, self.tcx);
|
||||||
let fail_out_of_bounds = |this: &Self, location| {
|
let fail_out_of_bounds = |this: &Self, location| {
|
||||||
this.fail(location, format!("Out of bounds field {:?} for {:?}", f, parent_ty));
|
this.fail(location, format!("Out of bounds field {:?} for {:?}", f, parent_ty));
|
||||||
|
@ -377,7 +377,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
// `<Foo as Iterator>::Item = String`.
|
// `<Foo as Iterator>::Item = String`.
|
||||||
let projection_ty = pred.skip_binder().projection_ty;
|
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())
|
std::iter::once(tcx.mk_ty_var(ty::TyVid::from_u32(0)).into())
|
||||||
.chain(projection_ty.substs.iter().skip(1)),
|
.chain(projection_ty.substs.iter().skip(1)),
|
||||||
);
|
);
|
||||||
|
@ -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.
|
/// Checks that the correct number of generic arguments have been provided.
|
||||||
|
@ -381,7 +381,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
// here and so associated type bindings will be handled regardless of whether there are any
|
// here and so associated type bindings will be handled regardless of whether there are any
|
||||||
// non-`Self` generic parameters.
|
// non-`Self` generic parameters.
|
||||||
if generics.params.is_empty() {
|
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> {
|
struct SubstsForAstPathCtxt<'a, 'tcx> {
|
||||||
@ -1529,7 +1529,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
arg
|
arg
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let substs = tcx.intern_substs(&substs[..]);
|
let substs = tcx.mk_substs(&substs);
|
||||||
|
|
||||||
let span = i.bottom().1;
|
let span = i.bottom().1;
|
||||||
let empty_generic_args = hir_trait_bounds.iter().any(|hir_bound| {
|
let empty_generic_args = hir_trait_bounds.iter().any(|hir_bound| {
|
||||||
@ -1591,7 +1591,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
arg
|
arg
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
b.projection_ty.substs = tcx.intern_substs(&substs[..]);
|
b.projection_ty.substs = tcx.mk_substs(&substs);
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::ExistentialProjection::erase_self_ty(tcx, b)
|
ty::ExistentialProjection::erase_self_ty(tcx, b)
|
||||||
@ -1613,7 +1613,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
.collect::<SmallVec<[_; 8]>>();
|
.collect::<SmallVec<[_; 8]>>();
|
||||||
v.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder()));
|
v.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder()));
|
||||||
v.dedup();
|
v.dedup();
|
||||||
let existential_predicates = tcx.intern_poly_existential_predicates(&v);
|
let existential_predicates = tcx.mk_poly_existential_predicates(&v);
|
||||||
|
|
||||||
// Use explicitly-specified region bound.
|
// Use explicitly-specified region bound.
|
||||||
let region_bound = if !lifetime.is_elided() {
|
let region_bound = if !lifetime.is_elided() {
|
||||||
@ -3020,7 +3020,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
tcx.mk_ref(r, ty::TypeAndMut { ty: t, mutbl: mt.mutbl })
|
tcx.mk_ref(r, ty::TypeAndMut { ty: t, mutbl: mt.mutbl })
|
||||||
}
|
}
|
||||||
hir::TyKind::Never => tcx.types.never,
|
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) => {
|
hir::TyKind::BareFn(bf) => {
|
||||||
require_c_abi_if_c_variadic(tcx, bf.decl, bf.abi, ast_ty.span);
|
require_c_abi_if_c_variadic(tcx, bf.decl, bf.abi, ast_ty.span);
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ fn compare_method_predicate_entailment<'tcx>(
|
|||||||
// the new hybrid bounds we computed.
|
// the new hybrid bounds we computed.
|
||||||
let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_def_id);
|
let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_def_id);
|
||||||
let param_env = ty::ParamEnv::new(
|
let param_env = ty::ParamEnv::new(
|
||||||
tcx.intern_predicates(&hybrid_preds.predicates),
|
tcx.mk_predicates(&hybrid_preds.predicates),
|
||||||
Reveal::UserFacing,
|
Reveal::UserFacing,
|
||||||
hir::Constness::NotConst,
|
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 impl_ty_span = tcx.def_span(impl_ty_def_id);
|
||||||
let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_def_id);
|
let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_def_id);
|
||||||
let param_env = ty::ParamEnv::new(
|
let param_env = ty::ParamEnv::new(
|
||||||
tcx.intern_predicates(&hybrid_preds.predicates),
|
tcx.mk_predicates(&hybrid_preds.predicates),
|
||||||
Reveal::UserFacing,
|
Reveal::UserFacing,
|
||||||
hir::Constness::NotConst,
|
hir::Constness::NotConst,
|
||||||
);
|
);
|
||||||
@ -1937,8 +1937,8 @@ pub(super) fn check_type_bounds<'tcx>(
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let bound_vars = tcx.intern_bound_variable_kinds(&bound_vars);
|
let bound_vars = tcx.mk_bound_variable_kinds(&bound_vars);
|
||||||
let impl_ty_substs = tcx.intern_substs(&substs);
|
let impl_ty_substs = tcx.mk_substs(&substs);
|
||||||
let container_id = impl_ty.container_id(tcx);
|
let container_id = impl_ty.container_id(tcx);
|
||||||
|
|
||||||
let rebased_substs = impl_ty_substs.rebase_onto(tcx, container_id, impl_trait_ref.substs);
|
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),
|
.to_predicate(tcx),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
ty::ParamEnv::new(
|
ty::ParamEnv::new(tcx.mk_predicates(&predicates), Reveal::UserFacing, param_env.constness())
|
||||||
tcx.intern_predicates(&predicates),
|
|
||||||
Reveal::UserFacing,
|
|
||||||
param_env.constness(),
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
debug!(?normalize_param_env);
|
debug!(?normalize_param_env);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
|
|||||||
let intrinsic_name = tcx.item_name(intrinsic_id);
|
let intrinsic_name = tcx.item_name(intrinsic_id);
|
||||||
let name_str = intrinsic_name.as_str();
|
let name_str = intrinsic_name.as_str();
|
||||||
|
|
||||||
let bound_vars = tcx.intern_bound_variable_kinds(&[
|
let bound_vars = tcx.mk_bound_variable_kinds(&[
|
||||||
ty::BoundVariableKind::Region(ty::BrAnon(0, None)),
|
ty::BoundVariableKind::Region(ty::BrAnon(0, None)),
|
||||||
ty::BoundVariableKind::Region(ty::BrEnv),
|
ty::BoundVariableKind::Region(ty::BrEnv),
|
||||||
]);
|
]);
|
||||||
@ -165,7 +165,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
|
|||||||
"cxchg" | "cxchgweak" => (
|
"cxchg" | "cxchgweak" => (
|
||||||
1,
|
1,
|
||||||
vec![tcx.mk_mut_ptr(param(0)), param(0), param(0)],
|
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)),
|
"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()),
|
"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::bitreverse => (1, vec![param(0)], param(0)),
|
||||||
|
|
||||||
sym::add_with_overflow | sym::sub_with_overflow | sym::mul_with_overflow => {
|
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 => {
|
sym::ptr_guaranteed_cmp => {
|
||||||
@ -372,7 +372,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
|
|||||||
(
|
(
|
||||||
1,
|
1,
|
||||||
vec![tcx.mk_imm_ref(tcx.mk_re_late_bound(ty::INNERMOST, br), param(0))],
|
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()])),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,8 +493,9 @@ fn augment_param_env<'tcx>(
|
|||||||
return param_env;
|
return param_env;
|
||||||
}
|
}
|
||||||
|
|
||||||
let bounds =
|
let bounds = tcx.mk_predicates_from_iter(
|
||||||
tcx.mk_predicates(param_env.caller_bounds().iter().chain(new_predicates.iter().cloned()));
|
param_env.caller_bounds().iter().chain(new_predicates.iter().cloned()),
|
||||||
|
);
|
||||||
// FIXME(compiler-errors): Perhaps there is a case where we need to normalize this
|
// FIXME(compiler-errors): Perhaps there is a case where we need to normalize this
|
||||||
// i.e. traits::normalize_param_env_or_error
|
// i.e. traits::normalize_param_env_or_error
|
||||||
ty::ParamEnv::new(bounds, param_env.reveal(), param_env.constness())
|
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);
|
|idx| hir_decl.inputs.get(idx).map_or(hir_decl.output.span(), |arg: &hir::Ty<'_>| arg.span);
|
||||||
|
|
||||||
sig.inputs_and_output =
|
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(
|
wfcx.normalize(
|
||||||
arg_span(idx),
|
arg_span(idx),
|
||||||
Some(WellFormedLoc::Param {
|
Some(WellFormedLoc::Param {
|
||||||
|
@ -905,7 +905,7 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AdtDef<'_> {
|
|||||||
}
|
}
|
||||||
_ => bug!(),
|
_ => 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 {
|
fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef {
|
||||||
|
@ -103,7 +103,7 @@ pub(super) fn item_bounds(
|
|||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
) -> ty::EarlyBinder<&'_ ty::List<ty::Predicate<'_>>> {
|
) -> ty::EarlyBinder<&'_ ty::List<ty::Predicate<'_>>> {
|
||||||
let bounds = tcx.mk_predicates(
|
let bounds = tcx.mk_predicates_from_iter(
|
||||||
util::elaborate_predicates(
|
util::elaborate_predicates(
|
||||||
tcx,
|
tcx,
|
||||||
tcx.explicit_item_bounds(def_id).iter().map(|&(bound, _span)| bound),
|
tcx.explicit_item_bounds(def_id).iter().map(|&(bound, _span)| bound),
|
||||||
|
@ -232,7 +232,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let Some(trait_def_id) = opt_trait_def_id else { continue };
|
let Some(trait_def_id) = opt_trait_def_id else { continue };
|
||||||
|
|
||||||
let opt_input_type = opt_arg_exprs.map(|arg_exprs| {
|
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 {
|
self.next_ty_var(TypeVariableOrigin {
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
kind: TypeVariableOriginKind::TypeInference,
|
||||||
span: e.span,
|
span: e.span,
|
||||||
|
@ -127,7 +127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// the `closures` table.
|
// the `closures` table.
|
||||||
let sig = bound_sig.map_bound(|sig| {
|
let sig = bound_sig.map_bound(|sig| {
|
||||||
self.tcx.mk_fn_sig(
|
self.tcx.mk_fn_sig(
|
||||||
[self.tcx.intern_tup(sig.inputs())],
|
[self.tcx.mk_tup(sig.inputs())],
|
||||||
sig.output(),
|
sig.output(),
|
||||||
sig.c_variadic,
|
sig.c_variadic,
|
||||||
sig.unsafety,
|
sig.unsafety,
|
||||||
|
@ -1492,7 +1492,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
_ => self.check_expr_with_expectation(&e, NoExpectation),
|
_ => 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() {
|
if let Err(guar) = tuple.error_reported() {
|
||||||
self.tcx.ty_error(guar)
|
self.tcx.ty_error(guar)
|
||||||
} else {
|
} else {
|
||||||
|
@ -102,7 +102,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
let err_inputs = match tuple_arguments {
|
let err_inputs = match tuple_arguments {
|
||||||
DontTupleArguments => err_inputs,
|
DontTupleArguments => err_inputs,
|
||||||
TupleArguments => vec![self.tcx.intern_tup(&err_inputs)],
|
TupleArguments => vec![self.tcx.mk_tup(&err_inputs)],
|
||||||
};
|
};
|
||||||
|
|
||||||
self.check_argument_types(
|
self.check_argument_types(
|
||||||
@ -642,7 +642,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
&& provided_arg_tys.len() == formal_and_expected_inputs.len() - 1 + tys.len()
|
&& 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.
|
// 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()),
|
provided_arg_tys.iter().map(|(ty, _)| *ty).skip(mismatch_idx).take(tys.len()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -311,8 +311,8 @@ pub fn resolve_interior<'a, 'tcx>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Extract type components to build the witness type.
|
// Extract type components to build the witness type.
|
||||||
let type_list = fcx.tcx.mk_type_list(type_causes.iter().map(|cause| cause.ty));
|
let type_list = fcx.tcx.mk_type_list_from_iter(type_causes.iter().map(|cause| cause.ty));
|
||||||
let bound_vars = fcx.tcx.intern_bound_variable_kinds(&bound_vars);
|
let bound_vars = fcx.tcx.mk_bound_variable_kinds(&bound_vars);
|
||||||
let witness =
|
let witness =
|
||||||
fcx.tcx.mk_generator_witness(ty::Binder::bind_with_vars(type_list, bound_vars.clone()));
|
fcx.tcx.mk_generator_witness(ty::Binder::bind_with_vars(type_list, bound_vars.clone()));
|
||||||
|
|
||||||
|
@ -574,7 +574,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// `<Foo as Iterator>::Item = String`.
|
// `<Foo as Iterator>::Item = String`.
|
||||||
let projection_ty = pred.skip_binder().projection_ty;
|
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())
|
iter::once(tcx.mk_ty_var(ty::TyVid::from_u32(0)).into())
|
||||||
.chain(projection_ty.substs.iter().skip(1)),
|
.chain(projection_ty.substs.iter().skip(1)),
|
||||||
);
|
);
|
||||||
@ -1252,7 +1252,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
if let ty::Adt(def, substs) = target_ty.kind() {
|
if let ty::Adt(def, substs) = target_ty.kind() {
|
||||||
// If there are any inferred arguments, (`{integer}`), we should replace
|
// If there are any inferred arguments, (`{integer}`), we should replace
|
||||||
// them with underscores to allow the compiler to infer them
|
// 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) {
|
if !arg.is_suggestable(self.tcx, true) {
|
||||||
has_unsuggestable_args = true;
|
has_unsuggestable_args = true;
|
||||||
match arg.unpack() {
|
match arg.unpack() {
|
||||||
|
@ -1302,8 +1302,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span },
|
TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span },
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
let element_tys = tcx.mk_type_list(element_tys_iter);
|
let element_tys = tcx.mk_type_list_from_iter(element_tys_iter);
|
||||||
let pat_ty = tcx.intern_tup(element_tys);
|
let pat_ty = tcx.mk_tup(element_tys);
|
||||||
if let Some(mut err) = self.demand_eqtype_pat_diag(span, expected, pat_ty, ti) {
|
if let Some(mut err) = self.demand_eqtype_pat_diag(span, expected, pat_ty, ti) {
|
||||||
let reported = err.emit();
|
let reported = err.emit();
|
||||||
// Walk subpatterns with an expected type of `err` in this case to silence
|
// Walk subpatterns with an expected type of `err` in this case to silence
|
||||||
@ -1312,7 +1312,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
for (_, elem) in elements.iter().enumerate_and_adjust(max_len, ddpos) {
|
for (_, elem) in elements.iter().enumerate_and_adjust(max_len, ddpos) {
|
||||||
self.check_pat(elem, tcx.ty_error(reported), def_bm, ti);
|
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 {
|
} else {
|
||||||
for (i, elem) in elements.iter().enumerate_and_adjust(max_len, ddpos) {
|
for (i, elem) in elements.iter().enumerate_and_adjust(max_len, ddpos) {
|
||||||
self.check_pat(elem, element_tys[i], def_bm, ti);
|
self.check_pat(elem, element_tys[i], def_bm, ti);
|
||||||
|
@ -301,7 +301,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
// Build a tuple (U0..Un) of the final upvar types U0..Un
|
// Build a tuple (U0..Un) of the final upvar types U0..Un
|
||||||
// and unify the upvar tuple type in the closure with it:
|
// 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);
|
self.demand_suptype(span, substs.tupled_upvars_ty(), final_tupled_upvars_type);
|
||||||
|
|
||||||
let fake_reads = delegate
|
let fake_reads = delegate
|
||||||
@ -315,8 +315,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
self.typeck_results.borrow_mut().closure_size_eval.insert(
|
self.typeck_results.borrow_mut().closure_size_eval.insert(
|
||||||
closure_def_id,
|
closure_def_id,
|
||||||
ClosureSizeProfileData {
|
ClosureSizeProfileData {
|
||||||
before_feature_tys: self.tcx.intern_tup(&before_feature_tys),
|
before_feature_tys: self.tcx.mk_tup(&before_feature_tys),
|
||||||
after_feature_tys: self.tcx.intern_tup(&after_feature_tys),
|
after_feature_tys: self.tcx.mk_tup(&after_feature_tys),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -572,7 +572,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
|||||||
debug_assert!(!out_value.needs_infer() && !out_value.has_placeholders());
|
debug_assert!(!out_value.needs_infer() && !out_value.has_placeholders());
|
||||||
|
|
||||||
let canonical_variables =
|
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
|
let max_universe = canonical_variables
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -88,7 +88,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
|
universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
|
||||||
) -> CanonicalVarValues<'tcx> {
|
) -> CanonicalVarValues<'tcx> {
|
||||||
CanonicalVarValues {
|
CanonicalVarValues {
|
||||||
var_values: self.tcx.mk_substs(
|
var_values: self.tcx.mk_substs_from_iter(
|
||||||
variables
|
variables
|
||||||
.iter()
|
.iter()
|
||||||
.map(|info| self.instantiate_canonical_var(span, info, &universe_map)),
|
.map(|info| self.instantiate_canonical_var(span, info, &universe_map)),
|
||||||
|
@ -474,8 +474,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
// given variable in the loop above, use that. Otherwise, use
|
// given variable in the loop above, use that. Otherwise, use
|
||||||
// a fresh inference variable.
|
// a fresh inference variable.
|
||||||
let result_subst = CanonicalVarValues {
|
let result_subst = CanonicalVarValues {
|
||||||
var_values: self.tcx.mk_substs(query_response.variables.iter().enumerate().map(
|
var_values: self.tcx.mk_substs_from_iter(
|
||||||
|(index, info)| {
|
query_response.variables.iter().enumerate().map(|(index, info)| {
|
||||||
if info.is_existential() {
|
if info.is_existential() {
|
||||||
match opt_values[BoundVar::new(index)] {
|
match opt_values[BoundVar::new(index)] {
|
||||||
Some(k) => k,
|
Some(k) => k,
|
||||||
@ -488,8 +488,8 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
universe_map[u.as_usize()]
|
universe_map[u.as_usize()]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
}),
|
||||||
)),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut obligations = vec![];
|
let mut obligations = vec![];
|
||||||
|
@ -925,7 +925,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
// FIXME/HACK: Go back to `SubstsRef` to use its inherent methods,
|
// FIXME/HACK: Go back to `SubstsRef` to use its inherent methods,
|
||||||
// ideally that shouldn't be necessary.
|
// 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() {
|
for (i, ta) in sub.types().enumerate() {
|
||||||
if ta == other_ty {
|
if ta == other_ty {
|
||||||
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, other_ty);
|
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, other_ty);
|
||||||
|
@ -677,21 +677,21 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let def = cx.tcx.adt_def(item.owner_id);
|
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, cx.tcx.mk_substs(&[])))
|
||||||
}
|
}
|
||||||
hir::ItemKind::Union(_, ref ast_generics) => {
|
hir::ItemKind::Union(_, ref ast_generics) => {
|
||||||
if !ast_generics.params.is_empty() {
|
if !ast_generics.params.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let def = cx.tcx.adt_def(item.owner_id);
|
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, cx.tcx.mk_substs(&[])))
|
||||||
}
|
}
|
||||||
hir::ItemKind::Enum(_, ref ast_generics) => {
|
hir::ItemKind::Enum(_, ref ast_generics) => {
|
||||||
if !ast_generics.params.is_empty() {
|
if !ast_generics.params.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let def = cx.tcx.adt_def(item.owner_id);
|
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, cx.tcx.mk_substs(&[])))
|
||||||
}
|
}
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
@ -502,7 +502,7 @@ impl<'tcx> Collector<'tcx> {
|
|||||||
.subst_identity()
|
.subst_identity()
|
||||||
.fn_sig(self.tcx)
|
.fn_sig(self.tcx)
|
||||||
.inputs()
|
.inputs()
|
||||||
.map_bound(|slice| self.tcx.intern_type_list(slice)),
|
.map_bound(|slice| self.tcx.mk_type_list(slice)),
|
||||||
);
|
);
|
||||||
|
|
||||||
argument_types
|
argument_types
|
||||||
|
@ -910,7 +910,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||||||
std::iter::once(self.get_variant(&kind, item_id, did)).collect()
|
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 {
|
fn get_generics(self, item_id: DefIndex, sess: &Session) -> ty::Generics {
|
||||||
|
@ -47,7 +47,7 @@ impl<'tcx> ty::TypeFoldable<TyCtxt<'tcx>> for CanonicalVarInfos<'tcx> {
|
|||||||
self,
|
self,
|
||||||
folder: &mut F,
|
folder: &mut F,
|
||||||
) -> Result<Self, F::Error> {
|
) -> 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 @@ impl<'tcx> CanonicalVarValues<'tcx> {
|
|||||||
infos: CanonicalVarInfos<'tcx>,
|
infos: CanonicalVarInfos<'tcx>,
|
||||||
) -> CanonicalVarValues<'tcx> {
|
) -> CanonicalVarValues<'tcx> {
|
||||||
CanonicalVarValues {
|
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> {
|
|(i, info)| -> ty::GenericArg<'tcx> {
|
||||||
match info.kind {
|
match info.kind {
|
||||||
CanonicalVarKind::Ty(_) | CanonicalVarKind::PlaceholderTy(_) => {
|
CanonicalVarKind::Ty(_) | CanonicalVarKind::PlaceholderTy(_) => {
|
||||||
|
@ -1620,7 +1620,7 @@ impl<'tcx> Place<'tcx> {
|
|||||||
&v
|
&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 @@ impl<'tcx> ConstantKind<'tcx> {
|
|||||||
{
|
{
|
||||||
InternalSubsts::identity_for_item(tcx, parent_did.to_def_id())
|
InternalSubsts::identity_for_item(tcx, parent_did.to_def_id())
|
||||||
} else {
|
} else {
|
||||||
tcx.intern_substs(&[])
|
tcx.mk_substs(&[])
|
||||||
};
|
};
|
||||||
debug!(?parent_substs);
|
debug!(?parent_substs);
|
||||||
|
|
||||||
let did = def.did.to_def_id();
|
let did = def.did.to_def_id();
|
||||||
let child_substs = InternalSubsts::identity_for_item(tcx, did);
|
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);
|
debug!(?substs);
|
||||||
|
|
||||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def.did);
|
let hir_id = tcx.hir().local_def_id_to_hir_id(def.did);
|
||||||
|
@ -194,14 +194,16 @@ impl<'tcx> Rvalue<'tcx> {
|
|||||||
let lhs_ty = lhs.ty(local_decls, tcx);
|
let lhs_ty = lhs.ty(local_decls, tcx);
|
||||||
let rhs_ty = rhs.ty(local_decls, tcx);
|
let rhs_ty = rhs.ty(local_decls, tcx);
|
||||||
let ty = op.ty(tcx, lhs_ty, rhs_ty);
|
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::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::Discriminant(ref place) => place.ty(local_decls, tcx).ty.discriminant_ty(tcx),
|
||||||
Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, _) => tcx.types.usize,
|
Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, _) => tcx.types.usize,
|
||||||
Rvalue::Aggregate(ref ak, ref ops) => match **ak {
|
Rvalue::Aggregate(ref ak, ref ops) => match **ak {
|
||||||
AggregateKind::Array(ty) => tcx.mk_array(ty, ops.len() as u64),
|
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::Adt(did, _, substs, _, _) => tcx.type_of(did).subst(tcx, substs),
|
||||||
AggregateKind::Closure(did, substs) => tcx.mk_closure(did, substs),
|
AggregateKind::Closure(did, substs) => tcx.mk_closure(did, substs),
|
||||||
AggregateKind::Generator(did, substs, movability) => {
|
AggregateKind::Generator(did, substs, movability) => {
|
||||||
|
@ -53,6 +53,6 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<PlaceElem<'tcx>> {
|
|||||||
self,
|
self,
|
||||||
folder: &mut F,
|
folder: &mut F,
|
||||||
) -> Result<Self, F::Error> {
|
) -> 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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1045,7 +1045,7 @@ macro_rules! visit_place_fns {
|
|||||||
self.visit_local(&mut place.local, context, location);
|
self.visit_local(&mut place.local, context, location);
|
||||||
|
|
||||||
if let Some(new_projection) = self.process_projection(&place.projection, 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,20 +30,18 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
|
|||||||
self,
|
self,
|
||||||
folder: &mut F,
|
folder: &mut F,
|
||||||
) -> Result<Self, F::Error> {
|
) -> Result<Self, F::Error> {
|
||||||
Ok(FallibleTypeFolder::interner(folder).intern_external_constraints(
|
Ok(FallibleTypeFolder::interner(folder).mk_external_constraints(ExternalConstraintsData {
|
||||||
ExternalConstraintsData {
|
regions: (),
|
||||||
regions: (),
|
opaque_types: self
|
||||||
opaque_types: self
|
.opaque_types
|
||||||
.opaque_types
|
.iter()
|
||||||
.iter()
|
.map(|opaque| opaque.try_fold_with(folder))
|
||||||
.map(|opaque| opaque.try_fold_with(folder))
|
.collect::<Result<_, F::Error>>()?,
|
||||||
.collect::<Result<_, F::Error>>()?,
|
}))
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
|
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: (),
|
regions: (),
|
||||||
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
|
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
|
||||||
})
|
})
|
||||||
|
@ -54,7 +54,7 @@ bitflags! {
|
|||||||
|
|
||||||
/// The definition of a user-defined type, e.g., a `struct`, `enum`, or `union`.
|
/// 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].
|
/// The initialism *ADT* stands for an [*algebraic data type (ADT)*][adt].
|
||||||
/// This is slightly wrong because `union`s are not ADTs.
|
/// This is slightly wrong because `union`s are not ADTs.
|
||||||
|
@ -244,7 +244,7 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for SubstsRef<'tcx> {
|
|||||||
fn decode(decoder: &mut D) -> Self {
|
fn decode(decoder: &mut D) -> Self {
|
||||||
let len = decoder.read_usize();
|
let len = decoder.read_usize();
|
||||||
let tcx = decoder.interner();
|
let tcx = decoder.interner();
|
||||||
tcx.mk_substs(
|
tcx.mk_substs_from_iter(
|
||||||
(0..len).map::<ty::subst::GenericArg<'tcx>, _>(|_| Decodable::decode(decoder)),
|
(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 {
|
fn decode(decoder: &mut D) -> Self {
|
||||||
let local: mir::Local = Decodable::decode(decoder);
|
let local: mir::Local = Decodable::decode(decoder);
|
||||||
let len = decoder.read_usize();
|
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)),
|
(0..len).map::<mir::PlaceElem<'tcx>, _>(|_| Decodable::decode(decoder)),
|
||||||
);
|
);
|
||||||
mir::Place { local, projection }
|
mir::Place { local, projection }
|
||||||
@ -272,7 +272,7 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for CanonicalVarInfos<'t
|
|||||||
let len = decoder.read_usize();
|
let len = decoder.read_usize();
|
||||||
let interned: Vec<CanonicalVarInfo<'tcx>> =
|
let interned: Vec<CanonicalVarInfo<'tcx>> =
|
||||||
(0..len).map(|_| Decodable::decode(decoder)).collect();
|
(0..len).map(|_| Decodable::decode(decoder)).collect();
|
||||||
decoder.interner().intern_canonical_var_infos(interned.as_slice())
|
decoder.interner().mk_canonical_var_infos(&interned)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +310,9 @@ macro_rules! impl_decodable_via_ref {
|
|||||||
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<Ty<'tcx>> {
|
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<Ty<'tcx>> {
|
||||||
fn decode(decoder: &mut D) -> &'tcx Self {
|
fn decode(decoder: &mut D) -> &'tcx Self {
|
||||||
let len = decoder.read_usize();
|
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 {
|
fn decode(decoder: &mut D) -> &'tcx Self {
|
||||||
let len = decoder.read_usize();
|
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)),
|
(0..len).map::<ty::Binder<'tcx, _>, _>(|_| Decodable::decode(decoder)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -342,13 +344,13 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for [ty::ValTre
|
|||||||
|
|
||||||
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for ConstAllocation<'tcx> {
|
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for ConstAllocation<'tcx> {
|
||||||
fn decode(decoder: &mut D) -> Self {
|
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> {
|
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for AdtDef<'tcx> {
|
||||||
fn decode(decoder: &mut D) -> Self {
|
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 {
|
fn decode(decoder: &mut D) -> &'tcx Self {
|
||||||
let len = decoder.read_usize();
|
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)),
|
(0..len).map::<ty::BoundVariableKind, _>(|_| Decodable::decode(decoder)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -384,18 +386,18 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D>
|
|||||||
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<ty::Const<'tcx>> {
|
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<ty::Const<'tcx>> {
|
||||||
fn decode(decoder: &mut D) -> &'tcx Self {
|
fn decode(decoder: &mut D) -> &'tcx Self {
|
||||||
let len = decoder.read_usize();
|
let len = decoder.read_usize();
|
||||||
decoder
|
decoder.interner().mk_const_list_from_iter(
|
||||||
.interner()
|
(0..len).map::<ty::Const<'tcx>, _>(|_| Decodable::decode(decoder)),
|
||||||
.mk_const_list((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>> {
|
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for ty::List<ty::Predicate<'tcx>> {
|
||||||
fn decode(decoder: &mut D) -> &'tcx Self {
|
fn decode(decoder: &mut D) -> &'tcx Self {
|
||||||
let len = decoder.read_usize();
|
let len = decoder.read_usize();
|
||||||
let predicates: Vec<_> =
|
decoder.interner().mk_predicates_from_iter(
|
||||||
(0..len).map::<ty::Predicate<'tcx>, _>(|_| Decodable::decode(decoder)).collect();
|
(0..len).map::<ty::Predicate<'tcx>, _>(|_| Decodable::decode(decoder)),
|
||||||
decoder.interner().intern_predicates(&predicates)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ impl<'tcx> CtxtInterners<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Interns a type.
|
/// Interns a type. (Use `mk_*` functions instead, where possible.)
|
||||||
#[allow(rustc::usage_of_ty_tykind)]
|
#[allow(rustc::usage_of_ty_tykind)]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn intern_ty(&self, kind: TyKind<'tcx>, sess: &Session, untracked: &Untracked) -> Ty<'tcx> {
|
fn intern_ty(&self, kind: TyKind<'tcx>, sess: &Session, untracked: &Untracked) -> Ty<'tcx> {
|
||||||
@ -217,6 +217,7 @@ impl<'tcx> CtxtInterners<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Interns a predicate. (Use `mk_predicate` instead, where possible.)
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn intern_predicate(
|
fn intern_predicate(
|
||||||
&self,
|
&self,
|
||||||
@ -615,21 +616,21 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self.arena.alloc(Steal::new(promoted))
|
self.arena.alloc(Steal::new(promoted))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn alloc_adt_def(
|
pub fn mk_adt_def(
|
||||||
self,
|
self,
|
||||||
did: DefId,
|
did: DefId,
|
||||||
kind: AdtKind,
|
kind: AdtKind,
|
||||||
variants: IndexVec<VariantIdx, ty::VariantDef>,
|
variants: IndexVec<VariantIdx, ty::VariantDef>,
|
||||||
repr: ReprOptions,
|
repr: ReprOptions,
|
||||||
) -> ty::AdtDef<'tcx> {
|
) -> 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`.
|
/// Allocates a read-only byte or string literal for `mir::interpret`.
|
||||||
pub fn allocate_bytes(self, bytes: &[u8]) -> interpret::AllocId {
|
pub fn allocate_bytes(self, bytes: &[u8]) -> interpret::AllocId {
|
||||||
// Create an allocation that just contains these bytes.
|
// Create an allocation that just contains these bytes.
|
||||||
let alloc = interpret::Allocation::from_bytes_byte_aligned_immutable(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)
|
self.create_memory_alloc(alloc)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1194,7 +1195,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self.mk_imm_ref(
|
self.mk_imm_ref(
|
||||||
self.lifetimes.re_static,
|
self.lifetimes.re_static,
|
||||||
self.type_of(self.require_lang_item(LangItem::PanicLocation, None))
|
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 @@ macro_rules! nop_lift {
|
|||||||
|
|
||||||
// Can't use the macros as we have reuse the `substs` here.
|
// 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>> {
|
impl<'a, 'tcx> Lift<'tcx> for &'a List<Ty<'a>> {
|
||||||
type Lifted = &'tcx List<Ty<'tcx>>;
|
type Lifted = &'tcx List<Ty<'tcx>>;
|
||||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||||
@ -1517,7 +1518,7 @@ impl<'tcx, T: Hash> Hash for InternedInSet<'tcx, List<T>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! direct_interners {
|
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> {
|
$(impl<'tcx> Borrow<$ty> for InternedInSet<'tcx, $ty> {
|
||||||
fn borrow<'a>(&'a self) -> &'a $ty {
|
fn borrow<'a>(&'a self) -> &'a $ty {
|
||||||
&self.0
|
&self.0
|
||||||
@ -1543,7 +1544,7 @@ macro_rules! direct_interners {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TyCtxt<'tcx> {
|
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| {
|
$ret_ctor(Interned::new_unchecked(self.interners.$name.intern(v, |v| {
|
||||||
InternedInSet(self.interners.arena.alloc(v))
|
InternedInSet(self.interners.arena.alloc(v))
|
||||||
}).0))
|
}).0))
|
||||||
@ -1552,19 +1553,23 @@ macro_rules! direct_interners {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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! {
|
direct_interners! {
|
||||||
region: intern_region(RegionKind<'tcx>): Region -> Region<'tcx>,
|
region: intern_region(RegionKind<'tcx>): Region -> Region<'tcx>,
|
||||||
const_: mk_const_internal(ConstData<'tcx>): Const -> Const<'tcx>,
|
const_: intern_const(ConstData<'tcx>): Const -> Const<'tcx>,
|
||||||
const_allocation: intern_const_alloc(Allocation): ConstAllocation -> ConstAllocation<'tcx>,
|
const_allocation: pub mk_const_alloc(Allocation): ConstAllocation -> ConstAllocation<'tcx>,
|
||||||
layout: intern_layout(LayoutS): Layout -> Layout<'tcx>,
|
layout: pub mk_layout(LayoutS): Layout -> Layout<'tcx>,
|
||||||
adt_def: intern_adt_def(AdtDefData): AdtDef -> AdtDef<'tcx>,
|
adt_def: pub mk_adt_def_from_data(AdtDefData): AdtDef -> AdtDef<'tcx>,
|
||||||
external_constraints: intern_external_constraints(ExternalConstraintsData<'tcx>): ExternalConstraints -> ExternalConstraints<'tcx>,
|
external_constraints: pub mk_external_constraints(ExternalConstraintsData<'tcx>):
|
||||||
|
ExternalConstraints -> ExternalConstraints<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! slice_interners {
|
macro_rules! slice_interners {
|
||||||
($($field:ident: $method:ident($ty:ty)),+ $(,)?) => (
|
($($field:ident: $vis:vis $method:ident($ty:ty)),+ $(,)?) => (
|
||||||
impl<'tcx> TyCtxt<'tcx> {
|
impl<'tcx> TyCtxt<'tcx> {
|
||||||
$(pub fn $method(self, v: &[$ty]) -> &'tcx List<$ty> {
|
$($vis fn $method(self, v: &[$ty]) -> &'tcx List<$ty> {
|
||||||
if v.is_empty() {
|
if v.is_empty() {
|
||||||
List::empty()
|
List::empty()
|
||||||
} else {
|
} else {
|
||||||
@ -1577,16 +1582,18 @@ macro_rules! slice_interners {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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!(
|
slice_interners!(
|
||||||
const_lists: intern_const_list(Const<'tcx>),
|
const_lists: pub mk_const_list(Const<'tcx>),
|
||||||
substs: intern_substs(GenericArg<'tcx>),
|
substs: pub mk_substs(GenericArg<'tcx>),
|
||||||
canonical_var_infos: intern_canonical_var_infos(CanonicalVarInfo<'tcx>),
|
canonical_var_infos: pub mk_canonical_var_infos(CanonicalVarInfo<'tcx>),
|
||||||
poly_existential_predicates:
|
poly_existential_predicates: intern_poly_existential_predicates(PolyExistentialPredicate<'tcx>),
|
||||||
_intern_poly_existential_predicates(PolyExistentialPredicate<'tcx>),
|
predicates: intern_predicates(Predicate<'tcx>),
|
||||||
predicates: _intern_predicates(Predicate<'tcx>),
|
projs: pub mk_projs(ProjectionKind),
|
||||||
projs: intern_projs(ProjectionKind),
|
place_elems: pub mk_place_elems(PlaceElem<'tcx>),
|
||||||
place_elems: intern_place_elems(PlaceElem<'tcx>),
|
bound_variable_kinds: pub mk_bound_variable_kinds(ty::BoundVariableKind),
|
||||||
bound_variable_kinds: intern_bound_variable_kinds(ty::BoundVariableKind),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
impl<'tcx> TyCtxt<'tcx> {
|
impl<'tcx> TyCtxt<'tcx> {
|
||||||
@ -1834,16 +1841,16 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn intern_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx> {
|
pub fn mk_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx> {
|
||||||
if ts.is_empty() { self.types.unit } else { self.mk_ty(Tuple(self.intern_type_list(&ts))) }
|
if ts.is_empty() { self.types.unit } else { self.mk_ty(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
|
where
|
||||||
I: Iterator<Item = T>,
|
I: Iterator<Item = T>,
|
||||||
T: CollectAndApply<Ty<'tcx>, Ty<'tcx>>,
|
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]
|
#[inline]
|
||||||
@ -1862,12 +1869,12 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
let substs = self.check_substs(def_id, substs);
|
let substs = self.check_and_mk_substs(def_id, substs);
|
||||||
self.mk_ty(FnDef(def_id, substs))
|
self.mk_ty(FnDef(def_id, substs))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn check_substs(
|
fn check_and_mk_substs(
|
||||||
self,
|
self,
|
||||||
_def_id: DefId,
|
_def_id: DefId,
|
||||||
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
||||||
@ -1883,7 +1890,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
substs.collect::<Vec<_>>(),
|
substs.collect::<Vec<_>>(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
self.mk_substs(substs)
|
self.mk_substs_from_iter(substs)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -1934,7 +1941,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
pub fn mk_task_context(self) -> Ty<'tcx> {
|
pub fn mk_task_context(self) -> Ty<'tcx> {
|
||||||
let context_did = self.require_lang_item(LangItem::Context, None);
|
let context_did = self.require_lang_item(LangItem::Context, None);
|
||||||
let context_adt_ref = self.adt_def(context_did);
|
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);
|
let context_ty = self.mk_adt(context_adt_ref, context_substs);
|
||||||
self.mk_mut_ref(self.lifetimes.re_erased, context_ty)
|
self.mk_mut_ref(self.lifetimes.re_erased, context_ty)
|
||||||
}
|
}
|
||||||
@ -1946,7 +1953,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mk_const(self, kind: impl Into<ty::ConstKind<'tcx>>, ty: Ty<'tcx>) -> Const<'tcx> {
|
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]
|
#[inline]
|
||||||
@ -2136,10 +2143,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
let mut projection = place.projection.to_vec();
|
let mut projection = place.projection.to_vec();
|
||||||
projection.push(elem);
|
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,
|
self,
|
||||||
eps: &[PolyExistentialPredicate<'tcx>],
|
eps: &[PolyExistentialPredicate<'tcx>],
|
||||||
) -> &'tcx List<PolyExistentialPredicate<'tcx>> {
|
) -> &'tcx List<PolyExistentialPredicate<'tcx>> {
|
||||||
@ -2149,25 +2156,25 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
.all(|[a, b]| a.skip_binder().stable_cmp(self, &b.skip_binder())
|
.all(|[a, b]| a.skip_binder().stable_cmp(self, &b.skip_binder())
|
||||||
!= Ordering::Greater)
|
!= 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
|
// FIXME consider asking the input slice to be sorted to avoid
|
||||||
// re-interning permutations, in which case that would be asserted
|
// re-interning permutations, in which case that would be asserted
|
||||||
// here.
|
// here.
|
||||||
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
|
where
|
||||||
I: Iterator<Item = T>,
|
I: Iterator<Item = T>,
|
||||||
T: CollectAndApply<ty::Const<'tcx>, &'tcx List<ty::Const<'tcx>>>,
|
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_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx List<Ty<'tcx>> {
|
pub fn mk_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx List<Ty<'tcx>> {
|
||||||
// Actually intern type lists as lists of `GenericArg`s.
|
// Actually intern type lists as lists of `GenericArg`s.
|
||||||
//
|
//
|
||||||
// Transmuting from `Ty<'tcx>` to `GenericArg<'tcx>` is sound
|
// Transmuting from `Ty<'tcx>` to `GenericArg<'tcx>` is sound
|
||||||
@ -2175,15 +2182,14 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
// we guarantee that even when transmuting between `List<Ty<'tcx>>`
|
// we guarantee that even when transmuting between `List<Ty<'tcx>>`
|
||||||
// and `List<GenericArg<'tcx>>`, the uniqueness requirement for
|
// and `List<GenericArg<'tcx>>`, the uniqueness requirement for
|
||||||
// lists is upheld.
|
// lists is upheld.
|
||||||
let substs = self.intern_substs(ty::subst::ty_slice_as_generic_args(ts));
|
let substs = self.mk_substs(ty::subst::ty_slice_as_generic_args(ts));
|
||||||
substs.try_as_type_list().unwrap()
|
substs.try_as_type_list().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unlike various other `mk_*` functions, this one uses `I: IntoIterator`
|
// Unlike various other `mk_*_from_iter` functions, this one uses `I:
|
||||||
// instead of `I: Iterator`. Unlike those other functions, this one doesn't
|
// IntoIterator` instead of `I: Iterator`, and it doesn't have a slice
|
||||||
// have a `intern_fn_sig` variant that can be used for cases where `I` is
|
// variant, because of the need to combine `inputs` and `output`. This
|
||||||
// something like a `Vec`. That's because of the need to combine `inputs`
|
// explains the lack of `_from_iter` suffix.
|
||||||
// and `output`.
|
|
||||||
pub fn mk_fn_sig<I, T>(
|
pub fn mk_fn_sig<I, T>(
|
||||||
self,
|
self,
|
||||||
inputs: I,
|
inputs: I,
|
||||||
@ -2197,14 +2203,14 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
T: CollectAndApply<Ty<'tcx>, ty::FnSig<'tcx>>,
|
T: CollectAndApply<Ty<'tcx>, ty::FnSig<'tcx>>,
|
||||||
{
|
{
|
||||||
T::collect_and_apply(inputs.into_iter().chain(iter::once(output)), |xs| ty::FnSig {
|
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,
|
c_variadic,
|
||||||
unsafety,
|
unsafety,
|
||||||
abi,
|
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
|
where
|
||||||
I: Iterator<Item = T>,
|
I: Iterator<Item = T>,
|
||||||
T: CollectAndApply<
|
T: CollectAndApply<
|
||||||
@ -2212,39 +2218,39 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
&'tcx List<PolyExistentialPredicate<'tcx>>,
|
&'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
|
where
|
||||||
I: Iterator<Item = T>,
|
I: Iterator<Item = T>,
|
||||||
T: CollectAndApply<Predicate<'tcx>, &'tcx List<Predicate<'tcx>>>,
|
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
|
where
|
||||||
I: Iterator<Item = T>,
|
I: Iterator<Item = T>,
|
||||||
T: CollectAndApply<Ty<'tcx>, &'tcx List<Ty<'tcx>>>,
|
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
|
where
|
||||||
I: Iterator<Item = T>,
|
I: Iterator<Item = T>,
|
||||||
T: CollectAndApply<GenericArg<'tcx>, &'tcx List<GenericArg<'tcx>>>,
|
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_place_elems_from_iter<I, T>(self, iter: I) -> T::Output
|
||||||
where
|
where
|
||||||
I: Iterator<Item = T>,
|
I: Iterator<Item = T>,
|
||||||
T: CollectAndApply<PlaceElem<'tcx>, &'tcx List<PlaceElem<'tcx>>>,
|
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(
|
pub fn mk_substs_trait(
|
||||||
@ -2252,7 +2258,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
rest: impl IntoIterator<Item = GenericArg<'tcx>>,
|
rest: impl IntoIterator<Item = GenericArg<'tcx>>,
|
||||||
) -> SubstsRef<'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(
|
pub fn mk_trait_ref(
|
||||||
@ -2260,7 +2266,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
||||||
) -> ty::TraitRef<'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: () }
|
ty::TraitRef { def_id: trait_def_id, substs, _use_mk_trait_ref_instead: () }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2269,16 +2275,16 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
||||||
) -> ty::AliasTy<'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: () }
|
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
|
where
|
||||||
I: Iterator<Item = T>,
|
I: Iterator<Item = T>,
|
||||||
T: CollectAndApply<ty::BoundVariableKind, &'tcx List<ty::BoundVariableKind>>,
|
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`,
|
/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`,
|
||||||
@ -2363,7 +2369,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn late_bound_vars(self, id: HirId) -> &'tcx List<ty::BoundVariableKind> {
|
pub fn late_bound_vars(self, id: HirId) -> &'tcx List<ty::BoundVariableKind> {
|
||||||
self.intern_bound_variable_kinds(
|
self.mk_bound_variable_kinds(
|
||||||
&self
|
&self
|
||||||
.late_bound_vars_map(id.owner)
|
.late_bound_vars_map(id.owner)
|
||||||
.and_then(|map| map.get(&id.local_id).cloned())
|
.and_then(|map| map.get(&id.local_id).cloned())
|
||||||
|
@ -422,7 +422,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
let mut map = Default::default();
|
let mut map = Default::default();
|
||||||
let delegate = Anonymize { tcx: self, map: &mut map };
|
let delegate = Anonymize { tcx: self, map: &mut map };
|
||||||
let inner = self.replace_escaping_bound_vars_uncached(value.skip_binder(), delegate);
|
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)
|
Binder::bind_with_vars(inner, bound_vars)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::subst::GenericArgKin
|
|||||||
// WARNING: We dedup cache the `HashStable` results for `List`
|
// WARNING: We dedup cache the `HashStable` results for `List`
|
||||||
// while ignoring types and freely transmute
|
// while ignoring types and freely transmute
|
||||||
// between `List<Ty<'tcx>>` and `List<GenericArg<'tcx>>`.
|
// 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.
|
// We therefore hash types without adding a hash for their discriminant.
|
||||||
//
|
//
|
||||||
|
@ -540,7 +540,7 @@ impl<'tcx> Instance<'tcx> {
|
|||||||
|
|
||||||
pub fn resolve_drop_in_place(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> {
|
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 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)
|
Instance::expect_resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ where
|
|||||||
ty::Adt(def, _) => def.variant(variant_index).fields.len(),
|
ty::Adt(def, _) => def.variant(variant_index).fields.len(),
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
tcx.intern_layout(LayoutS {
|
tcx.mk_layout(LayoutS {
|
||||||
variants: Variants::Single { index: variant_index },
|
variants: Variants::Single { index: variant_index },
|
||||||
fields: match NonZeroUsize::new(fields) {
|
fields: match NonZeroUsize::new(fields) {
|
||||||
Some(fields) => FieldsShape::Union(fields),
|
Some(fields) => FieldsShape::Union(fields),
|
||||||
@ -609,7 +609,7 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
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 });
|
assert_eq!(*layout.variants(), Variants::Single { index: variant_index });
|
||||||
@ -631,7 +631,7 @@ where
|
|||||||
let tcx = cx.tcx();
|
let tcx = cx.tcx();
|
||||||
let tag_layout = |tag: Scalar| -> TyAndLayout<'tcx> {
|
let tag_layout = |tag: Scalar| -> TyAndLayout<'tcx> {
|
||||||
TyAndLayout {
|
TyAndLayout {
|
||||||
layout: tcx.intern_layout(LayoutS::scalar(cx, tag)),
|
layout: tcx.mk_layout(LayoutS::scalar(cx, tag)),
|
||||||
ty: tag.primitive().to_ty(tcx),
|
ty: tag.primitive().to_ty(tcx),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -687,7 +687,7 @@ where
|
|||||||
Increase this counter if you tried to implement this but
|
Increase this counter if you tried to implement this but
|
||||||
failed to do it without duplicating a lot of code from
|
failed to do it without duplicating a lot of code from
|
||||||
other places in the compiler: 2
|
other places in the compiler: 2
|
||||||
tcx.intern_tup(&[
|
tcx.mk_tup(&[
|
||||||
tcx.mk_array(tcx.types.usize, 3),
|
tcx.mk_array(tcx.types.usize, 3),
|
||||||
tcx.mk_array(Option<fn()>),
|
tcx.mk_array(Option<fn()>),
|
||||||
])
|
])
|
||||||
|
@ -757,7 +757,7 @@ impl<'tcx> Predicate<'tcx> {
|
|||||||
let new = EarlyBinder(shifted_pred).subst(tcx, trait_ref.skip_binder().substs);
|
let new = EarlyBinder(shifted_pred).subst(tcx, trait_ref.skip_binder().substs);
|
||||||
// 3) ['x] + ['b] -> ['x, 'b]
|
// 3) ['x] + ['b] -> ['x, 'b]
|
||||||
let bound_vars =
|
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))
|
tcx.reuse_or_mk_predicate(self, ty::Binder::bind_with_vars(new, bound_vars))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ impl<'tcx> ReverseMapper<'tcx> {
|
|||||||
// during codegen.
|
// during codegen.
|
||||||
|
|
||||||
let generics = self.tcx.generics_of(def_id);
|
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 {
|
if index < generics.parent_count {
|
||||||
// Accommodate missing regions in the parent kinds...
|
// Accommodate missing regions in the parent kinds...
|
||||||
self.fold_kind_no_missing_regions_error(kind)
|
self.fold_kind_no_missing_regions_error(kind)
|
||||||
|
@ -144,7 +144,7 @@ pub fn relate_substs<'tcx, R: TypeRelation<'tcx>>(
|
|||||||
a_subst: SubstsRef<'tcx>,
|
a_subst: SubstsRef<'tcx>,
|
||||||
b_subst: SubstsRef<'tcx>,
|
b_subst: SubstsRef<'tcx>,
|
||||||
) -> RelateResult<'tcx, 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)
|
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)
|
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> {
|
impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
|
||||||
@ -222,7 +222,7 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
|
|||||||
r => r,
|
r => r,
|
||||||
});
|
});
|
||||||
Ok(ty::FnSig {
|
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,
|
c_variadic: a.c_variadic,
|
||||||
unsafety,
|
unsafety,
|
||||||
abi,
|
abi,
|
||||||
@ -352,7 +352,8 @@ impl<'tcx> Relate<'tcx> for GeneratorWitness<'tcx> {
|
|||||||
) -> RelateResult<'tcx, GeneratorWitness<'tcx>> {
|
) -> RelateResult<'tcx, GeneratorWitness<'tcx>> {
|
||||||
assert_eq!(a.0.len(), b.0.len());
|
assert_eq!(a.0.len(), b.0.len());
|
||||||
let tcx = relation.tcx();
|
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))
|
Ok(GeneratorWitness(types))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -528,7 +529,7 @@ pub fn super_relate_tys<'tcx, R: TypeRelation<'tcx>>(
|
|||||||
|
|
||||||
(&ty::Tuple(as_), &ty::Tuple(bs)) => {
|
(&ty::Tuple(as_), &ty::Tuple(bs)) => {
|
||||||
if as_.len() == bs.len() {
|
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()) {
|
} else if !(as_.is_empty() || bs.is_empty()) {
|
||||||
Err(TypeError::TupleSize(expected_found(relation, as_.len(), bs.len())))
|
Err(TypeError::TupleSize(expected_found(relation, as_.len(), bs.len())))
|
||||||
} else {
|
} 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()) {
|
for (a_arg, b_arg) in aa.iter().zip(ba.iter()) {
|
||||||
related_args.push(r.consts(a_arg, b_arg)?);
|
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)
|
Expr::FunctionCall(func, related_args)
|
||||||
}
|
}
|
||||||
_ => return Err(TypeError::ConstMismatch(expected_found(r, a, b))),
|
_ => return Err(TypeError::ConstMismatch(expected_found(r, a, b))),
|
||||||
@ -720,7 +721,7 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>> {
|
|||||||
_ => Err(TypeError::ExistentialMismatch(expected_found(relation, a, b))),
|
_ => Err(TypeError::ExistentialMismatch(expected_found(relation, a, b))),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tcx.mk_poly_existential_predicates(v)
|
tcx.mk_poly_existential_predicates_from_iter(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<ty::PolyExistentialPred
|
|||||||
self,
|
self,
|
||||||
folder: &mut F,
|
folder: &mut F,
|
||||||
) -> Result<Self, F::Error> {
|
) -> 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 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<ty::Const<'tcx>> {
|
|||||||
self,
|
self,
|
||||||
folder: &mut F,
|
folder: &mut F,
|
||||||
) -> Result<Self, F::Error> {
|
) -> 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 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<ProjectionKind> {
|
|||||||
self,
|
self,
|
||||||
folder: &mut F,
|
folder: &mut F,
|
||||||
) -> Result<Self, F::Error> {
|
) -> 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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,7 +636,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<ty::Predicate<'tcx>> {
|
|||||||
self,
|
self,
|
||||||
folder: &mut F,
|
folder: &mut F,
|
||||||
) -> Result<Self, F::Error> {
|
) -> 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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ impl<'tcx> ClosureSubsts<'tcx> {
|
|||||||
parts: ClosureSubstsParts<'tcx, Ty<'tcx>>,
|
parts: ClosureSubstsParts<'tcx, Ty<'tcx>>,
|
||||||
) -> ClosureSubsts<'tcx> {
|
) -> ClosureSubsts<'tcx> {
|
||||||
ClosureSubsts {
|
ClosureSubsts {
|
||||||
substs: tcx.mk_substs(
|
substs: tcx.mk_substs_from_iter(
|
||||||
parts.parent_substs.iter().copied().chain(
|
parts.parent_substs.iter().copied().chain(
|
||||||
[parts.closure_kind_ty, parts.closure_sig_as_fn_ptr_ty, parts.tupled_upvars_ty]
|
[parts.closure_kind_ty, parts.closure_sig_as_fn_ptr_ty, parts.tupled_upvars_ty]
|
||||||
.iter()
|
.iter()
|
||||||
@ -377,7 +377,7 @@ impl<'tcx> GeneratorSubsts<'tcx> {
|
|||||||
parts: GeneratorSubstsParts<'tcx, Ty<'tcx>>,
|
parts: GeneratorSubstsParts<'tcx, Ty<'tcx>>,
|
||||||
) -> GeneratorSubsts<'tcx> {
|
) -> GeneratorSubsts<'tcx> {
|
||||||
GeneratorSubsts {
|
GeneratorSubsts {
|
||||||
substs: tcx.mk_substs(
|
substs: tcx.mk_substs_from_iter(
|
||||||
parts.parent_substs.iter().copied().chain(
|
parts.parent_substs.iter().copied().chain(
|
||||||
[
|
[
|
||||||
parts.resume_ty,
|
parts.resume_ty,
|
||||||
@ -655,7 +655,7 @@ impl<'tcx> InlineConstSubsts<'tcx> {
|
|||||||
parts: InlineConstSubstsParts<'tcx, Ty<'tcx>>,
|
parts: InlineConstSubstsParts<'tcx, Ty<'tcx>>,
|
||||||
) -> InlineConstSubsts<'tcx> {
|
) -> InlineConstSubsts<'tcx> {
|
||||||
InlineConstSubsts {
|
InlineConstSubsts {
|
||||||
substs: tcx.mk_substs(
|
substs: tcx.mk_substs_from_iter(
|
||||||
parts.parent_substs.iter().copied().chain(std::iter::once(parts.ty.into())),
|
parts.parent_substs.iter().copied().chain(std::iter::once(parts.ty.into())),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -853,7 +853,7 @@ impl<'tcx> TraitRef<'tcx> {
|
|||||||
substs: SubstsRef<'tcx>,
|
substs: SubstsRef<'tcx>,
|
||||||
) -> ty::TraitRef<'tcx> {
|
) -> ty::TraitRef<'tcx> {
|
||||||
let defs = tcx.generics_of(trait_id);
|
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 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
|
|||||||
|
|
||||||
ty::ExistentialTraitRef {
|
ty::ExistentialTraitRef {
|
||||||
def_id: trait_ref.def_id,
|
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> {
|
pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::ExistentialTraitRef<'tcx> {
|
||||||
let def_id = tcx.parent(self.def_id);
|
let def_id = tcx.parent(self.def_id);
|
||||||
let subst_count = tcx.generics_of(def_id).count() - 1;
|
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 }
|
ty::ExistentialTraitRef { def_id, substs }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1579,7 +1579,7 @@ impl<'tcx> ExistentialProjection<'tcx> {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
def_id: projection_predicate.projection_ty.def_id,
|
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,
|
term: projection_predicate.term,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2209,7 +2209,7 @@ impl<'tcx> Ty<'tcx> {
|
|||||||
let assoc_items = tcx.associated_item_def_ids(
|
let assoc_items = tcx.associated_item_def_ids(
|
||||||
tcx.require_lang_item(hir::LangItem::DiscriminantKind, None),
|
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
|
ty::Bool
|
||||||
|
@ -71,7 +71,7 @@ impl<'tcx> List<Ty<'tcx>> {
|
|||||||
/// Allows to freely switch between `List<Ty<'tcx>>` and `List<GenericArg<'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
|
/// 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]
|
#[inline]
|
||||||
pub fn as_substs(&'tcx self) -> SubstsRef<'tcx> {
|
pub fn as_substs(&'tcx self) -> SubstsRef<'tcx> {
|
||||||
assert_eq!(TYPE_TAG, 0);
|
assert_eq!(TYPE_TAG, 0);
|
||||||
@ -319,7 +319,7 @@ impl<'tcx> InternalSubsts<'tcx> {
|
|||||||
let count = defs.count();
|
let count = defs.count();
|
||||||
let mut substs = SmallVec::with_capacity(count);
|
let mut substs = SmallVec::with_capacity(count);
|
||||||
Self::fill_item(&mut substs, tcx, defs, &mut mk_kind);
|
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>
|
pub fn extend_to<F>(&self, tcx: TyCtxt<'tcx>, def_id: DefId, mut mk_kind: F) -> SubstsRef<'tcx>
|
||||||
@ -468,11 +468,11 @@ impl<'tcx> InternalSubsts<'tcx> {
|
|||||||
target_substs: SubstsRef<'tcx>,
|
target_substs: SubstsRef<'tcx>,
|
||||||
) -> SubstsRef<'tcx> {
|
) -> SubstsRef<'tcx> {
|
||||||
let defs = tcx.generics_of(source_ancestor);
|
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> {
|
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 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for SubstsRef<'tcx> {
|
|||||||
// The match arms are in order of frequency. The 1, 2, and 0 cases are
|
// 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
|
// 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
|
// the substs, it's faster to reuse the existing substs rather than
|
||||||
// calling `intern_substs`.
|
// calling `mk_substs`.
|
||||||
match self.len() {
|
match self.len() {
|
||||||
1 => {
|
1 => {
|
||||||
let param0 = self[0].try_fold_with(folder)?;
|
let param0 = self[0].try_fold_with(folder)?;
|
||||||
if param0 == self[0] {
|
if param0 == self[0] {
|
||||||
Ok(self)
|
Ok(self)
|
||||||
} else {
|
} else {
|
||||||
Ok(folder.interner().intern_substs(&[param0]))
|
Ok(folder.interner().mk_substs(&[param0]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
2 => {
|
2 => {
|
||||||
@ -502,11 +502,11 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for SubstsRef<'tcx> {
|
|||||||
if param0 == self[0] && param1 == self[1] {
|
if param0 == self[0] && param1 == self[1] {
|
||||||
Ok(self)
|
Ok(self)
|
||||||
} else {
|
} else {
|
||||||
Ok(folder.interner().intern_substs(&[param0, param1]))
|
Ok(folder.interner().mk_substs(&[param0, param1]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0 => Ok(self),
|
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 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<Ty<'tcx>> {
|
|||||||
if param0 == self[0] && param1 == self[1] {
|
if param0 == self[0] && param1 == self[1] {
|
||||||
Ok(self)
|
Ok(self)
|
||||||
} else {
|
} 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)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,5 +112,5 @@ pub(super) fn vtable_allocation_provider<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
vtable.mutability = Mutability::Not;
|
vtable.mutability = Mutability::Not;
|
||||||
tcx.create_memory_alloc(tcx.intern_const_alloc(vtable))
|
tcx.create_memory_alloc(tcx.mk_const_alloc(vtable))
|
||||||
}
|
}
|
||||||
|
@ -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() => {
|
(ast::LitKind::Str(s, _), ty::Ref(_, inner_ty, _)) if inner_ty.is_str() => {
|
||||||
let s = s.as_str();
|
let s = s.as_str();
|
||||||
let allocation = Allocation::from_bytes_byte_aligned_immutable(s.as_bytes());
|
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() }
|
ConstValue::Slice { data: allocation, start: 0, end: s.len() }
|
||||||
}
|
}
|
||||||
(ast::LitKind::ByteStr(data, _), ty::Ref(_, inner_ty, _))
|
(ast::LitKind::ByteStr(data, _), ty::Ref(_, inner_ty, _))
|
||||||
if matches!(inner_ty.kind(), ty::Slice(_)) =>
|
if matches!(inner_ty.kind(), ty::Slice(_)) =>
|
||||||
{
|
{
|
||||||
let allocation = Allocation::from_bytes_byte_aligned_immutable(data as &[u8]);
|
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() }
|
ConstValue::Slice { data: allocation, start: 0, end: data.len() }
|
||||||
}
|
}
|
||||||
(ast::LitKind::ByteStr(data, _), ty::Ref(_, inner_ty, _)) if inner_ty.is_array() => {
|
(ast::LitKind::ByteStr(data, _), ty::Ref(_, inner_ty, _)) if inner_ty.is_array() => {
|
||||||
|
@ -170,7 +170,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
// Return the operand *tmp0 to be used as the call argument
|
// Return the operand *tmp0 to be used as the call argument
|
||||||
let place = Place {
|
let place = Place {
|
||||||
local: operand,
|
local: operand,
|
||||||
projection: tcx.intern_place_elems(&[PlaceElem::Deref]),
|
projection: tcx.mk_place_elems(&[PlaceElem::Deref]),
|
||||||
};
|
};
|
||||||
|
|
||||||
return block.and(Operand::Move(place));
|
return block.and(Operand::Move(place));
|
||||||
|
@ -263,7 +263,7 @@ impl<'tcx> PlaceBuilder<'tcx> {
|
|||||||
let resolved = self.resolve_upvar(cx);
|
let resolved = self.resolve_upvar(cx);
|
||||||
let builder = resolved.as_ref().unwrap_or(self);
|
let builder = resolved.as_ref().unwrap_or(self);
|
||||||
let PlaceBase::Local(local) = builder.base else { return None };
|
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 })
|
Some(Place { local, projection })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,7 +692,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
tcx.mk_imm_ref(tcx.lifetimes.re_erased, fake_borrow_deref_ty);
|
tcx.mk_imm_ref(tcx.lifetimes.re_erased, fake_borrow_deref_ty);
|
||||||
let fake_borrow_temp =
|
let fake_borrow_temp =
|
||||||
self.local_decls.push(LocalDecl::new(fake_borrow_ty, expr_span));
|
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(
|
self.cfg.push_assign(
|
||||||
block,
|
block,
|
||||||
source_info,
|
source_info,
|
||||||
|
@ -520,7 +520,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
let source_info = self.source_info(span);
|
let source_info = self.source_info(span);
|
||||||
let bool_ty = self.tcx.types.bool;
|
let bool_ty = self.tcx.types.bool;
|
||||||
if self.check_overflow && op.is_checkable() && ty.is_integral() {
|
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);
|
let result_value = self.temp(result_tup, span);
|
||||||
|
|
||||||
self.cfg.push_assign(
|
self.cfg.push_assign(
|
||||||
|
@ -1206,7 +1206,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
|
|
||||||
fake_borrows.insert(Place {
|
fake_borrows.insert(Place {
|
||||||
local: source.local,
|
local: source.local,
|
||||||
projection: self.tcx.intern_place_elems(proj_base),
|
projection: self.tcx.mk_place_elems(proj_base),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1743,7 +1743,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
.map(|matched_place_ref| {
|
.map(|matched_place_ref| {
|
||||||
let matched_place = Place {
|
let matched_place = Place {
|
||||||
local: matched_place_ref.local,
|
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_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);
|
let fake_borrow_ty = tcx.mk_imm_ref(tcx.lifetimes.re_erased, fake_borrow_deref_ty);
|
||||||
|
@ -859,7 +859,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
|
|
||||||
let use_place = Place {
|
let use_place = Place {
|
||||||
local: ty::CAPTURE_STRUCT_LOCAL,
|
local: ty::CAPTURE_STRUCT_LOCAL,
|
||||||
projection: tcx.intern_place_elems(&projs),
|
projection: tcx.mk_place_elems(&projs),
|
||||||
};
|
};
|
||||||
self.var_debug_info.push(VarDebugInfo {
|
self.var_debug_info.push(VarDebugInfo {
|
||||||
name: *sym,
|
name: *sym,
|
||||||
|
@ -307,7 +307,7 @@ impl<'tcx> Cx<'tcx> {
|
|||||||
|
|
||||||
let arg_tys = args.iter().map(|e| self.typeck_results().expr_ty_adjusted(e));
|
let arg_tys = args.iter().map(|e| self.typeck_results().expr_ty_adjusted(e));
|
||||||
let tupled_args = Expr {
|
let tupled_args = Expr {
|
||||||
ty: tcx.mk_tup(arg_tys),
|
ty: tcx.mk_tup_from_iter(arg_tys),
|
||||||
temp_lifetime,
|
temp_lifetime,
|
||||||
span: expr.span,
|
span: expr.span,
|
||||||
kind: ExprKind::Tuple { fields: self.mirror_exprs(args) },
|
kind: ExprKind::Tuple { fields: self.mirror_exprs(args) },
|
||||||
|
@ -133,9 +133,8 @@ impl<'tcx> Cx<'tcx> {
|
|||||||
bug!("closure expr does not have closure type: {:?}", closure_ty);
|
bug!("closure expr does not have closure type: {:?}", closure_ty);
|
||||||
};
|
};
|
||||||
|
|
||||||
let bound_vars = self
|
let bound_vars =
|
||||||
.tcx
|
self.tcx.mk_bound_variable_kinds(&[ty::BoundVariableKind::Region(ty::BrEnv)]);
|
||||||
.intern_bound_variable_kinds(&[ty::BoundVariableKind::Region(ty::BrEnv)]);
|
|
||||||
let br = ty::BoundRegion {
|
let br = ty::BoundRegion {
|
||||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||||
kind: ty::BrEnv,
|
kind: ty::BrEnv,
|
||||||
|
@ -126,7 +126,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
|||||||
BorrowedContent {
|
BorrowedContent {
|
||||||
target_place: Place {
|
target_place: Place {
|
||||||
local: place.local,
|
local: place.local,
|
||||||
projection: tcx.intern_place_elems(proj),
|
projection: tcx.mk_place_elems(proj),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
@ -165,7 +165,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
|||||||
if union_path.is_none() {
|
if union_path.is_none() {
|
||||||
base = self.add_move_path(base, elem, |tcx| Place {
|
base = self.add_move_path(base, elem, |tcx| Place {
|
||||||
local: place.local,
|
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 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
|||||||
// `ConstIndex` patterns. This is done to ensure that all move paths
|
// `ConstIndex` patterns. This is done to ensure that all move paths
|
||||||
// are disjoint, which is expected by drop elaboration.
|
// are disjoint, which is expected by drop elaboration.
|
||||||
let base_place =
|
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) {
|
let base_path = match self.move_path_for(base_place) {
|
||||||
Ok(path) => path,
|
Ok(path) => path,
|
||||||
Err(MoveError::UnionMove { path }) => {
|
Err(MoveError::UnionMove { path }) => {
|
||||||
|
@ -124,7 +124,7 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
|
|||||||
|
|
||||||
fn visit_place(&mut self, place: &mut Place<'tcx>, ctxt: PlaceContext, loc: 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) {
|
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 {
|
let observes_address = match ctxt {
|
||||||
|
@ -17,7 +17,7 @@ pub fn build_ptr_tys<'tcx>(
|
|||||||
unique_did: DefId,
|
unique_did: DefId,
|
||||||
nonnull_did: DefId,
|
nonnull_did: DefId,
|
||||||
) -> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>) {
|
) -> (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 unique_ty = tcx.type_of(unique_did).subst(tcx, substs);
|
||||||
let nonnull_ty = tcx.type_of(nonnull_did).subst(tcx, substs);
|
let nonnull_ty = tcx.type_of(nonnull_did).subst(tcx, substs);
|
||||||
let ptr_ty = tcx.mk_imm_ptr(pointee);
|
let ptr_ty = tcx.mk_imm_ptr(pointee);
|
||||||
@ -138,7 +138,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
|
|||||||
|
|
||||||
if let Some(mut new_projections) = new_projections {
|
if let Some(mut new_projections) = new_projections {
|
||||||
new_projections.extend_from_slice(&place.projection[last_deref..]);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ impl<'tcx> MutVisitor<'tcx> for DerefArgVisitor<'tcx> {
|
|||||||
place,
|
place,
|
||||||
Place {
|
Place {
|
||||||
local: SELF_ARG,
|
local: SELF_ARG,
|
||||||
projection: self.tcx().intern_place_elems(&[ProjectionElem::Deref]),
|
projection: self.tcx().mk_place_elems(&[ProjectionElem::Deref]),
|
||||||
},
|
},
|
||||||
self.tcx,
|
self.tcx,
|
||||||
);
|
);
|
||||||
@ -162,10 +162,9 @@ impl<'tcx> MutVisitor<'tcx> for PinArgVisitor<'tcx> {
|
|||||||
place,
|
place,
|
||||||
Place {
|
Place {
|
||||||
local: SELF_ARG,
|
local: SELF_ARG,
|
||||||
projection: self.tcx().intern_place_elems(&[ProjectionElem::Field(
|
projection: self
|
||||||
Field::new(0),
|
.tcx()
|
||||||
self.ref_gen_ty,
|
.mk_place_elems(&[ProjectionElem::Field(Field::new(0), self.ref_gen_ty)]),
|
||||||
)]),
|
|
||||||
},
|
},
|
||||||
self.tcx,
|
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();
|
let mut new_projection = new_base.projection.to_vec();
|
||||||
new_projection.append(&mut place.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);
|
const SELF_ARG: Local = Local::from_u32(1);
|
||||||
@ -300,7 +299,7 @@ impl<'tcx> TransformVisitor<'tcx> {
|
|||||||
let mut projection = base.projection.to_vec();
|
let mut projection = base.projection.to_vec();
|
||||||
projection.push(ProjectionElem::Field(Field::new(idx), ty));
|
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
|
// 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_did = tcx.require_lang_item(LangItem::Pin, Some(body.span));
|
||||||
let pin_adt_ref = tcx.adt_def(pin_did);
|
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);
|
let pin_ref_gen_ty = tcx.mk_adt(pin_adt_ref, substs);
|
||||||
|
|
||||||
// Replace the by ref generator argument
|
// Replace the by ref generator argument
|
||||||
@ -1450,13 +1449,13 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
|
|||||||
// Compute Poll<return_ty>
|
// Compute Poll<return_ty>
|
||||||
let poll_did = tcx.require_lang_item(LangItem::Poll, None);
|
let poll_did = tcx.require_lang_item(LangItem::Poll, None);
|
||||||
let poll_adt_ref = tcx.adt_def(poll_did);
|
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)
|
(poll_adt_ref, poll_substs)
|
||||||
} else {
|
} else {
|
||||||
// Compute GeneratorState<yield_ty, return_ty>
|
// Compute GeneratorState<yield_ty, return_ty>
|
||||||
let state_did = tcx.require_lang_item(LangItem::GeneratorState, None);
|
let state_did = tcx.require_lang_item(LangItem::GeneratorState, None);
|
||||||
let state_adt_ref = tcx.adt_def(state_did);
|
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)
|
(state_adt_ref, state_substs)
|
||||||
};
|
};
|
||||||
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);
|
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);
|
||||||
|
@ -888,7 +888,7 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> {
|
|||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
if let ProjectionElem::Field(f, ty) = elem {
|
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 parent_ty = parent.ty(&self.callee_body.local_decls, self.tcx);
|
||||||
let check_equal = |this: &mut Self, f_ty| {
|
let check_equal = |this: &mut Self, f_ty| {
|
||||||
if !util::is_equal_up_to_subtyping(this.tcx, this.param_env, ty, f_ty) {
|
if !util::is_equal_up_to_subtyping(this.tcx, this.param_env, ty, f_ty) {
|
||||||
|
@ -121,7 +121,7 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
|
|||||||
|
|
||||||
*rvalue = Rvalue::Use(Operand::Copy(Place {
|
*rvalue = Rvalue::Use(Operand::Copy(Place {
|
||||||
local: base.local,
|
local: base.local,
|
||||||
projection: self.tcx.intern_place_elems(base.projection),
|
projection: self.tcx.mk_place_elems(base.projection),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ impl EnumSizeOpt {
|
|||||||
tcx.data_layout.ptr_sized_integer().align(&tcx.data_layout).abi,
|
tcx.data_layout.ptr_sized_integer().align(&tcx.data_layout).abi,
|
||||||
Mutability::Not,
|
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)))
|
Some((*adt_def, num_discrs, *alloc_cache.entry(ty).or_insert(alloc)))
|
||||||
}
|
}
|
||||||
fn optim<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
fn optim<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||||
@ -197,9 +197,8 @@ impl EnumSizeOpt {
|
|||||||
size_place,
|
size_place,
|
||||||
Rvalue::Use(Operand::Copy(Place {
|
Rvalue::Use(Operand::Copy(Place {
|
||||||
local: size_array_local,
|
local: size_array_local,
|
||||||
projection: tcx.intern_place_elems(&[PlaceElem::Index(
|
projection: tcx
|
||||||
discr_cast_place.local,
|
.mk_place_elems(&[PlaceElem::Index(discr_cast_place.local)]),
|
||||||
)]),
|
|
||||||
})),
|
})),
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
|
@ -192,7 +192,7 @@ fn remap_mir_for_const_eval_select<'tcx>(
|
|||||||
let arguments = (0..num_args).map(|x| {
|
let arguments = (0..num_args).map(|x| {
|
||||||
let mut place_elems = place_elems.to_vec();
|
let mut place_elems = place_elems.to_vec();
|
||||||
place_elems.push(ProjectionElem::Field(x.into(), fields[x]));
|
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 {
|
let place = Place {
|
||||||
local: place.local,
|
local: place.local,
|
||||||
projection,
|
projection,
|
||||||
|
@ -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()));
|
assert!(!matches!(ty, Some(ty) if ty.is_generator()));
|
||||||
|
|
||||||
let substs = if let Some(ty) = ty {
|
let substs = if let Some(ty) = ty {
|
||||||
tcx.intern_substs(&[ty.into()])
|
tcx.mk_substs(&[ty.into()])
|
||||||
} else {
|
} else {
|
||||||
InternalSubsts::identity_for_item(tcx, def_id)
|
InternalSubsts::identity_for_item(tcx, def_id)
|
||||||
};
|
};
|
||||||
@ -597,7 +597,7 @@ fn build_call_shim<'tcx>(
|
|||||||
let untuple_args = sig.inputs();
|
let untuple_args = sig.inputs();
|
||||||
|
|
||||||
// Create substitutions for the `Self` and `Args` generic parameters of the shim body.
|
// 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))
|
(Some([ty.into(), arg_tup.into()]), Some(untuple_args))
|
||||||
} else {
|
} else {
|
||||||
@ -632,7 +632,7 @@ fn build_call_shim<'tcx>(
|
|||||||
Adjustment::Deref => tcx.mk_imm_ptr(fnty),
|
Adjustment::Deref => tcx.mk_imm_ptr(fnty),
|
||||||
Adjustment::RefMut => tcx.mk_mut_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
|
// 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];
|
let self_arg = &mut inputs_and_output[0];
|
||||||
debug_assert!(tcx.generics_of(def_id).has_self && *self_arg == tcx.types.self_param);
|
debug_assert!(tcx.generics_of(def_id).has_self && *self_arg == tcx.types.self_param);
|
||||||
*self_arg = tcx.mk_mut_ptr(*self_arg);
|
*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);
|
let span = tcx.def_span(def_id);
|
||||||
|
@ -122,7 +122,7 @@ impl<'tcx> ReplacementMap<'tcx> {
|
|||||||
let &[PlaceElem::Field(f, _), ref rest @ ..] = place.projection else { return None; };
|
let &[PlaceElem::Field(f, _), ref rest @ ..] = place.projection else { return None; };
|
||||||
let fields = self.fragments[place.local].as_ref()?;
|
let fields = self.fragments[place.local].as_ref()?;
|
||||||
let (_, new_local) = fields[f]?;
|
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(
|
fn place_fragments(
|
||||||
|
@ -1298,7 +1298,7 @@ impl<'v> RootCollector<'_, 'v> {
|
|||||||
self.tcx,
|
self.tcx,
|
||||||
ty::ParamEnv::reveal_all(),
|
ty::ParamEnv::reveal_all(),
|
||||||
start_def_id,
|
start_def_id,
|
||||||
self.tcx.intern_substs(&[main_ret_ty.into()]),
|
self.tcx.mk_substs(&[main_ret_ty.into()]),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -675,7 +675,7 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
|
|||||||
_ if ty.is_unit() => {}
|
_ if ty.is_unit() => {}
|
||||||
|
|
||||||
ty::Tuple(tys) => {
|
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) => {
|
ty::Array(ty0, len) => {
|
||||||
@ -825,7 +825,7 @@ fn transform_substs<'tcx>(
|
|||||||
subst
|
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
|
/// Returns a type metadata identifier for the specified FnAbi using the Itanium C++ ABI with vendor
|
||||||
|
@ -567,7 +567,7 @@ fn compute_external_query_constraints<'tcx>(
|
|||||||
) -> Result<ExternalConstraints<'tcx>, NoSolution> {
|
) -> Result<ExternalConstraints<'tcx>, NoSolution> {
|
||||||
let region_obligations = infcx.take_registered_region_obligations();
|
let region_obligations = infcx.take_registered_region_obligations();
|
||||||
let opaque_types = infcx.take_opaque_types_for_query_response();
|
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 :)
|
// FIXME: Now that's definitely wrong :)
|
||||||
//
|
//
|
||||||
// Should also do the leak check here I think
|
// 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),
|
var_values: CanonicalVarValues::make_identity(tcx, goal.variables),
|
||||||
// FIXME: maybe we should store the "no response" version in tcx, like
|
// FIXME: maybe we should store the "no response" version in tcx, like
|
||||||
// we do for tcx.types and stuff.
|
// we do for tcx.types and stuff.
|
||||||
external_constraints: tcx
|
external_constraints: tcx.mk_external_constraints(ExternalConstraintsData::default()),
|
||||||
.intern_external_constraints(ExternalConstraintsData::default()),
|
|
||||||
certainty,
|
certainty,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -343,9 +343,10 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
|||||||
// Substitute just the unsizing params from B into A. The type after
|
// 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
|
// this substitution must be equal to B. This is so we don't unsize
|
||||||
// unrelated type parameters.
|
// unrelated type parameters.
|
||||||
let new_a_substs = tcx.mk_substs(a_substs.iter().enumerate().map(|(i, a)| {
|
let new_a_substs =
|
||||||
if unsizing_params.contains(i as u32) { b_substs[i] } else { a }
|
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);
|
let unsized_a_ty = tcx.mk_adt(a_def, new_a_substs);
|
||||||
|
|
||||||
// Finally, we require that `TailA: Unsize<TailB>` for the tail field
|
// Finally, we require that `TailA: Unsize<TailB>` for the tail field
|
||||||
@ -368,7 +369,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
|||||||
let b_last_ty = b_tys.last().unwrap();
|
let b_last_ty = b_tys.last().unwrap();
|
||||||
|
|
||||||
// Substitute just the tail field of B., and require that they're equal.
|
// 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)?;
|
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.
|
// Similar to ADTs, require that the rest of the fields are equal.
|
||||||
@ -425,7 +427,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
|||||||
.map(ty::ExistentialPredicate::AutoTrait)
|
.map(ty::ExistentialPredicate::AutoTrait)
|
||||||
.map(ty::Binder::dummy),
|
.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);
|
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.
|
// We also require that A's lifetime outlives B's lifetime.
|
||||||
|
@ -189,11 +189,9 @@ pub(crate) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
|
|||||||
ty::FnDef(def_id, substs) => Ok(Some(
|
ty::FnDef(def_id, substs) => Ok(Some(
|
||||||
tcx.fn_sig(def_id)
|
tcx.fn_sig(def_id)
|
||||||
.subst(tcx, substs)
|
.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) => {
|
ty::FnPtr(sig) => Ok(Some(sig.map_bound(|sig| (tcx.mk_tup(sig.inputs()), sig.output())))),
|
||||||
Ok(Some(sig.map_bound(|sig| (tcx.intern_tup(sig.inputs()), sig.output()))))
|
|
||||||
}
|
|
||||||
ty::Closure(_, substs) => {
|
ty::Closure(_, substs) => {
|
||||||
let closure_substs = substs.as_closure();
|
let closure_substs = substs.as_closure();
|
||||||
match closure_substs.kind_ty().to_opt_closure_kind() {
|
match closure_substs.kind_ty().to_opt_closure_kind() {
|
||||||
|
@ -350,14 +350,14 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||||||
)
|
)
|
||||||
.map(|o| o.predicate);
|
.map(|o| o.predicate);
|
||||||
new_env = ty::ParamEnv::new(
|
new_env = ty::ParamEnv::new(
|
||||||
tcx.mk_predicates(normalized_preds),
|
tcx.mk_predicates_from_iter(normalized_preds),
|
||||||
param_env.reveal(),
|
param_env.reveal(),
|
||||||
param_env.constness(),
|
param_env.constness(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let final_user_env = ty::ParamEnv::new(
|
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.reveal(),
|
||||||
user_env.constness(),
|
user_env.constness(),
|
||||||
);
|
);
|
||||||
|
@ -281,7 +281,7 @@ pub fn normalize_param_env_or_error<'tcx>(
|
|||||||
debug!("normalize_param_env_or_error: elaborated-predicates={:?}", predicates);
|
debug!("normalize_param_env_or_error: elaborated-predicates={:?}", predicates);
|
||||||
|
|
||||||
let elaborated_env = ty::ParamEnv::new(
|
let elaborated_env = ty::ParamEnv::new(
|
||||||
tcx.intern_predicates(&predicates),
|
tcx.mk_predicates(&predicates),
|
||||||
unnormalized_env.reveal(),
|
unnormalized_env.reveal(),
|
||||||
unnormalized_env.constness(),
|
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
|
// 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
|
// 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.
|
// predicates here anyway. Keeping them here anyway because it seems safer.
|
||||||
let outlives_env: Vec<_> =
|
let outlives_env = non_outlives_predicates.iter().chain(&outlives_predicates).cloned();
|
||||||
non_outlives_predicates.iter().chain(&outlives_predicates).cloned().collect();
|
|
||||||
let outlives_env = ty::ParamEnv::new(
|
let outlives_env = ty::ParamEnv::new(
|
||||||
tcx.intern_predicates(&outlives_env),
|
tcx.mk_predicates_from_iter(outlives_env),
|
||||||
unnormalized_env.reveal(),
|
unnormalized_env.reveal(),
|
||||||
unnormalized_env.constness(),
|
unnormalized_env.constness(),
|
||||||
);
|
);
|
||||||
@ -356,7 +355,7 @@ pub fn normalize_param_env_or_error<'tcx>(
|
|||||||
predicates.extend(outlives_predicates);
|
predicates.extend(outlives_predicates);
|
||||||
debug!("normalize_param_env_or_error: final predicates={:?}", predicates);
|
debug!("normalize_param_env_or_error: final predicates={:?}", predicates);
|
||||||
ty::ParamEnv::new(
|
ty::ParamEnv::new(
|
||||||
tcx.intern_predicates(&predicates),
|
tcx.mk_predicates(&predicates),
|
||||||
unnormalized_env.reveal(),
|
unnormalized_env.reveal(),
|
||||||
unnormalized_env.constness(),
|
unnormalized_env.constness(),
|
||||||
)
|
)
|
||||||
|
@ -18,10 +18,10 @@ use rustc_errors::{DelayDm, FatalError, MultiSpan};
|
|||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_middle::ty::subst::{GenericArg, InternalSubsts};
|
use rustc_middle::ty::subst::{GenericArg, InternalSubsts};
|
||||||
|
use rustc_middle::ty::ToPredicate;
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor,
|
self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor,
|
||||||
};
|
};
|
||||||
use rustc_middle::ty::{Predicate, ToPredicate};
|
|
||||||
use rustc_session::lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY;
|
use rustc_session::lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY;
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::Span;
|
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.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder()));
|
||||||
elaborated_predicates.dedup();
|
elaborated_predicates.dedup();
|
||||||
|
|
||||||
let existential_predicates = tcx
|
let existential_predicates = tcx.mk_poly_existential_predicates_from_iter(
|
||||||
.mk_poly_existential_predicates(iter::once(trait_predicate).chain(elaborated_predicates));
|
iter::once(trait_predicate).chain(elaborated_predicates),
|
||||||
|
);
|
||||||
debug!(?existential_predicates);
|
debug!(?existential_predicates);
|
||||||
|
|
||||||
tcx.mk_dynamic(existential_predicates, lifetime, ty::Dyn)
|
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)
|
ty::Binder::dummy(tcx.mk_trait_ref(trait_def_id, substs)).to_predicate(tcx)
|
||||||
};
|
};
|
||||||
|
|
||||||
let caller_bounds: Vec<Predicate<'tcx>> =
|
let caller_bounds =
|
||||||
param_env.caller_bounds().iter().chain([unsize_predicate, trait_predicate]).collect();
|
param_env.caller_bounds().iter().chain([unsize_predicate, trait_predicate]);
|
||||||
|
|
||||||
ty::ParamEnv::new(
|
ty::ParamEnv::new(
|
||||||
tcx.intern_predicates(&caller_bounds),
|
tcx.mk_predicates_from_iter(caller_bounds),
|
||||||
param_env.reveal(),
|
param_env.reveal(),
|
||||||
param_env.constness(),
|
param_env.constness(),
|
||||||
)
|
)
|
||||||
|
@ -1906,7 +1906,7 @@ fn confirm_builtin_candidate<'cx, 'tcx>(
|
|||||||
) -> Progress<'tcx> {
|
) -> Progress<'tcx> {
|
||||||
let tcx = selcx.tcx();
|
let tcx = selcx.tcx();
|
||||||
let self_ty = obligation.predicate.self_ty();
|
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 lang_items = tcx.lang_items();
|
||||||
let item_def_id = obligation.predicate.def_id;
|
let item_def_id = obligation.predicate.def_id;
|
||||||
let trait_def_id = tcx.trait_of_item(item_def_id).unwrap();
|
let trait_def_id = tcx.trait_of_item(item_def_id).unwrap();
|
||||||
|
@ -564,8 +564,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let bound_vars = tcx.intern_bound_variable_kinds(&bound_vars);
|
let bound_vars = tcx.mk_bound_variable_kinds(&bound_vars);
|
||||||
let assoc_ty_substs = tcx.intern_substs(&substs);
|
let assoc_ty_substs = tcx.mk_substs(&substs);
|
||||||
let bound =
|
let bound =
|
||||||
bound.map_bound(|b| b.kind().skip_binder()).subst(tcx, assoc_ty_substs);
|
bound.map_bound(|b| b.kind().skip_binder()).subst(tcx, assoc_ty_substs);
|
||||||
tcx.mk_predicate(ty::Binder::bind_with_vars(bound, bound_vars))
|
tcx.mk_predicate(ty::Binder::bind_with_vars(bound, bound_vars))
|
||||||
@ -880,7 +880,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
.map(ty::ExistentialPredicate::AutoTrait)
|
.map(ty::ExistentialPredicate::AutoTrait)
|
||||||
.map(ty::Binder::dummy),
|
.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);
|
let source_trait = tcx.mk_dynamic(existential_predicates, r_b, repr_a);
|
||||||
|
|
||||||
// Require that the traits involved in this upcast are **equal**;
|
// Require that the traits involved in this upcast are **equal**;
|
||||||
@ -979,7 +979,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
.map(ty::ExistentialPredicate::AutoTrait)
|
.map(ty::ExistentialPredicate::AutoTrait)
|
||||||
.map(ty::Binder::dummy),
|
.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);
|
let source_trait = tcx.mk_dynamic(existential_predicates, r_b, dyn_a);
|
||||||
|
|
||||||
// Require that the traits involved in this upcast are **equal**;
|
// Require that the traits involved in this upcast are **equal**;
|
||||||
@ -1099,7 +1099,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
|
|
||||||
// Check that the source struct with the target's
|
// Check that the source struct with the target's
|
||||||
// unsizing parameters is equal to the target.
|
// 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 }
|
if unsizing_params.contains(i as u32) { substs_b[i] } else { k }
|
||||||
}));
|
}));
|
||||||
let new_struct = tcx.mk_adt(def, substs);
|
let new_struct = tcx.mk_adt(def, substs);
|
||||||
@ -1131,7 +1131,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
|
|
||||||
// Check that the source tuple with the target's
|
// Check that the source tuple with the target's
|
||||||
// last element is equal to the target.
|
// 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
|
let InferOk { obligations, .. } = self
|
||||||
.infcx
|
.infcx
|
||||||
.at(&obligation.cause, obligation.param_env)
|
.at(&obligation.cause, obligation.param_env)
|
||||||
|
@ -2230,7 +2230,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// (*) binder moved here
|
// (*) 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()),
|
obligation.predicate.bound_vars().iter().chain(binder.bound_vars().iter()),
|
||||||
);
|
);
|
||||||
Where(ty::Binder::bind_with_vars(witness_tys.to_vec(), all_vars))
|
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 {
|
if considering_regions {
|
||||||
debug_assert!(!hidden_types.has_erased_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))),
|
(num_bound_variables..counter).map(|i| ty::BoundVariableKind::Region(ty::BrAnon(i, None))),
|
||||||
));
|
));
|
||||||
ty::Binder::bind_with_vars(hidden_types, bound_vars)
|
ty::Binder::bind_with_vars(hidden_types, bound_vars)
|
||||||
|
@ -292,7 +292,7 @@ pub fn closure_trait_ref_and_return_type<'tcx>(
|
|||||||
assert!(!self_ty.has_escaping_bound_vars());
|
assert!(!self_ty.has_escaping_bound_vars());
|
||||||
let arguments_tuple = match tuple_arguments {
|
let arguments_tuple = match tuple_arguments {
|
||||||
TupleArgumentsFlag::No => sig.skip_binder().inputs()[0],
|
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]);
|
let trait_ref = tcx.mk_trait_ref(fn_trait_def_id, [self_ty, arguments_tuple]);
|
||||||
sig.map_bound(|sig| (trait_ref, sig.output()))
|
sig.map_bound(|sig| (trait_ref, sig.output()))
|
||||||
|
@ -62,7 +62,9 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Substitution<RustInterner<'tcx>>> for Subst
|
|||||||
|
|
||||||
impl<'tcx> LowerInto<'tcx, SubstsRef<'tcx>> for &chalk_ir::Substitution<RustInterner<'tcx>> {
|
impl<'tcx> LowerInto<'tcx, SubstsRef<'tcx>> for &chalk_ir::Substitution<RustInterner<'tcx>> {
|
||||||
fn lower_into(self, interner: RustInterner<'tcx>) -> SubstsRef<'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)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ pub(crate) fn evaluate_goal<'tcx>(
|
|||||||
use rustc_middle::infer::canonical::CanonicalVarInfo;
|
use rustc_middle::infer::canonical::CanonicalVarInfo;
|
||||||
|
|
||||||
let mut reverse_param_substitutor = ReverseParamsSubstitutor::new(tcx, params);
|
let mut reverse_param_substitutor = ReverseParamsSubstitutor::new(tcx, params);
|
||||||
let var_values = tcx.mk_substs(
|
let var_values = tcx.mk_substs_from_iter(
|
||||||
subst
|
subst
|
||||||
.as_slice(interner)
|
.as_slice(interner)
|
||||||
.iter()
|
.iter()
|
||||||
@ -126,7 +126,7 @@ pub(crate) fn evaluate_goal<'tcx>(
|
|||||||
let max_universe = binders.iter(interner).map(|v| v.skip_kind().counter).max().unwrap_or(0);
|
let max_universe = binders.iter(interner).map(|v| v.skip_kind().counter).max().unwrap_or(0);
|
||||||
let sol = Canonical {
|
let sol = Canonical {
|
||||||
max_universe: ty::UniverseIndex::from_usize(max_universe),
|
max_universe: ty::UniverseIndex::from_usize(max_universe),
|
||||||
variables: tcx.intern_canonical_var_infos(&variables),
|
variables: tcx.mk_canonical_var_infos(&variables),
|
||||||
value: QueryResponse {
|
value: QueryResponse {
|
||||||
var_values: CanonicalVarValues { var_values },
|
var_values: CanonicalVarValues { var_values },
|
||||||
region_constraints: QueryRegionConstraints::default(),
|
region_constraints: QueryRegionConstraints::default(),
|
||||||
|
@ -54,7 +54,7 @@ fn fn_sig_for_fn_abi<'tcx>(
|
|||||||
sig = sig.map_bound(|mut sig| {
|
sig = sig.map_bound(|mut sig| {
|
||||||
let mut inputs_and_output = sig.inputs_and_output.to_vec();
|
let mut inputs_and_output = sig.inputs_and_output.to_vec();
|
||||||
inputs_and_output[0] = tcx.mk_mut_ptr(inputs_and_output[0]);
|
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
|
sig
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ fn fn_sig_for_fn_abi<'tcx>(
|
|||||||
ty::Closure(def_id, substs) => {
|
ty::Closure(def_id, substs) => {
|
||||||
let sig = substs.as_closure().sig();
|
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))),
|
sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
|
||||||
);
|
);
|
||||||
let br = ty::BoundRegion {
|
let br = ty::BoundRegion {
|
||||||
@ -88,7 +88,7 @@ fn fn_sig_for_fn_abi<'tcx>(
|
|||||||
ty::Generator(did, substs, _) => {
|
ty::Generator(did, substs, _) => {
|
||||||
let sig = substs.as_generator().poly_sig();
|
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))),
|
sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
|
||||||
);
|
);
|
||||||
let br = ty::BoundRegion {
|
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_did = tcx.require_lang_item(LangItem::Pin, None);
|
||||||
let pin_adt_ref = tcx.adt_def(pin_did);
|
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 env_ty = tcx.mk_adt(pin_adt_ref, pin_substs);
|
||||||
|
|
||||||
let sig = sig.skip_binder();
|
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>`
|
// The signature should be `Future::poll(_, &mut Context<'_>) -> Poll<Output>`
|
||||||
let poll_did = tcx.require_lang_item(LangItem::Poll, None);
|
let poll_did = tcx.require_lang_item(LangItem::Poll, None);
|
||||||
let poll_adt_ref = tcx.adt_def(poll_did);
|
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);
|
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
|
// 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>`
|
// The signature should be `Generator::resume(_, Resume) -> GeneratorState<Yield, Return>`
|
||||||
let state_did = tcx.require_lang_item(LangItem::GeneratorState, None);
|
let state_did = tcx.require_lang_item(LangItem::GeneratorState, None);
|
||||||
let state_adt_ref = tcx.adt_def(state_did);
|
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);
|
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);
|
||||||
|
|
||||||
(sig.resume_ty, ret_ty)
|
(sig.resume_ty, ret_ty)
|
||||||
|
@ -144,7 +144,7 @@ fn recurse_build<'tcx>(
|
|||||||
for &id in args.iter() {
|
for &id in args.iter() {
|
||||||
new_args.push(recurse_build(tcx, body, id, root_span)?);
|
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)
|
tcx.mk_const(Expr::FunctionCall(fun, new_args), node.ty)
|
||||||
}
|
}
|
||||||
&ExprKind::Binary { op, lhs, rhs } if check_binop(op) => {
|
&ExprKind::Binary { op, lhs, rhs } if check_binop(op) => {
|
||||||
|
@ -19,16 +19,16 @@ fn assumed_wf_types(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List<Ty<'_>> {
|
|||||||
let mut assumed_wf_types: Vec<_> =
|
let mut assumed_wf_types: Vec<_> =
|
||||||
tcx.assumed_wf_types(tcx.parent(def_id)).as_slice().into();
|
tcx.assumed_wf_types(tcx.parent(def_id)).as_slice().into();
|
||||||
assumed_wf_types.extend(liberated_sig.inputs_and_output);
|
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 { .. } => {
|
DefKind::Impl { .. } => {
|
||||||
match tcx.impl_trait_ref(def_id) {
|
match tcx.impl_trait_ref(def_id) {
|
||||||
Some(trait_ref) => {
|
Some(trait_ref) => {
|
||||||
let types: Vec<_> = trait_ref.skip_binder().substs.types().collect();
|
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
|
// 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)),
|
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
Loading…
Reference in New Issue
Block a user