mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Overhaul TyS
and Ty
.
Specifically, change `Ty` from this: ``` pub type Ty<'tcx> = &'tcx TyS<'tcx>; ``` to this ``` pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>); ``` There are two benefits to this. - It's now a first class type, so we can define methods on it. This means we can move a lot of methods away from `TyS`, leaving `TyS` as a barely-used type, which is appropriate given that it's not meant to be used directly. - The uniqueness requirement is now explicit, via the `Interned` type. E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather than via `TyS`, which wasn't obvious at all. Much of this commit is boring churn. The interesting changes are in these files: - compiler/rustc_middle/src/arena.rs - compiler/rustc_middle/src/mir/visit.rs - compiler/rustc_middle/src/ty/context.rs - compiler/rustc_middle/src/ty/mod.rs Specifically: - Most mentions of `TyS` are removed. It's very much a dumb struct now; `Ty` has all the smarts. - `TyS` now has `crate` visibility instead of `pub`. - `TyS::make_for_test` is removed in favour of the static `BOOL_TY`, which just works better with the new structure. - The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned` (pointer-based, for the `Equal` case) and partly on `TyS` (contents-based, for the other cases). - There are many tedious sigil adjustments, i.e. adding or removing `*` or `&`. They seem to be unavoidable.
This commit is contained in:
parent
0c2ebbd412
commit
e9a0c429c5
@ -2324,7 +2324,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
// This is also case 2 from above but for functions, return type is still an
|
||||
// anonymous reference so we select the first argument.
|
||||
let argument_span = fn_decl.inputs.first()?.span;
|
||||
let argument_ty = sig.inputs().skip_binder().first()?;
|
||||
let argument_ty = *sig.inputs().skip_binder().first()?;
|
||||
|
||||
let return_span = fn_decl.output.span();
|
||||
let return_ty = sig.output().skip_binder();
|
||||
@ -2379,27 +2379,27 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
|
||||
diag: &mut DiagnosticBuilder<'_>,
|
||||
) -> String {
|
||||
match self {
|
||||
AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => {
|
||||
&AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => {
|
||||
diag.span_label(
|
||||
*argument_span,
|
||||
argument_span,
|
||||
format!("has type `{}`", cx.get_name_for_ty(argument_ty, 0)),
|
||||
);
|
||||
|
||||
cx.get_region_name_for_ty(argument_ty, 0)
|
||||
}
|
||||
AnnotatedBorrowFnSignature::AnonymousFunction {
|
||||
&AnnotatedBorrowFnSignature::AnonymousFunction {
|
||||
argument_ty,
|
||||
argument_span,
|
||||
return_ty,
|
||||
return_span,
|
||||
} => {
|
||||
let argument_ty_name = cx.get_name_for_ty(argument_ty, 0);
|
||||
diag.span_label(*argument_span, format!("has type `{}`", argument_ty_name));
|
||||
diag.span_label(argument_span, format!("has type `{}`", argument_ty_name));
|
||||
|
||||
let return_ty_name = cx.get_name_for_ty(return_ty, 0);
|
||||
let types_equal = return_ty_name == argument_ty_name;
|
||||
diag.span_label(
|
||||
*return_span,
|
||||
return_span,
|
||||
format!(
|
||||
"{}has type `{}`",
|
||||
if types_equal { "also " } else { "" },
|
||||
@ -2419,7 +2419,7 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
|
||||
}
|
||||
AnnotatedBorrowFnSignature::NamedFunction { arguments, return_ty, return_span } => {
|
||||
// Region of return type and arguments checked to be the same earlier.
|
||||
let region_name = cx.get_region_name_for_ty(return_ty, 0);
|
||||
let region_name = cx.get_region_name_for_ty(*return_ty, 0);
|
||||
for (_, argument_span) in arguments {
|
||||
diag.span_label(*argument_span, format!("has lifetime `{}`", region_name));
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
match place {
|
||||
PlaceRef { local, projection: [] } => {
|
||||
let local = &self.body.local_decls[local];
|
||||
self.describe_field_from_ty(&local.ty, field, None)
|
||||
self.describe_field_from_ty(local.ty, field, None)
|
||||
}
|
||||
PlaceRef { local, projection: [proj_base @ .., elem] } => match elem {
|
||||
ProjectionElem::Deref => {
|
||||
@ -339,10 +339,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
}
|
||||
ProjectionElem::Downcast(_, variant_index) => {
|
||||
let base_ty = place.ty(self.body, self.infcx.tcx).ty;
|
||||
self.describe_field_from_ty(&base_ty, field, Some(*variant_index))
|
||||
self.describe_field_from_ty(base_ty, field, Some(*variant_index))
|
||||
}
|
||||
ProjectionElem::Field(_, field_type) => {
|
||||
self.describe_field_from_ty(&field_type, field, None)
|
||||
self.describe_field_from_ty(*field_type, field, None)
|
||||
}
|
||||
ProjectionElem::Index(..)
|
||||
| ProjectionElem::ConstantIndex { .. }
|
||||
@ -362,7 +362,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
) -> String {
|
||||
if ty.is_box() {
|
||||
// If the type is a box, the field is described from the boxed type
|
||||
self.describe_field_from_ty(&ty.boxed_ty(), field, variant_index)
|
||||
self.describe_field_from_ty(ty.boxed_ty(), field, variant_index)
|
||||
} else {
|
||||
match *ty.kind() {
|
||||
ty::Adt(def, _) => {
|
||||
@ -376,10 +376,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
}
|
||||
ty::Tuple(_) => field.index().to_string(),
|
||||
ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => {
|
||||
self.describe_field_from_ty(&ty, field, variant_index)
|
||||
self.describe_field_from_ty(ty, field, variant_index)
|
||||
}
|
||||
ty::Array(ty, _) | ty::Slice(ty) => {
|
||||
self.describe_field_from_ty(&ty, field, variant_index)
|
||||
self.describe_field_from_ty(ty, field, variant_index)
|
||||
}
|
||||
ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => {
|
||||
// We won't be borrowck'ing here if the closure came from another crate,
|
||||
|
@ -246,18 +246,18 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
);
|
||||
(
|
||||
match kind {
|
||||
IllegalMoveOriginKind::BorrowedContent { target_place } => self
|
||||
&IllegalMoveOriginKind::BorrowedContent { target_place } => self
|
||||
.report_cannot_move_from_borrowed_content(
|
||||
original_path,
|
||||
*target_place,
|
||||
target_place,
|
||||
span,
|
||||
use_spans,
|
||||
),
|
||||
IllegalMoveOriginKind::InteriorOfTypeWithDestructor { container_ty: ty } => {
|
||||
&IllegalMoveOriginKind::InteriorOfTypeWithDestructor { container_ty: ty } => {
|
||||
self.cannot_move_out_of_interior_of_drop(span, ty)
|
||||
}
|
||||
IllegalMoveOriginKind::InteriorOfSliceOrArray { ty, is_index } => {
|
||||
self.cannot_move_out_of_interior_noncopy(span, ty, Some(*is_index))
|
||||
&IllegalMoveOriginKind::InteriorOfSliceOrArray { ty, is_index } => {
|
||||
self.cannot_move_out_of_interior_noncopy(span, ty, Some(is_index))
|
||||
}
|
||||
},
|
||||
span,
|
||||
|
@ -500,7 +500,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
||||
}
|
||||
|
||||
// Otherwise, let's descend into the referent types.
|
||||
search_stack.push((referent_ty, &referent_hir_ty.ty));
|
||||
search_stack.push((*referent_ty, &referent_hir_ty.ty));
|
||||
}
|
||||
|
||||
// Match up something like `Foo<'1>`
|
||||
@ -539,7 +539,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
||||
|
||||
(ty::Slice(elem_ty), hir::TyKind::Slice(elem_hir_ty))
|
||||
| (ty::Array(elem_ty, _), hir::TyKind::Array(elem_hir_ty, _)) => {
|
||||
search_stack.push((elem_ty, elem_hir_ty));
|
||||
search_stack.push((*elem_ty, elem_hir_ty));
|
||||
}
|
||||
|
||||
(ty::RawPtr(mut_ty), hir::TyKind::Ptr(mut_hir_ty)) => {
|
||||
|
@ -1169,7 +1169,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
|
||||
match verify_bound {
|
||||
VerifyBound::IfEq(test_ty, verify_bound1) => {
|
||||
self.eval_if_eq(tcx, body, generic_ty, lower_bound, test_ty, verify_bound1)
|
||||
self.eval_if_eq(tcx, body, generic_ty, lower_bound, *test_ty, verify_bound1)
|
||||
}
|
||||
|
||||
VerifyBound::IsEmpty => {
|
||||
|
@ -57,7 +57,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
|
||||
*ty = self.renumber_regions(ty);
|
||||
*ty = self.renumber_regions(*ty);
|
||||
|
||||
debug!(?ty);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
|
||||
// create new region variables, which can't be done later when
|
||||
// verifying these bounds.
|
||||
if t1.has_placeholders() {
|
||||
t1 = tcx.fold_regions(&t1, &mut false, |r, _| match *r {
|
||||
t1 = tcx.fold_regions(t1, &mut false, |r, _| match *r {
|
||||
ty::RegionKind::RePlaceholder(placeholder) => {
|
||||
self.constraints.placeholder_region(self.infcx, placeholder)
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
|
||||
// then remove the outermost reference so we can check the
|
||||
// type annotation for the remaining type.
|
||||
if let ty::Ref(_, rty, _) = local_decl.ty.kind() {
|
||||
rty
|
||||
*rty
|
||||
} else {
|
||||
bug!("{:?} with ref binding has wrong type {}", local, local_decl.ty);
|
||||
}
|
||||
@ -716,7 +716,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
|
||||
PlaceTy::from_ty(match base_ty.kind() {
|
||||
ty::Array(inner, _) => {
|
||||
assert!(!from_end, "array subslices should not use from_end");
|
||||
tcx.mk_array(inner, to - from)
|
||||
tcx.mk_array(*inner, to - from)
|
||||
}
|
||||
ty::Slice(..) => {
|
||||
assert!(from_end, "slice subslices should use from_end");
|
||||
@ -1737,7 +1737,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
ConstraintCategory::Boring
|
||||
};
|
||||
if let Err(terr) =
|
||||
self.sub_types(op_arg_ty, fn_arg, term_location.to_locations(), category)
|
||||
self.sub_types(op_arg_ty, *fn_arg, term_location.to_locations(), category)
|
||||
{
|
||||
span_mirbug!(
|
||||
self,
|
||||
@ -2048,7 +2048,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
Rvalue::NullaryOp(_, ty) => {
|
||||
&Rvalue::NullaryOp(_, ty) => {
|
||||
let trait_ref = ty::TraitRef {
|
||||
def_id: tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
|
||||
substs: tcx.mk_substs_trait(ty, &[]),
|
||||
@ -2066,7 +2066,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
|
||||
let trait_ref = ty::TraitRef {
|
||||
def_id: tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
|
||||
substs: tcx.mk_substs_trait(ty, &[]),
|
||||
substs: tcx.mk_substs_trait(*ty, &[]),
|
||||
};
|
||||
|
||||
self.prove_trait_ref(
|
||||
@ -2093,7 +2093,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
let ty_fn_ptr_from = tcx.mk_fn_ptr(fn_sig);
|
||||
|
||||
if let Err(terr) = self.eq_types(
|
||||
ty,
|
||||
*ty,
|
||||
ty_fn_ptr_from,
|
||||
location.to_locations(),
|
||||
ConstraintCategory::Cast,
|
||||
@ -2117,7 +2117,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
let ty_fn_ptr_from = tcx.mk_fn_ptr(tcx.signature_unclosure(sig, *unsafety));
|
||||
|
||||
if let Err(terr) = self.eq_types(
|
||||
ty,
|
||||
*ty,
|
||||
ty_fn_ptr_from,
|
||||
location.to_locations(),
|
||||
ConstraintCategory::Cast,
|
||||
@ -2146,7 +2146,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
let ty_fn_ptr_from = tcx.safe_to_unsafe_fn_ty(fn_sig);
|
||||
|
||||
if let Err(terr) = self.eq_types(
|
||||
ty,
|
||||
*ty,
|
||||
ty_fn_ptr_from,
|
||||
location.to_locations(),
|
||||
ConstraintCategory::Cast,
|
||||
@ -2209,8 +2209,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
}
|
||||
};
|
||||
if let Err(terr) = self.sub_types(
|
||||
ty_from,
|
||||
ty_to,
|
||||
*ty_from,
|
||||
*ty_to,
|
||||
location.to_locations(),
|
||||
ConstraintCategory::Cast,
|
||||
) {
|
||||
@ -2278,8 +2278,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
}
|
||||
|
||||
if let Err(terr) = self.sub_types(
|
||||
ty_elem,
|
||||
ty_to,
|
||||
*ty_elem,
|
||||
*ty_to,
|
||||
location.to_locations(),
|
||||
ConstraintCategory::Cast,
|
||||
) {
|
||||
@ -2297,7 +2297,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
CastKind::Misc => {
|
||||
let ty_from = op.ty(body, tcx);
|
||||
let cast_ty_from = CastTy::from_ty(ty_from);
|
||||
let cast_ty_to = CastTy::from_ty(ty);
|
||||
let cast_ty_to = CastTy::from_ty(*ty);
|
||||
match (cast_ty_from, cast_ty_to) {
|
||||
(None, _)
|
||||
| (_, None | Some(CastTy::FnPtr))
|
||||
|
@ -512,7 +512,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
||||
first_local_index,
|
||||
num_universals,
|
||||
defining_ty,
|
||||
unnormalized_output_ty,
|
||||
unnormalized_output_ty: *unnormalized_output_ty,
|
||||
unnormalized_input_tys,
|
||||
yield_ty,
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
||||
let arg_uninhabited = fx
|
||||
.mir
|
||||
.args_iter()
|
||||
.any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited());
|
||||
.any(|arg| fx.layout_of(fx.monomorphize(fx.mir.local_decls[arg].ty)).abi.is_uninhabited());
|
||||
|
||||
if !crate::constant::check_constants(&mut fx) {
|
||||
fx.bcx.append_block_params_for_function_params(fx.block_map[START_BLOCK]);
|
||||
@ -818,16 +818,16 @@ pub(crate) fn codegen_place<'tcx>(
|
||||
match cplace.layout().ty.kind() {
|
||||
ty::Array(elem_ty, _len) => {
|
||||
assert!(!from_end, "array subslices are never `from_end`");
|
||||
let elem_layout = fx.layout_of(elem_ty);
|
||||
let elem_layout = fx.layout_of(*elem_ty);
|
||||
let ptr = cplace.to_ptr();
|
||||
cplace = CPlace::for_ptr(
|
||||
ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)),
|
||||
fx.layout_of(fx.tcx.mk_array(elem_ty, to - from)),
|
||||
fx.layout_of(fx.tcx.mk_array(*elem_ty, to - from)),
|
||||
);
|
||||
}
|
||||
ty::Slice(elem_ty) => {
|
||||
assert!(from_end, "slice subslices should be `from_end`");
|
||||
let elem_layout = fx.layout_of(elem_ty);
|
||||
let elem_layout = fx.layout_of(*elem_ty);
|
||||
let (ptr, len) = cplace.to_ptr_maybe_unsized();
|
||||
let len = len.unwrap();
|
||||
cplace = CPlace::for_ptr_with_extra(
|
||||
|
@ -61,7 +61,7 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<types::Typ
|
||||
},
|
||||
ty::FnPtr(_) => pointer_ty(tcx),
|
||||
ty::RawPtr(TypeAndMut { ty: pointee_ty, mutbl: _ }) | ty::Ref(_, pointee_ty, _) => {
|
||||
if has_ptr_meta(tcx, pointee_ty) {
|
||||
if has_ptr_meta(tcx, *pointee_ty) {
|
||||
return None;
|
||||
} else {
|
||||
pointer_ty(tcx)
|
||||
@ -100,7 +100,7 @@ fn clif_pair_type_from_ty<'tcx>(
|
||||
(a, b)
|
||||
}
|
||||
ty::RawPtr(TypeAndMut { ty: pointee_ty, mutbl: _ }) | ty::Ref(_, pointee_ty, _) => {
|
||||
if has_ptr_meta(tcx, pointee_ty) {
|
||||
if has_ptr_meta(tcx, *pointee_ty) {
|
||||
(pointer_ty(tcx), pointer_ty(tcx))
|
||||
} else {
|
||||
return None;
|
||||
|
@ -490,7 +490,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
|
||||
return None;
|
||||
}
|
||||
let const_val = mir_operand_get_const_val(fx, operand)?;
|
||||
if fx.layout_of(ty).size
|
||||
if fx.layout_of(*ty).size
|
||||
!= const_val.try_to_scalar_int()?.size()
|
||||
{
|
||||
return None;
|
||||
|
@ -114,7 +114,7 @@ impl<'tcx> DebugContext<'tcx> {
|
||||
}
|
||||
|
||||
fn dwarf_ty(&mut self, ty: Ty<'tcx>) -> UnitEntryId {
|
||||
if let Some(type_id) = self.types.get(ty) {
|
||||
if let Some(type_id) = self.types.get(&ty) {
|
||||
return *type_id;
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ impl<'tcx> DebugContext<'tcx> {
|
||||
// Ensure that type is inserted before recursing to avoid duplicates
|
||||
self.types.insert(ty, type_id);
|
||||
|
||||
let pointee = self.dwarf_ty(pointee_ty);
|
||||
let pointee = self.dwarf_ty(*pointee_ty);
|
||||
|
||||
let type_entry = self.dwarf.unit.get_mut(type_id);
|
||||
|
||||
|
@ -66,7 +66,7 @@ fn unsize_ptr<'tcx>(
|
||||
(&ty::Ref(_, a, _), &ty::Ref(_, b, _))
|
||||
| (&ty::Ref(_, a, _), &ty::RawPtr(ty::TypeAndMut { ty: b, .. }))
|
||||
| (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => {
|
||||
(src, unsized_info(fx, a, b, old_info))
|
||||
(src, unsized_info(fx, *a, *b, old_info))
|
||||
}
|
||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => {
|
||||
let (a, b) = (src_layout.ty.boxed_ty(), dst_layout.ty.boxed_ty());
|
||||
|
@ -514,7 +514,7 @@ impl<'tcx> CPlace<'tcx> {
|
||||
// Can only happen for vector types
|
||||
let len =
|
||||
u16::try_from(len.eval_usize(fx.tcx, ParamEnv::reveal_all())).unwrap();
|
||||
let vector_ty = fx.clif_type(element).unwrap().by(len).unwrap();
|
||||
let vector_ty = fx.clif_type(*element).unwrap().by(len).unwrap();
|
||||
|
||||
let data = match from.0 {
|
||||
CValueInner::ByRef(ptr, None) => {
|
||||
@ -721,8 +721,8 @@ impl<'tcx> CPlace<'tcx> {
|
||||
index: Value,
|
||||
) -> CPlace<'tcx> {
|
||||
let (elem_layout, ptr) = match self.layout().ty.kind() {
|
||||
ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.to_ptr()),
|
||||
ty::Slice(elem_ty) => (fx.layout_of(elem_ty), self.to_ptr_maybe_unsized().0),
|
||||
ty::Array(elem_ty, _) => (fx.layout_of(*elem_ty), self.to_ptr()),
|
||||
ty::Slice(elem_ty) => (fx.layout_of(*elem_ty), self.to_ptr_maybe_unsized().0),
|
||||
_ => bug!("place_index({:?})", self.layout().ty),
|
||||
};
|
||||
|
||||
@ -781,11 +781,11 @@ pub(crate) fn assert_assignable<'tcx>(
|
||||
ty::RawPtr(TypeAndMut { ty: a, mutbl: _ }),
|
||||
ty::RawPtr(TypeAndMut { ty: b, mutbl: _ }),
|
||||
) => {
|
||||
assert_assignable(fx, a, b);
|
||||
assert_assignable(fx, *a, *b);
|
||||
}
|
||||
(ty::Ref(_, a, _), ty::RawPtr(TypeAndMut { ty: b, mutbl: _ }))
|
||||
| (ty::RawPtr(TypeAndMut { ty: a, mutbl: _ }), ty::Ref(_, b, _)) => {
|
||||
assert_assignable(fx, a, b);
|
||||
assert_assignable(fx, *a, *b);
|
||||
}
|
||||
(ty::FnPtr(_), ty::FnPtr(_)) => {
|
||||
let from_sig = fx.tcx.normalize_erasing_late_bound_regions(
|
||||
|
@ -185,9 +185,9 @@ impl<'ll, 'tcx> TypeMap<'ll, 'tcx> {
|
||||
///
|
||||
/// This function is used to remove the temporary metadata
|
||||
/// mapping after we've computed the actual metadata.
|
||||
fn remove_type(&mut self, type_: Ty<'tcx>) {
|
||||
if self.type_to_metadata.remove(type_).is_none() {
|
||||
bug!("type metadata `Ty` '{}' is not in the `TypeMap`!", type_);
|
||||
fn remove_type(&mut self, ty: Ty<'tcx>) {
|
||||
if self.type_to_metadata.remove(&ty).is_none() {
|
||||
bug!("type metadata `Ty` '{}' is not in the `TypeMap`!", ty);
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,7 +397,7 @@ fn fixed_size_array_metadata<'ll, 'tcx>(
|
||||
bug!("fixed_size_array_metadata() called with non-ty::Array type `{:?}`", array_type)
|
||||
};
|
||||
|
||||
let element_type_metadata = type_metadata(cx, element_type);
|
||||
let element_type_metadata = type_metadata(cx, *element_type);
|
||||
|
||||
return_if_metadata_created_in_meantime!(cx, unique_type_id);
|
||||
|
||||
@ -546,7 +546,7 @@ fn subroutine_type_metadata<'ll, 'tcx>(
|
||||
)
|
||||
.chain(
|
||||
// regular arguments
|
||||
signature.inputs().iter().map(|argument_type| Some(type_metadata(cx, argument_type))),
|
||||
signature.inputs().iter().map(|&argument_type| Some(type_metadata(cx, argument_type))),
|
||||
)
|
||||
.collect();
|
||||
|
||||
@ -601,7 +601,7 @@ fn slice_type_metadata<'ll, 'tcx>(
|
||||
unique_type_id: UniqueTypeId,
|
||||
) -> MetadataCreationResult<'ll> {
|
||||
let element_type = match slice_type.kind() {
|
||||
ty::Slice(element_type) => element_type,
|
||||
ty::Slice(element_type) => *element_type,
|
||||
ty::Str => cx.tcx.types.u8,
|
||||
_ => {
|
||||
bug!(
|
||||
|
@ -430,9 +430,9 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
let t = arg.layout.ty;
|
||||
let t = match t.kind() {
|
||||
ty::Array(ct, _)
|
||||
if (*ct == cx.tcx.types.u8) || cx.layout_of(ct).is_zst() =>
|
||||
if (*ct == cx.tcx.types.u8) || cx.layout_of(*ct).is_zst() =>
|
||||
{
|
||||
cx.tcx.mk_imm_ptr(ct)
|
||||
cx.tcx.mk_imm_ptr(*ct)
|
||||
}
|
||||
_ => t,
|
||||
};
|
||||
|
@ -1132,8 +1132,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
||||
|
||||
fn simd_simple_float_intrinsic<'ll, 'tcx>(
|
||||
name: Symbol,
|
||||
in_elem: &::rustc_middle::ty::TyS<'_>,
|
||||
in_ty: &::rustc_middle::ty::TyS<'_>,
|
||||
in_elem: Ty<'_>,
|
||||
in_ty: Ty<'_>,
|
||||
in_len: u64,
|
||||
bx: &mut Builder<'_, 'll, 'tcx>,
|
||||
span: Span,
|
||||
|
@ -343,7 +343,7 @@ fn push_debuginfo_type_name<'tcx>(
|
||||
// We only care about avoiding recursing
|
||||
// directly back to the type we're currently
|
||||
// processing
|
||||
visited.remove(t);
|
||||
visited.remove(&t);
|
||||
}
|
||||
ty::Closure(def_id, substs) | ty::Generator(def_id, substs, ..) => {
|
||||
// Name will be "{closure_env#0}<T1, T2, ...>", "{generator_env#0}<T1, T2, ...>", or
|
||||
|
@ -194,7 +194,7 @@ pub(crate) fn deref_const<'tcx>(
|
||||
// In case of unsized types, figure out the real type behind.
|
||||
MemPlaceMeta::Meta(scalar) => match mplace.layout.ty.kind() {
|
||||
ty::Str => bug!("there's no sized equivalent of a `str`"),
|
||||
ty::Slice(elem_ty) => tcx.mk_array(elem_ty, scalar.to_machine_usize(&tcx).unwrap()),
|
||||
ty::Slice(elem_ty) => tcx.mk_array(*elem_ty, scalar.to_machine_usize(&tcx).unwrap()),
|
||||
_ => bug!(
|
||||
"type {} should not have metadata, but had {:?}",
|
||||
mplace.layout.ty,
|
||||
|
@ -315,7 +315,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
match (&src.layout.ty.kind(), &cast_ty.ty.kind()) {
|
||||
(&ty::Ref(_, s, _), &ty::Ref(_, c, _) | &ty::RawPtr(TypeAndMut { ty: c, .. }))
|
||||
| (&ty::RawPtr(TypeAndMut { ty: s, .. }), &ty::RawPtr(TypeAndMut { ty: c, .. })) => {
|
||||
self.unsize_into_ptr(src, dest, s, c)
|
||||
self.unsize_into_ptr(src, dest, *s, *c)
|
||||
}
|
||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
|
||||
assert_eq!(def_a, def_b);
|
||||
|
@ -585,7 +585,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
|
||||
match val {
|
||||
mir::ConstantKind::Ty(ct) => self.const_to_op(ct, layout),
|
||||
mir::ConstantKind::Val(val, ty) => self.const_val_to_op(*val, ty, layout),
|
||||
mir::ConstantKind::Val(val, ty) => self.const_val_to_op(*val, *ty, layout),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -462,7 +462,7 @@ where
|
||||
let (meta, ty) = match base.layout.ty.kind() {
|
||||
// It is not nice to match on the type, but that seems to be the only way to
|
||||
// implement this.
|
||||
ty::Array(inner, _) => (MemPlaceMeta::None, self.tcx.mk_array(inner, inner_len)),
|
||||
ty::Array(inner, _) => (MemPlaceMeta::None, self.tcx.mk_array(*inner, inner_len)),
|
||||
ty::Slice(..) => {
|
||||
let len = Scalar::from_machine_usize(inner_len, self);
|
||||
(MemPlaceMeta::Meta(len), base.layout.ty)
|
||||
|
@ -553,7 +553,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
|
||||
{
|
||||
// A mutable reference inside a const? That does not seem right (except if it is
|
||||
// a ZST).
|
||||
let layout = self.ecx.layout_of(ty)?;
|
||||
let layout = self.ecx.layout_of(*ty)?;
|
||||
if !layout.is_zst() {
|
||||
throw_validation_failure!(self.path, { "mutable reference in a `const`" });
|
||||
}
|
||||
@ -837,7 +837,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
|
||||
// This is the length of the array/slice.
|
||||
let len = mplace.len(self.ecx)?;
|
||||
// This is the element type size.
|
||||
let layout = self.ecx.layout_of(tys)?;
|
||||
let layout = self.ecx.layout_of(*tys)?;
|
||||
// This is the size in bytes of the whole array. (This checks for overflow.)
|
||||
let size = layout.size * len;
|
||||
|
||||
@ -896,7 +896,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
|
||||
// Fast path for arrays and slices of ZSTs. We only need to check a single ZST element
|
||||
// of an array and not all of them, because there's only a single value of a specific
|
||||
// ZST type, so either validation fails for all elements or none.
|
||||
ty::Array(tys, ..) | ty::Slice(tys) if self.ecx.layout_of(tys)?.is_zst() => {
|
||||
ty::Array(tys, ..) | ty::Slice(tys) if self.ecx.layout_of(*tys)?.is_zst() => {
|
||||
// Validate just the first element (if any).
|
||||
self.walk_aggregate(op, fields.take(1))?
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
|
||||
let mut tmp_ty = self_ty;
|
||||
while let rustc_middle::ty::Ref(_, inner_ty, _) = tmp_ty.kind() {
|
||||
num_refs += 1;
|
||||
tmp_ty = inner_ty;
|
||||
tmp_ty = *inner_ty;
|
||||
}
|
||||
let deref = "*".repeat(num_refs);
|
||||
|
||||
|
@ -496,7 +496,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
||||
if matches!(kind, CastKind::Misc) {
|
||||
let operand_ty = operand.ty(self.body, self.tcx);
|
||||
let cast_in = CastTy::from_ty(operand_ty).expect("bad input type for cast");
|
||||
let cast_out = CastTy::from_ty(cast_ty).expect("bad output type for cast");
|
||||
let cast_out = CastTy::from_ty(*cast_ty).expect("bad output type for cast");
|
||||
if let (CastTy::Ptr(_) | CastTy::FnPtr, CastTy::Int(_)) = (cast_in, cast_out) {
|
||||
// ptr-to-int casts are not possible in consts and thus not promotable
|
||||
return Err(Unpromotable);
|
||||
|
@ -915,13 +915,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
) -> Option<()> {
|
||||
for (i, ta) in sub.types().enumerate() {
|
||||
if ta == other_ty {
|
||||
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
|
||||
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, other_ty);
|
||||
return Some(());
|
||||
}
|
||||
if let ty::Adt(def, _) = ta.kind() {
|
||||
let path_ = self.tcx.def_path_str(def.did);
|
||||
if path_ == other_path {
|
||||
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);
|
||||
return Some(());
|
||||
}
|
||||
}
|
||||
@ -1036,7 +1036,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
let len2 = sig2.inputs().len();
|
||||
if len1 == len2 {
|
||||
for (i, (l, r)) in iter::zip(sig1.inputs(), sig2.inputs()).enumerate() {
|
||||
let (x1, x2) = self.cmp(l, r);
|
||||
let (x1, x2) = self.cmp(*l, *r);
|
||||
(values.0).0.extend(x1.0);
|
||||
(values.1).0.extend(x2.0);
|
||||
self.push_comma(&mut values.0, &mut values.1, len1, i);
|
||||
@ -1263,7 +1263,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
path1.clone(),
|
||||
sub_no_defaults_1,
|
||||
path2.clone(),
|
||||
&t2,
|
||||
t2,
|
||||
)
|
||||
.is_some()
|
||||
{
|
||||
@ -1281,7 +1281,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
path2,
|
||||
sub_no_defaults_2,
|
||||
path1,
|
||||
&t1,
|
||||
t1,
|
||||
)
|
||||
.is_some()
|
||||
{
|
||||
@ -1333,13 +1333,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
// When finding T != &T, highlight only the borrow
|
||||
(&ty::Ref(r1, ref_ty1, mutbl1), _) if equals(&ref_ty1, &t2) => {
|
||||
(&ty::Ref(r1, ref_ty1, mutbl1), _) if equals(ref_ty1, t2) => {
|
||||
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
|
||||
push_ty_ref(&r1, ref_ty1, mutbl1, &mut values.0);
|
||||
values.1.push_normal(t2.to_string());
|
||||
values
|
||||
}
|
||||
(_, &ty::Ref(r2, ref_ty2, mutbl2)) if equals(&t1, &ref_ty2) => {
|
||||
(_, &ty::Ref(r2, ref_ty2, mutbl2)) if equals(t1, ref_ty2) => {
|
||||
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
|
||||
values.0.push_normal(t1.to_string());
|
||||
push_ty_ref(&r2, ref_ty2, mutbl2, &mut values.1);
|
||||
@ -1348,7 +1348,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
|
||||
// When encountering &T != &mut T, highlight only the borrow
|
||||
(&ty::Ref(r1, ref_ty1, mutbl1), &ty::Ref(r2, ref_ty2, mutbl2))
|
||||
if equals(&ref_ty1, &ref_ty2) =>
|
||||
if equals(ref_ty1, ref_ty2) =>
|
||||
{
|
||||
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
|
||||
push_ty_ref(&r1, ref_ty1, mutbl1, &mut values.0);
|
||||
@ -1923,7 +1923,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
.iter()
|
||||
.filter(|field| field.vis.is_accessible_from(field.did, self.tcx))
|
||||
.map(|field| (field.name, field.ty(self.tcx, expected_substs)))
|
||||
.find(|(_, ty)| same_type_modulo_infer(ty, exp_found.found))
|
||||
.find(|(_, ty)| same_type_modulo_infer(*ty, exp_found.found))
|
||||
{
|
||||
if let ObligationCauseCode::Pattern { span: Some(span), .. } = *cause.code() {
|
||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
|
||||
@ -2116,7 +2116,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
let [expected_tup_elem] = &expected.tuple_fields().collect::<Vec<_>>()[..]
|
||||
else { return };
|
||||
|
||||
if !same_type_modulo_infer(expected_tup_elem, found) {
|
||||
if !same_type_modulo_infer(*expected_tup_elem, found) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -985,7 +985,7 @@ impl<'tcx> TypeFolder<'tcx> for ResolvedTypeParamEraser<'tcx> {
|
||||
}
|
||||
}
|
||||
ty::Ref(_, ty, _) => {
|
||||
let ty = self.fold_ty(ty);
|
||||
let ty = self.fold_ty(*ty);
|
||||
match ty.kind() {
|
||||
// Avoid `&_`, these can be safely presented as `_`.
|
||||
ty::Error(_) => self.tcx().ty_error(),
|
||||
@ -1002,7 +1002,7 @@ impl<'tcx> TypeFolder<'tcx> for ResolvedTypeParamEraser<'tcx> {
|
||||
| ty::Projection(_)
|
||||
| ty::Never => t.super_fold_with(self),
|
||||
ty::Array(ty, c) => {
|
||||
self.tcx().mk_ty(ty::Array(self.fold_ty(ty), self.replace_infers(c, 0, sym::N)))
|
||||
self.tcx().mk_ty(ty::Array(self.fold_ty(*ty), self.replace_infers(c, 0, sym::N)))
|
||||
}
|
||||
// We don't want to hide type params that haven't been resolved yet.
|
||||
// This would be the type that will be written out with the type param
|
||||
|
@ -42,8 +42,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
if sup_expected_found == sub_expected_found {
|
||||
self.emit_err(
|
||||
var_origin.span(),
|
||||
sub_expected,
|
||||
sub_found,
|
||||
*sub_expected,
|
||||
*sub_found,
|
||||
*trait_item_def_id,
|
||||
);
|
||||
return Some(ErrorReported);
|
||||
|
@ -237,7 +237,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for InferenceFudger<'a, 'tcx> {
|
||||
// Recreate it with a fresh variable here.
|
||||
let idx = (vid.index - self.const_vars.0.start.index) as usize;
|
||||
let origin = self.const_vars.1[idx];
|
||||
self.infcx.next_const_var(ty, origin)
|
||||
self.infcx.next_const_var(*ty, origin)
|
||||
} else {
|
||||
ct
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ impl<'tcx> ValuePairs<'tcx> {
|
||||
found: ty::Term::Ty(found),
|
||||
}) = self
|
||||
{
|
||||
Some((expected, found))
|
||||
Some((*expected, *found))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ impl<'tcx> VidValuePair<'tcx> for (ty::TyVid, Ty<'tcx>) {
|
||||
where
|
||||
D: TypeRelatingDelegate<'tcx>,
|
||||
{
|
||||
relate.relate(&generalized_ty, &self.value_ty())
|
||||
relate.relate(generalized_ty, self.value_ty())
|
||||
}
|
||||
}
|
||||
|
||||
@ -482,7 +482,7 @@ impl<'tcx> VidValuePair<'tcx> for (Ty<'tcx>, ty::TyVid) {
|
||||
where
|
||||
D: TypeRelatingDelegate<'tcx>,
|
||||
{
|
||||
relate.relate(&self.value_ty(), &generalized_ty)
|
||||
relate.relate(self.value_ty(), generalized_ty)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2896,25 +2896,21 @@ impl ClashingExternDeclarations {
|
||||
(Array(a_ty, a_const), Array(b_ty, b_const)) => {
|
||||
// For arrays, we also check the constness of the type.
|
||||
a_const.val == b_const.val
|
||||
&& structurally_same_type_impl(seen_types, cx, a_ty, b_ty, ckind)
|
||||
&& structurally_same_type_impl(seen_types, cx, *a_ty, *b_ty, ckind)
|
||||
}
|
||||
(Slice(a_ty), Slice(b_ty)) => {
|
||||
structurally_same_type_impl(seen_types, cx, a_ty, b_ty, ckind)
|
||||
structurally_same_type_impl(seen_types, cx, *a_ty, *b_ty, ckind)
|
||||
}
|
||||
(RawPtr(a_tymut), RawPtr(b_tymut)) => {
|
||||
a_tymut.mutbl == b_tymut.mutbl
|
||||
&& structurally_same_type_impl(
|
||||
seen_types,
|
||||
cx,
|
||||
&a_tymut.ty,
|
||||
&b_tymut.ty,
|
||||
ckind,
|
||||
seen_types, cx, a_tymut.ty, b_tymut.ty, ckind,
|
||||
)
|
||||
}
|
||||
(Ref(_a_region, a_ty, a_mut), Ref(_b_region, b_ty, b_mut)) => {
|
||||
// For structural sameness, we don't need the region to be same.
|
||||
a_mut == b_mut
|
||||
&& structurally_same_type_impl(seen_types, cx, a_ty, b_ty, ckind)
|
||||
&& structurally_same_type_impl(seen_types, cx, *a_ty, *b_ty, ckind)
|
||||
}
|
||||
(FnDef(..), FnDef(..)) => {
|
||||
let a_poly_sig = a.fn_sig(tcx);
|
||||
@ -2927,7 +2923,7 @@ impl ClashingExternDeclarations {
|
||||
(a_sig.abi, a_sig.unsafety, a_sig.c_variadic)
|
||||
== (b_sig.abi, b_sig.unsafety, b_sig.c_variadic)
|
||||
&& a_sig.inputs().iter().eq_by(b_sig.inputs().iter(), |a, b| {
|
||||
structurally_same_type_impl(seen_types, cx, a, b, ckind)
|
||||
structurally_same_type_impl(seen_types, cx, *a, *b, ckind)
|
||||
})
|
||||
&& structurally_same_type_impl(
|
||||
seen_types,
|
||||
|
@ -7,9 +7,10 @@ use rustc_middle::ty;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
declare_tool_lint! {
|
||||
/// The `rustc_pass_by_value` lint marks a type with `#[rustc_pass_by_value]` requiring it to always be passed by value.
|
||||
/// This is usually used for types that are thin wrappers around references, so there is no benefit to an extra
|
||||
/// layer of indirection. (Example: `Ty` which is a reference to a `TyS`)
|
||||
/// The `rustc_pass_by_value` lint marks a type with `#[rustc_pass_by_value]` requiring it to
|
||||
/// always be passed by value. This is usually used for types that are thin wrappers around
|
||||
/// references, so there is no benefit to an extra layer of indirection. (Example: `Ty` which
|
||||
/// is a reference to an `Interned<TyS>`)
|
||||
pub rustc::PASS_BY_VALUE,
|
||||
Warn,
|
||||
"pass by reference of a type flagged as `#[rustc_pass_by_value]`",
|
||||
|
@ -249,7 +249,7 @@ fn report_bin_hex_error(
|
||||
));
|
||||
}
|
||||
if let Some(sugg_ty) =
|
||||
get_type_suggestion(&cx.typeck_results().node_type(expr.hir_id), val, negative)
|
||||
get_type_suggestion(cx.typeck_results().node_type(expr.hir_id), val, negative)
|
||||
{
|
||||
if let Some(pos) = repr_str.chars().position(|c| c == 'i' || c == 'u') {
|
||||
let (sans_suffix, _) = repr_str.split_at(pos);
|
||||
@ -367,7 +367,7 @@ fn lint_int_literal<'tcx>(
|
||||
max,
|
||||
));
|
||||
if let Some(sugg_ty) =
|
||||
get_type_suggestion(&cx.typeck_results().node_type(e.hir_id), v, negative)
|
||||
get_type_suggestion(cx.typeck_results().node_type(e.hir_id), v, negative)
|
||||
{
|
||||
err.help(&format!("consider using the type `{}` instead", sugg_ty));
|
||||
}
|
||||
@ -1095,7 +1095,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
for arg in sig.inputs() {
|
||||
let r = self.check_type_for_ffi(cache, arg);
|
||||
let r = self.check_type_for_ffi(cache, *arg);
|
||||
match r {
|
||||
FfiSafe => {}
|
||||
_ => {
|
||||
@ -1257,7 +1257,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
let sig = self.cx.tcx.erase_late_bound_regions(sig);
|
||||
|
||||
for (input_ty, input_hir) in iter::zip(sig.inputs(), decl.inputs) {
|
||||
self.check_type_for_ffi_and_report_errors(input_hir.span, input_ty, false, false);
|
||||
self.check_type_for_ffi_and_report_errors(input_hir.span, *input_ty, false, false);
|
||||
}
|
||||
|
||||
if let hir::FnRetTy::Return(ref ret_hir) = decl.output {
|
||||
|
@ -2558,7 +2558,7 @@ impl<'tcx> ConstantKind<'tcx> {
|
||||
pub fn ty(&self) -> Ty<'tcx> {
|
||||
match self {
|
||||
ConstantKind::Ty(c) => c.ty,
|
||||
ConstantKind::Val(_, ty) => ty,
|
||||
ConstantKind::Val(_, ty) => *ty,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ use rustc_middle::mir::interpret::{
|
||||
use rustc_middle::mir::visit::Visitor;
|
||||
use rustc_middle::mir::MirSource;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{self, TyCtxt, TyS, TypeFoldable, TypeVisitor};
|
||||
use rustc_middle::ty::{self, TyCtxt, TypeFoldable, TypeVisitor};
|
||||
use rustc_target::abi::Size;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
@ -427,12 +427,12 @@ impl<'tcx> ExtraComments<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn use_verbose<'tcx>(ty: &&TyS<'tcx>, fn_def: bool) -> bool {
|
||||
match ty.kind() {
|
||||
fn use_verbose<'tcx>(ty: Ty<'tcx>, fn_def: bool) -> bool {
|
||||
match *ty.kind() {
|
||||
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char | ty::Float(_) => false,
|
||||
// Unit type
|
||||
ty::Tuple(g_args) if g_args.is_empty() => false,
|
||||
ty::Tuple(g_args) => g_args.iter().any(|g_arg| use_verbose(&g_arg.expect_ty(), fn_def)),
|
||||
ty::Tuple(g_args) => g_args.iter().any(|g_arg| use_verbose(g_arg.expect_ty(), fn_def)),
|
||||
ty::Array(ty, _) => use_verbose(ty, fn_def),
|
||||
ty::FnDef(..) => fn_def,
|
||||
_ => true,
|
||||
@ -443,7 +443,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
|
||||
fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) {
|
||||
self.super_constant(constant, location);
|
||||
let Constant { span, user_ty, literal } = constant;
|
||||
if use_verbose(&literal.ty(), true) {
|
||||
if use_verbose(literal.ty(), true) {
|
||||
self.push("mir::Constant");
|
||||
self.push(&format!(
|
||||
"+ span: {}",
|
||||
@ -465,7 +465,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
|
||||
fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, _: Location) {
|
||||
self.super_const(constant);
|
||||
let ty::Const { ty, val, .. } = constant;
|
||||
if use_verbose(ty, false) {
|
||||
if use_verbose(*ty, false) {
|
||||
self.push("ty::Const");
|
||||
self.push(&format!("+ ty: {:?}", ty));
|
||||
let val = match val {
|
||||
|
@ -57,7 +57,7 @@ impl<'tcx> PlaceTy<'tcx> {
|
||||
/// `PlaceElem`, where we can just use the `Ty` that is already
|
||||
/// stored inline on field projection elems.
|
||||
pub fn projection_ty(self, tcx: TyCtxt<'tcx>, elem: PlaceElem<'tcx>) -> PlaceTy<'tcx> {
|
||||
self.projection_ty_core(tcx, ty::ParamEnv::empty(), &elem, |_, _, ty| ty)
|
||||
self.projection_ty_core(tcx, ty::ParamEnv::empty(), &elem, |_, _, &ty| ty)
|
||||
}
|
||||
|
||||
/// `place_ty.projection_ty_core(tcx, elem, |...| { ... })`
|
||||
@ -93,11 +93,11 @@ impl<'tcx> PlaceTy<'tcx> {
|
||||
ProjectionElem::Subslice { from, to, from_end } => {
|
||||
PlaceTy::from_ty(match self.ty.kind() {
|
||||
ty::Slice(..) => self.ty,
|
||||
ty::Array(inner, _) if !from_end => tcx.mk_array(inner, (to - from) as u64),
|
||||
ty::Array(inner, _) if !from_end => tcx.mk_array(*inner, (to - from) as u64),
|
||||
ty::Array(inner, size) if from_end => {
|
||||
let size = size.eval_usize(tcx, param_env);
|
||||
let len = size - (from as u64) - (to as u64);
|
||||
tcx.mk_array(inner, len)
|
||||
tcx.mk_array(*inner, len)
|
||||
}
|
||||
_ => bug!("cannot subslice non-array type: `{:?}`", self),
|
||||
})
|
||||
|
@ -430,7 +430,7 @@ impl<'tcx> TerminatorKind<'tcx> {
|
||||
pub fn as_switch(&self) -> Option<(&Operand<'tcx>, Ty<'tcx>, &SwitchTargets)> {
|
||||
match self {
|
||||
TerminatorKind::SwitchInt { discr, switch_ty, targets } => {
|
||||
Some((discr, switch_ty, targets))
|
||||
Some((discr, *switch_ty, targets))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ macro_rules! make_mir_visitor {
|
||||
) {
|
||||
let span = body.span;
|
||||
if let Some(gen) = &$($mutability)? body.generator {
|
||||
if let Some(yield_ty) = &$($mutability)? gen.yield_ty {
|
||||
if let Some(yield_ty) = $(& $mutability)? gen.yield_ty {
|
||||
self.visit_ty(
|
||||
yield_ty,
|
||||
TyContext::YieldTy(SourceInfo::outermost(span))
|
||||
@ -266,7 +266,7 @@ macro_rules! make_mir_visitor {
|
||||
}
|
||||
|
||||
self.visit_ty(
|
||||
&$($mutability)? body.return_ty(),
|
||||
$(& $mutability)? body.return_ty(),
|
||||
TyContext::ReturnTy(SourceInfo::outermost(body.span))
|
||||
);
|
||||
|
||||
@ -355,7 +355,7 @@ macro_rules! make_mir_visitor {
|
||||
ty::InstanceDef::DropGlue(_def_id, Some(ty)) |
|
||||
ty::InstanceDef::CloneShim(_def_id, ty) => {
|
||||
// FIXME(eddyb) use a better `TyContext` here.
|
||||
self.visit_ty(ty, TyContext::Location(location));
|
||||
self.visit_ty($(& $mutability)? *ty, TyContext::Location(location));
|
||||
}
|
||||
}
|
||||
self.visit_substs(callee_substs, location);
|
||||
@ -487,7 +487,7 @@ macro_rules! make_mir_visitor {
|
||||
targets: _
|
||||
} => {
|
||||
self.visit_operand(discr, location);
|
||||
self.visit_ty(switch_ty, TyContext::Location(location));
|
||||
self.visit_ty($(& $mutability)? *switch_ty, TyContext::Location(location));
|
||||
}
|
||||
|
||||
TerminatorKind::Drop {
|
||||
@ -680,7 +680,7 @@ macro_rules! make_mir_visitor {
|
||||
|
||||
Rvalue::Cast(_cast_kind, operand, ty) => {
|
||||
self.visit_operand(operand, location);
|
||||
self.visit_ty(ty, TyContext::Location(location));
|
||||
self.visit_ty($(& $mutability)? *ty, TyContext::Location(location));
|
||||
}
|
||||
|
||||
Rvalue::BinaryOp(_bin_op, box(lhs, rhs))
|
||||
@ -702,14 +702,14 @@ macro_rules! make_mir_visitor {
|
||||
}
|
||||
|
||||
Rvalue::NullaryOp(_op, ty) => {
|
||||
self.visit_ty(ty, TyContext::Location(location));
|
||||
self.visit_ty($(& $mutability)? *ty, TyContext::Location(location));
|
||||
}
|
||||
|
||||
Rvalue::Aggregate(kind, operands) => {
|
||||
let kind = &$($mutability)? **kind;
|
||||
match kind {
|
||||
AggregateKind::Array(ty) => {
|
||||
self.visit_ty(ty, TyContext::Location(location));
|
||||
self.visit_ty($(& $mutability)? *ty, TyContext::Location(location));
|
||||
}
|
||||
AggregateKind::Tuple => {
|
||||
}
|
||||
@ -744,7 +744,7 @@ macro_rules! make_mir_visitor {
|
||||
|
||||
Rvalue::ShallowInitBox(operand, ty) => {
|
||||
self.visit_operand(operand, location);
|
||||
self.visit_ty(ty, TyContext::Location(location));
|
||||
self.visit_ty($(& $mutability)? *ty, TyContext::Location(location));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -815,7 +815,7 @@ macro_rules! make_mir_visitor {
|
||||
is_block_tail: _,
|
||||
} = local_decl;
|
||||
|
||||
self.visit_ty(ty, TyContext::LocalDecl {
|
||||
self.visit_ty($(& $mutability)? *ty, TyContext::LocalDecl {
|
||||
local,
|
||||
source_info: *source_info,
|
||||
});
|
||||
@ -865,7 +865,7 @@ macro_rules! make_mir_visitor {
|
||||
drop(user_ty); // no visit method for this
|
||||
match literal {
|
||||
ConstantKind::Ty(ct) => self.visit_const(ct, location),
|
||||
ConstantKind::Val(_, t) => self.visit_ty(t, TyContext::Location(location)),
|
||||
ConstantKind::Val(_, ty) => self.visit_ty($(& $mutability)? *ty, TyContext::Location(location)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -894,7 +894,7 @@ macro_rules! make_mir_visitor {
|
||||
ty: & $($mutability)? CanonicalUserTypeAnnotation<'tcx>,
|
||||
) {
|
||||
self.visit_span(& $($mutability)? ty.span);
|
||||
self.visit_ty(& $($mutability)? ty.inferred_ty, TyContext::UserTy(ty.span));
|
||||
self.visit_ty($(& $mutability)? ty.inferred_ty, TyContext::UserTy(ty.span));
|
||||
}
|
||||
|
||||
fn super_ty(&mut self, _ty: $(& $mutability)? Ty<'tcx>) {
|
||||
|
@ -1146,33 +1146,33 @@ rustc_queries! {
|
||||
desc { "computing whether `{}` is `Copy`", env.value }
|
||||
remap_env_constness
|
||||
}
|
||||
/// Query backing `TyS::is_sized`.
|
||||
/// Query backing `Ty::is_sized`.
|
||||
query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||
desc { "computing whether `{}` is `Sized`", env.value }
|
||||
remap_env_constness
|
||||
}
|
||||
/// Query backing `TyS::is_freeze`.
|
||||
/// Query backing `Ty::is_freeze`.
|
||||
query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||
desc { "computing whether `{}` is freeze", env.value }
|
||||
remap_env_constness
|
||||
}
|
||||
/// Query backing `TyS::is_unpin`.
|
||||
/// Query backing `Ty::is_unpin`.
|
||||
query is_unpin_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||
desc { "computing whether `{}` is `Unpin`", env.value }
|
||||
remap_env_constness
|
||||
}
|
||||
/// Query backing `TyS::needs_drop`.
|
||||
/// Query backing `Ty::needs_drop`.
|
||||
query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||
desc { "computing whether `{}` needs drop", env.value }
|
||||
remap_env_constness
|
||||
}
|
||||
/// Query backing `TyS::has_significant_drop_raw`.
|
||||
/// Query backing `Ty::has_significant_drop_raw`.
|
||||
query has_significant_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||
desc { "computing whether `{}` has a significant drop", env.value }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
/// Query backing `TyS::is_structural_eq_shallow`.
|
||||
/// Query backing `Ty::is_structural_eq_shallow`.
|
||||
///
|
||||
/// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
|
||||
/// correctly.
|
||||
|
@ -77,7 +77,7 @@ impl<'tcx> TypeRelation<'tcx> for Match<'tcx> {
|
||||
) => Ok(a),
|
||||
|
||||
(&ty::Infer(_), _) | (_, &ty::Infer(_)) => {
|
||||
Err(TypeError::Sorts(relate::expected_found(self, &a, &b)))
|
||||
Err(TypeError::Sorts(relate::expected_found(self, a, b)))
|
||||
}
|
||||
|
||||
(&ty::Error(_), _) | (_, &ty::Error(_)) => Ok(self.tcx().ty_error()),
|
||||
|
@ -116,7 +116,7 @@ impl<'tcx> ClosureKind {
|
||||
}
|
||||
|
||||
/// Returns the representative scalar type for this closure kind.
|
||||
/// See `TyS::to_opt_closure_kind` for more details.
|
||||
/// See `Ty::to_opt_closure_kind` for more details.
|
||||
pub fn to_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
match self {
|
||||
ty::ClosureKind::Fn => tcx.types.i8,
|
||||
|
@ -26,6 +26,7 @@ use crate::ty::{
|
||||
use rustc_ast as ast;
|
||||
use rustc_attr as attr;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_data_structures::memmap::Mmap;
|
||||
use rustc_data_structures::profiling::SelfProfilerRef;
|
||||
use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
|
||||
@ -151,19 +152,21 @@ impl<'tcx> CtxtInterners<'tcx> {
|
||||
#[allow(rustc::usage_of_ty_tykind)]
|
||||
#[inline(never)]
|
||||
fn intern_ty(&self, kind: TyKind<'tcx>) -> Ty<'tcx> {
|
||||
self.type_
|
||||
.intern(kind, |kind| {
|
||||
let flags = super::flags::FlagComputation::for_kind(&kind);
|
||||
Ty(Interned::new_unchecked(
|
||||
self.type_
|
||||
.intern(kind, |kind| {
|
||||
let flags = super::flags::FlagComputation::for_kind(&kind);
|
||||
|
||||
let ty_struct = TyS {
|
||||
kind,
|
||||
flags: flags.flags,
|
||||
outer_exclusive_binder: flags.outer_exclusive_binder,
|
||||
};
|
||||
let ty_struct = TyS {
|
||||
kind,
|
||||
flags: flags.flags,
|
||||
outer_exclusive_binder: flags.outer_exclusive_binder,
|
||||
};
|
||||
|
||||
InternedInSet(self.arena.alloc(ty_struct))
|
||||
})
|
||||
.0
|
||||
InternedInSet(self.arena.alloc(ty_struct))
|
||||
})
|
||||
.0,
|
||||
))
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
@ -1628,7 +1631,8 @@ pub trait Lift<'tcx>: fmt::Debug {
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted>;
|
||||
}
|
||||
|
||||
macro_rules! nop_lift {
|
||||
// Deprecated: we are in the process of converting all uses to `nop_lift`.
|
||||
macro_rules! nop_lift_old {
|
||||
($set:ident; $ty:ty => $lifted:ty) => {
|
||||
impl<'a, 'tcx> Lift<'tcx> for $ty {
|
||||
type Lifted = $lifted;
|
||||
@ -1643,6 +1647,21 @@ macro_rules! nop_lift {
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! nop_lift {
|
||||
($set:ident; $ty:ty => $lifted:ty) => {
|
||||
impl<'a, 'tcx> Lift<'tcx> for $ty {
|
||||
type Lifted = $lifted;
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
if tcx.interners.$set.contains_pointer_to(&InternedInSet(self.0.0)) {
|
||||
Some(unsafe { mem::transmute(self) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! nop_list_lift {
|
||||
($set:ident; $ty:ty => $lifted:ty) => {
|
||||
impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> {
|
||||
@ -1662,10 +1681,10 @@ macro_rules! nop_list_lift {
|
||||
}
|
||||
|
||||
nop_lift! {type_; Ty<'a> => Ty<'tcx>}
|
||||
nop_lift! {region; Region<'a> => Region<'tcx>}
|
||||
nop_lift! {const_; &'a Const<'a> => &'tcx Const<'tcx>}
|
||||
nop_lift! {const_allocation; &'a Allocation => &'tcx Allocation}
|
||||
nop_lift! {predicate; &'a PredicateInner<'a> => &'tcx PredicateInner<'tcx>}
|
||||
nop_lift_old! {region; Region<'a> => Region<'tcx>}
|
||||
nop_lift_old! {const_; &'a Const<'a> => &'tcx Const<'tcx>}
|
||||
nop_lift_old! {const_allocation; &'a Allocation => &'tcx Allocation}
|
||||
nop_lift_old! {predicate; &'a PredicateInner<'a> => &'tcx PredicateInner<'tcx>}
|
||||
|
||||
nop_list_lift! {type_list; Ty<'a> => Ty<'tcx>}
|
||||
nop_list_lift! {poly_existential_predicates; ty::Binder<'a, ExistentialPredicate<'a>> => ty::Binder<'tcx, ExistentialPredicate<'tcx>>}
|
||||
@ -1882,15 +1901,15 @@ macro_rules! sty_debug_print {
|
||||
let shards = tcx.interners.type_.lock_shards();
|
||||
let types = shards.iter().flat_map(|shard| shard.keys());
|
||||
for &InternedInSet(t) in types {
|
||||
let variant = match t.kind() {
|
||||
let variant = match t.kind {
|
||||
ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) |
|
||||
ty::Float(..) | ty::Str | ty::Never => continue,
|
||||
ty::Error(_) => /* unimportant */ continue,
|
||||
$(ty::$variant(..) => &mut $variant,)*
|
||||
};
|
||||
let lt = t.flags().intersects(ty::TypeFlags::HAS_RE_INFER);
|
||||
let ty = t.flags().intersects(ty::TypeFlags::HAS_TY_INFER);
|
||||
let ct = t.flags().intersects(ty::TypeFlags::HAS_CT_INFER);
|
||||
let lt = t.flags.intersects(ty::TypeFlags::HAS_RE_INFER);
|
||||
let ty = t.flags.intersects(ty::TypeFlags::HAS_TY_INFER);
|
||||
let ct = t.flags.intersects(ty::TypeFlags::HAS_CT_INFER);
|
||||
|
||||
variant.total += 1;
|
||||
total.total += 1;
|
||||
@ -2000,7 +2019,7 @@ impl<'tcx, T: 'tcx + ?Sized> IntoPointer for InternedInSet<'tcx, T> {
|
||||
#[allow(rustc::usage_of_ty_tykind)]
|
||||
impl<'tcx> Borrow<TyKind<'tcx>> for InternedInSet<'tcx, TyS<'tcx>> {
|
||||
fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> {
|
||||
&self.0.kind()
|
||||
&self.0.kind
|
||||
}
|
||||
}
|
||||
|
||||
@ -2008,7 +2027,7 @@ impl<'tcx> PartialEq for InternedInSet<'tcx, TyS<'tcx>> {
|
||||
fn eq(&self, other: &InternedInSet<'tcx, TyS<'tcx>>) -> bool {
|
||||
// The `Borrow` trait requires that `x.borrow() == y.borrow()` equals
|
||||
// `x == y`.
|
||||
self.0.kind() == other.0.kind()
|
||||
self.0.kind == other.0.kind
|
||||
}
|
||||
}
|
||||
|
||||
@ -2017,7 +2036,7 @@ impl<'tcx> Eq for InternedInSet<'tcx, TyS<'tcx>> {}
|
||||
impl<'tcx> Hash for InternedInSet<'tcx, TyS<'tcx>> {
|
||||
fn hash<H: Hasher>(&self, s: &mut H) {
|
||||
// The `Borrow` trait requires that `x.borrow().hash(s) == x.hash(s)`.
|
||||
self.0.kind().hash(s)
|
||||
self.0.kind.hash(s)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
//! Diagnostics related methods for `TyS`.
|
||||
//! Diagnostics related methods for `Ty`.
|
||||
|
||||
use crate::ty::subst::{GenericArg, GenericArgKind};
|
||||
use crate::ty::TyKind::*;
|
||||
use crate::ty::{
|
||||
ConstKind, ExistentialPredicate, ExistentialProjection, ExistentialTraitRef, InferTy,
|
||||
ProjectionTy, Term, TyCtxt, TyS, TypeAndMut,
|
||||
ProjectionTy, Term, Ty, TyCtxt, TypeAndMut,
|
||||
};
|
||||
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
@ -13,9 +13,9 @@ use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{QPath, TyKind, WhereBoundPredicate, WherePredicate};
|
||||
use rustc_span::Span;
|
||||
|
||||
impl<'tcx> TyS<'tcx> {
|
||||
/// Similar to `TyS::is_primitive`, but also considers inferred numeric values to be primitive.
|
||||
pub fn is_primitive_ty(&self) -> bool {
|
||||
impl<'tcx> Ty<'tcx> {
|
||||
/// Similar to `Ty::is_primitive`, but also considers inferred numeric values to be primitive.
|
||||
pub fn is_primitive_ty(self) -> bool {
|
||||
matches!(
|
||||
self.kind(),
|
||||
Bool | Char
|
||||
@ -34,7 +34,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
|
||||
/// Whether the type is succinctly representable as a type instead of just referred to with a
|
||||
/// description in error messages. This is used in the main error message.
|
||||
pub fn is_simple_ty(&self) -> bool {
|
||||
pub fn is_simple_ty(self) -> bool {
|
||||
match self.kind() {
|
||||
Bool
|
||||
| Char
|
||||
@ -58,7 +58,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
/// description in error messages. This is used in the primary span label. Beyond what
|
||||
/// `is_simple_ty` includes, it also accepts ADTs with no type arguments and references to
|
||||
/// ADTs with no type arguments.
|
||||
pub fn is_simple_text(&self) -> bool {
|
||||
pub fn is_simple_text(self) -> bool {
|
||||
match self.kind() {
|
||||
Adt(_, substs) => substs.non_erasable_generics().next().is_none(),
|
||||
Ref(_, ty, _) => ty.is_simple_text(),
|
||||
@ -67,7 +67,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
}
|
||||
|
||||
/// Whether the type can be safely suggested during error recovery.
|
||||
pub fn is_suggestable(&self) -> bool {
|
||||
pub fn is_suggestable(self) -> bool {
|
||||
fn generic_arg_is_suggestible(arg: GenericArg<'_>) -> bool {
|
||||
match arg.unpack() {
|
||||
GenericArgKind::Type(ty) => ty.is_suggestable(),
|
||||
|
@ -239,8 +239,8 @@ impl<'tcx> TypeError<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ty::TyS<'tcx> {
|
||||
pub fn sort_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
|
||||
impl<'tcx> Ty<'tcx> {
|
||||
pub fn sort_string(self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
|
||||
match *self.kind() {
|
||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => {
|
||||
format!("`{}`", self).into()
|
||||
@ -306,7 +306,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prefix_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
|
||||
pub fn prefix_string(self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
|
||||
match *self.kind() {
|
||||
ty::Infer(_)
|
||||
| ty::Error(_)
|
||||
|
@ -6,7 +6,7 @@ use std::slice;
|
||||
pub struct FlagComputation {
|
||||
pub flags: TypeFlags,
|
||||
|
||||
// see `TyS::outer_exclusive_binder` for details
|
||||
// see `Ty::outer_exclusive_binder` for details
|
||||
pub outer_exclusive_binder: ty::DebruijnIndex,
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ impl FlagComputation {
|
||||
|
||||
fn add_ty(&mut self, ty: Ty<'_>) {
|
||||
self.add_flags(ty.flags());
|
||||
self.add_exclusive_binder(ty.outer_exclusive_binder);
|
||||
self.add_exclusive_binder(ty.outer_exclusive_binder());
|
||||
}
|
||||
|
||||
fn add_tys(&mut self, tys: &[Ty<'_>]) {
|
||||
|
@ -627,7 +627,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for BoundVarReplacer<'a, 'tcx> {
|
||||
ty::Bound(debruijn, bound_ty) if debruijn == self.current_index => {
|
||||
if let Some(fld_t) = self.fld_t.as_mut() {
|
||||
let ty = fld_t(bound_ty);
|
||||
return ty::fold::shift_vars(self.tcx, &ty, self.current_index.as_u32());
|
||||
return ty::fold::shift_vars(self.tcx, ty, self.current_index.as_u32());
|
||||
}
|
||||
}
|
||||
_ if t.has_vars_bound_at_or_above(self.current_index) => {
|
||||
@ -926,7 +926,7 @@ impl<'tcx> TypeVisitor<'tcx> for ValidateBoundVars<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if t.outer_exclusive_binder < self.binder_index
|
||||
if t.outer_exclusive_binder() < self.binder_index
|
||||
|| !self.visited.insert((self.binder_index, t))
|
||||
{
|
||||
return ControlFlow::BREAK;
|
||||
@ -1146,7 +1146,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
||||
// bound at `outer_index` or above (because
|
||||
// `outer_exclusive_binder` is always 1 higher than the
|
||||
// content in `t`). Therefore, `t` has some escaping vars.
|
||||
if t.outer_exclusive_binder > self.outer_index {
|
||||
if t.outer_exclusive_binder() > self.outer_index {
|
||||
ControlFlow::Break(FoundEscapingVars)
|
||||
} else {
|
||||
ControlFlow::CONTINUE
|
||||
|
@ -3,7 +3,7 @@ pub use self::def_id_forest::DefIdForest;
|
||||
use crate::ty;
|
||||
use crate::ty::context::TyCtxt;
|
||||
use crate::ty::TyKind::*;
|
||||
use crate::ty::{AdtDef, FieldDef, Ty, TyS, VariantDef};
|
||||
use crate::ty::{AdtDef, FieldDef, Ty, VariantDef};
|
||||
use crate::ty::{AdtKind, Visibility};
|
||||
use crate::ty::{DefId, SubstsRef};
|
||||
|
||||
@ -184,10 +184,10 @@ impl<'tcx> FieldDef {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TyS<'tcx> {
|
||||
impl<'tcx> Ty<'tcx> {
|
||||
/// Calculates the forest of `DefId`s from which this type is visibly uninhabited.
|
||||
fn uninhabited_from(
|
||||
&'tcx self,
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> DefIdForest<'tcx> {
|
||||
|
@ -101,7 +101,7 @@ impl<'tcx> Instance<'tcx> {
|
||||
/// lifetimes erased, allowing a `ParamEnv` to be specified for use during normalization.
|
||||
pub fn ty(&self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Ty<'tcx> {
|
||||
let ty = tcx.type_of(self.def.def_id());
|
||||
tcx.subst_and_normalize_erasing_regions(self.substs, param_env, &ty)
|
||||
tcx.subst_and_normalize_erasing_regions(self.substs, param_env, ty)
|
||||
}
|
||||
|
||||
/// Finds a crate that contains a monomorphization of this instance that
|
||||
@ -642,7 +642,7 @@ fn polymorphize<'tcx>(
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
debug!("fold_ty: ty={:?}", ty);
|
||||
match ty.kind {
|
||||
match *ty.kind() {
|
||||
ty::Closure(def_id, substs) => {
|
||||
let polymorphized_substs = polymorphize(
|
||||
self.tcx,
|
||||
|
@ -29,6 +29,7 @@ use crate::ty::util::Discr;
|
||||
use rustc_ast as ast;
|
||||
use rustc_attr as attr;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_data_structures::tagged_ptr::CopyTaggedPtr;
|
||||
use rustc_hir as hir;
|
||||
@ -42,7 +43,6 @@ use rustc_span::symbol::{kw, Ident, Symbol};
|
||||
use rustc_span::{sym, Span};
|
||||
use rustc_target::abi::Align;
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::ops::ControlFlow;
|
||||
use std::{fmt, ptr, str};
|
||||
@ -380,21 +380,25 @@ pub struct CReaderCacheKey {
|
||||
|
||||
/// Represents a type.
|
||||
///
|
||||
/// IMPORTANT: Every `TyS` is *required* to have unique contents. The type's
|
||||
/// correctness relies on this, *but it does not enforce it*. Therefore, any
|
||||
/// code that creates a `TyS` must ensure uniqueness itself. In practice this
|
||||
/// is achieved by interning.
|
||||
/// IMPORTANT:
|
||||
/// - This is a very "dumb" struct (with no derives and no `impls`).
|
||||
/// - Values of this type are always interned and thus unique, and are stored
|
||||
/// as an `Interned<TyS>`.
|
||||
/// - `Ty` (which contains a reference to a `Interned<TyS>`) or `Interned<TyS>`
|
||||
/// should be used everywhere instead of `TyS`. In particular, `Ty` has most
|
||||
/// of the relevant methods.
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[allow(rustc::usage_of_ty_tykind)]
|
||||
pub struct TyS<'tcx> {
|
||||
crate struct TyS<'tcx> {
|
||||
/// This field shouldn't be used directly and may be removed in the future.
|
||||
/// Use `TyS::kind()` instead.
|
||||
/// Use `Ty::kind()` instead.
|
||||
kind: TyKind<'tcx>,
|
||||
|
||||
/// This field provides fast access to information that is also contained
|
||||
/// in `kind`.
|
||||
///
|
||||
/// This field shouldn't be used directly and may be removed in the future.
|
||||
/// Use `TyS::flags()` instead.
|
||||
/// Use `Ty::flags()` instead.
|
||||
flags: TypeFlags,
|
||||
|
||||
/// This field provides fast access to information that is also contained
|
||||
@ -420,55 +424,27 @@ pub struct TyS<'tcx> {
|
||||
outer_exclusive_binder: ty::DebruijnIndex,
|
||||
}
|
||||
|
||||
impl<'tcx> TyS<'tcx> {
|
||||
/// A constructor used only for internal testing.
|
||||
#[allow(rustc::usage_of_ty_tykind)]
|
||||
pub fn make_for_test(
|
||||
kind: TyKind<'tcx>,
|
||||
flags: TypeFlags,
|
||||
outer_exclusive_binder: ty::DebruijnIndex,
|
||||
) -> TyS<'tcx> {
|
||||
TyS { kind, flags, outer_exclusive_binder }
|
||||
}
|
||||
}
|
||||
|
||||
// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
static_assert_size!(TyS<'_>, 40);
|
||||
|
||||
impl<'tcx> Ord for TyS<'tcx> {
|
||||
fn cmp(&self, other: &TyS<'tcx>) -> Ordering {
|
||||
self.kind().cmp(other.kind())
|
||||
}
|
||||
}
|
||||
/// Use this rather than `TyS`, whenever possible.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[rustc_diagnostic_item = "Ty"]
|
||||
#[cfg_attr(not(bootstrap), rustc_pass_by_value)]
|
||||
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
|
||||
|
||||
impl<'tcx> PartialOrd for TyS<'tcx> {
|
||||
fn partial_cmp(&self, other: &TyS<'tcx>) -> Option<Ordering> {
|
||||
Some(self.kind().cmp(other.kind()))
|
||||
}
|
||||
}
|
||||
// Statics only used for internal testing.
|
||||
pub static BOOL_TY: Ty<'static> = Ty(Interned::new_unchecked(&BOOL_TYS));
|
||||
static BOOL_TYS: TyS<'static> = TyS {
|
||||
kind: ty::Bool,
|
||||
flags: TypeFlags::empty(),
|
||||
outer_exclusive_binder: DebruijnIndex::from_usize(0),
|
||||
};
|
||||
|
||||
impl<'tcx> PartialEq for TyS<'tcx> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &TyS<'tcx>) -> bool {
|
||||
// Pointer equality implies equality (due to the unique contents
|
||||
// assumption).
|
||||
ptr::eq(self, other)
|
||||
}
|
||||
}
|
||||
impl<'tcx> Eq for TyS<'tcx> {}
|
||||
|
||||
impl<'tcx> Hash for TyS<'tcx> {
|
||||
fn hash<H: Hasher>(&self, s: &mut H) {
|
||||
// Pointer hashing is sufficient (due to the unique contents
|
||||
// assumption).
|
||||
(self as *const TyS<'_>).hash(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TyS<'tcx> {
|
||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Ty<'tcx> {
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
let ty::TyS {
|
||||
let TyS {
|
||||
ref kind,
|
||||
|
||||
// The other fields just provide fast access to information that is
|
||||
@ -476,16 +452,12 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TyS<'tcx> {
|
||||
flags: _,
|
||||
|
||||
outer_exclusive_binder: _,
|
||||
} = *self;
|
||||
} = self.0.0;
|
||||
|
||||
kind.hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
#[rustc_diagnostic_item = "Ty"]
|
||||
#[cfg_attr(not(bootstrap), rustc_pass_by_value)]
|
||||
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
|
||||
|
||||
impl ty::EarlyBoundRegion {
|
||||
/// Does this early bound region have a name? Early bound regions normally
|
||||
/// always have names except when using anonymous lifetimes (`'_`).
|
||||
@ -864,7 +836,7 @@ impl<'tcx> From<&'tcx Const<'tcx>> for Term<'tcx> {
|
||||
|
||||
impl<'tcx> Term<'tcx> {
|
||||
pub fn ty(&self) -> Option<Ty<'tcx>> {
|
||||
if let Term::Ty(ty) = self { Some(ty) } else { None }
|
||||
if let Term::Ty(ty) = self { Some(*ty) } else { None }
|
||||
}
|
||||
pub fn ct(&self) -> Option<&'tcx Const<'tcx>> {
|
||||
if let Term::Const(c) = self { Some(c) } else { None }
|
||||
|
@ -346,7 +346,7 @@ impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for Ty<'tcx> {
|
||||
type Output = P::Type;
|
||||
type Error = P::Error;
|
||||
fn print(&self, cx: P) -> Result<Self::Output, Self::Error> {
|
||||
cx.print_type(self)
|
||||
cx.print_type(*self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ use crate::ty::subst::{GenericArg, GenericArgKind, Subst};
|
||||
use crate::ty::{self, ConstInt, DefIdTree, ParamConst, ScalarInt, Term, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_apfloat::ieee::{Double, Single};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_data_structures::sso::SsoHashSet;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
|
||||
@ -1232,16 +1233,20 @@ pub trait PrettyPrinter<'tcx>:
|
||||
// Byte strings (&[u8; N])
|
||||
ty::Ref(
|
||||
_,
|
||||
ty::TyS {
|
||||
kind:
|
||||
ty::Array(
|
||||
ty::TyS { kind: ty::Uint(ty::UintTy::U8), .. },
|
||||
ty::Const {
|
||||
val: ty::ConstKind::Value(ConstValue::Scalar(int)), ..
|
||||
},
|
||||
),
|
||||
..
|
||||
},
|
||||
Ty(Interned(
|
||||
ty::TyS {
|
||||
kind:
|
||||
ty::Array(
|
||||
Ty(Interned(ty::TyS { kind: ty::Uint(ty::UintTy::U8), .. }, _)),
|
||||
ty::Const {
|
||||
val: ty::ConstKind::Value(ConstValue::Scalar(int)),
|
||||
..
|
||||
},
|
||||
),
|
||||
..
|
||||
},
|
||||
_,
|
||||
)),
|
||||
_,
|
||||
) => match self.tcx().get_global_alloc(alloc_id) {
|
||||
Some(GlobalAlloc::Memory(alloc)) => {
|
||||
@ -1399,7 +1404,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
// Byte/string slices, printed as (byte) string literals.
|
||||
(
|
||||
ConstValue::Slice { data, start, end },
|
||||
ty::Ref(_, ty::TyS { kind: ty::Slice(t), .. }, _),
|
||||
ty::Ref(_, Ty(Interned(ty::TyS { kind: ty::Slice(t), .. }, _)), _),
|
||||
) if *t == u8_type => {
|
||||
// The `inspect` here is okay since we checked the bounds, and there are
|
||||
// no relocations (we have an active slice reference here). We don't use
|
||||
@ -1409,7 +1414,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
}
|
||||
(
|
||||
ConstValue::Slice { data, start, end },
|
||||
ty::Ref(_, ty::TyS { kind: ty::Str, .. }, _),
|
||||
ty::Ref(_, Ty(Interned(ty::TyS { kind: ty::Str, .. }, _)), _),
|
||||
) => {
|
||||
// The `inspect` here is okay since we checked the bounds, and there are no
|
||||
// relocations (we have an active `str` reference here). We don't use this
|
||||
|
@ -149,8 +149,8 @@ pub fn relate_substs<'tcx, R: TypeRelation<'tcx>>(
|
||||
Some((ty_def_id, variances)) => {
|
||||
let variance = variances[i];
|
||||
let variance_info = if variance == ty::Invariant {
|
||||
let ty =
|
||||
cached_ty.get_or_insert_with(|| tcx.type_of(ty_def_id).subst(tcx, a_subst));
|
||||
let ty = *cached_ty
|
||||
.get_or_insert_with(|| tcx.type_of(ty_def_id).subst(tcx, a_subst));
|
||||
ty::VarianceDiagInfo::Invariant { ty, param_index: i.try_into().unwrap() }
|
||||
} else {
|
||||
ty::VarianceDiagInfo::default()
|
||||
|
@ -1078,7 +1078,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
||||
}
|
||||
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
visitor.visit_ty(self)
|
||||
visitor.visit_ty(*self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ use crate::ty::fold::ValidateBoundVars;
|
||||
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
|
||||
use crate::ty::InferTy::{self, *};
|
||||
use crate::ty::{self, AdtDef, DefIdTree, Discr, Term, Ty, TyCtxt, TypeFlags, TypeFoldable};
|
||||
use crate::ty::{DelaySpanBugEmitted, List, ParamEnv, TyS};
|
||||
use crate::ty::{DelaySpanBugEmitted, List, ParamEnv};
|
||||
use polonius_engine::Atom;
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_hir as hir;
|
||||
@ -196,7 +196,7 @@ pub enum TyKind<'tcx> {
|
||||
Never,
|
||||
|
||||
/// A tuple type. For example, `(i32, bool)`.
|
||||
/// Use `TyS::tuple_fields` to iterate over the field types.
|
||||
/// Use `Ty::tuple_fields` to iterate over the field types.
|
||||
Tuple(SubstsRef<'tcx>),
|
||||
|
||||
/// The projection of an associated type. For example,
|
||||
@ -282,7 +282,7 @@ static_assert_size!(TyKind<'_>, 32);
|
||||
/// in scope on the function that defined the closure,
|
||||
/// - CK represents the *closure kind* (Fn vs FnMut vs FnOnce). This
|
||||
/// is rather hackily encoded via a scalar type. See
|
||||
/// `TyS::to_opt_closure_kind` for details.
|
||||
/// `Ty::to_opt_closure_kind` for details.
|
||||
/// - CS represents the *closure signature*, representing as a `fn()`
|
||||
/// type. For example, `fn(u32, u32) -> u32` would mean that the closure
|
||||
/// implements `CK<(u32, u32), Output = u32>`, where `CK` is the trait
|
||||
@ -1756,19 +1756,19 @@ impl RegionKind {
|
||||
}
|
||||
|
||||
/// Type utilities
|
||||
impl<'tcx> TyS<'tcx> {
|
||||
impl<'tcx> Ty<'tcx> {
|
||||
#[inline(always)]
|
||||
pub fn kind(&self) -> &TyKind<'tcx> {
|
||||
&self.kind
|
||||
pub fn kind(self) -> &'tcx TyKind<'tcx> {
|
||||
&self.0.0.kind
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn flags(&self) -> TypeFlags {
|
||||
self.flags
|
||||
pub fn flags(self) -> TypeFlags {
|
||||
self.0.0.flags
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_unit(&self) -> bool {
|
||||
pub fn is_unit(self) -> bool {
|
||||
match self.kind() {
|
||||
Tuple(ref tys) => tys.is_empty(),
|
||||
_ => false,
|
||||
@ -1776,32 +1776,32 @@ impl<'tcx> TyS<'tcx> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_never(&self) -> bool {
|
||||
pub fn is_never(self) -> bool {
|
||||
matches!(self.kind(), Never)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_primitive(&self) -> bool {
|
||||
pub fn is_primitive(self) -> bool {
|
||||
self.kind().is_primitive()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_adt(&self) -> bool {
|
||||
pub fn is_adt(self) -> bool {
|
||||
matches!(self.kind(), Adt(..))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_ref(&self) -> bool {
|
||||
pub fn is_ref(self) -> bool {
|
||||
matches!(self.kind(), Ref(..))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_ty_var(&self) -> bool {
|
||||
pub fn is_ty_var(self) -> bool {
|
||||
matches!(self.kind(), Infer(TyVar(_)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn ty_vid(&self) -> Option<ty::TyVid> {
|
||||
pub fn ty_vid(self) -> Option<ty::TyVid> {
|
||||
match self.kind() {
|
||||
&Infer(TyVar(vid)) => Some(vid),
|
||||
_ => None,
|
||||
@ -1809,28 +1809,28 @@ impl<'tcx> TyS<'tcx> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_ty_infer(&self) -> bool {
|
||||
pub fn is_ty_infer(self) -> bool {
|
||||
matches!(self.kind(), Infer(_))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_phantom_data(&self) -> bool {
|
||||
pub fn is_phantom_data(self) -> bool {
|
||||
if let Adt(def, _) = self.kind() { def.is_phantom_data() } else { false }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_bool(&self) -> bool {
|
||||
pub fn is_bool(self) -> bool {
|
||||
*self.kind() == Bool
|
||||
}
|
||||
|
||||
/// Returns `true` if this type is a `str`.
|
||||
#[inline]
|
||||
pub fn is_str(&self) -> bool {
|
||||
pub fn is_str(self) -> bool {
|
||||
*self.kind() == Str
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_param(&self, index: u32) -> bool {
|
||||
pub fn is_param(self, index: u32) -> bool {
|
||||
match self.kind() {
|
||||
ty::Param(ref data) => data.index == index,
|
||||
_ => false,
|
||||
@ -1838,7 +1838,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_slice(&self) -> bool {
|
||||
pub fn is_slice(self) -> bool {
|
||||
match self.kind() {
|
||||
RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => matches!(ty.kind(), Slice(_) | Str),
|
||||
_ => false,
|
||||
@ -1846,27 +1846,27 @@ impl<'tcx> TyS<'tcx> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_array(&self) -> bool {
|
||||
pub fn is_array(self) -> bool {
|
||||
matches!(self.kind(), Array(..))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_simd(&self) -> bool {
|
||||
pub fn is_simd(self) -> bool {
|
||||
match self.kind() {
|
||||
Adt(def, _) => def.repr.simd(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sequence_element_type(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
pub fn sequence_element_type(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
match self.kind() {
|
||||
Array(ty, _) | Slice(ty) => ty,
|
||||
Array(ty, _) | Slice(ty) => *ty,
|
||||
Str => tcx.types.u8,
|
||||
_ => bug!("`sequence_element_type` called on non-sequence value: {}", self),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn simd_size_and_type(&self, tcx: TyCtxt<'tcx>) -> (u64, Ty<'tcx>) {
|
||||
pub fn simd_size_and_type(self, tcx: TyCtxt<'tcx>) -> (u64, Ty<'tcx>) {
|
||||
match self.kind() {
|
||||
Adt(def, substs) => {
|
||||
assert!(def.repr.simd(), "`simd_size_and_type` called on non-SIMD type");
|
||||
@ -1881,7 +1881,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
// The way we evaluate the `N` in `[T; N]` here only works since we use
|
||||
// `simd_size_and_type` post-monomorphization. It will probably start to ICE
|
||||
// if we use it in generic code. See the `simd-array-trait` ui test.
|
||||
(f0_len.eval_usize(tcx, ParamEnv::empty()) as u64, f0_elem_ty)
|
||||
(f0_len.eval_usize(tcx, ParamEnv::empty()) as u64, *f0_elem_ty)
|
||||
}
|
||||
// Otherwise, the fields of this Adt are the SIMD components (and we assume they
|
||||
// all have the same type).
|
||||
@ -1893,12 +1893,12 @@ impl<'tcx> TyS<'tcx> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_region_ptr(&self) -> bool {
|
||||
pub fn is_region_ptr(self) -> bool {
|
||||
matches!(self.kind(), Ref(..))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_mutable_ptr(&self) -> bool {
|
||||
pub fn is_mutable_ptr(self) -> bool {
|
||||
matches!(
|
||||
self.kind(),
|
||||
RawPtr(TypeAndMut { mutbl: hir::Mutability::Mut, .. })
|
||||
@ -1908,7 +1908,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
|
||||
/// Get the mutability of the reference or `None` when not a reference
|
||||
#[inline]
|
||||
pub fn ref_mutability(&self) -> Option<hir::Mutability> {
|
||||
pub fn ref_mutability(self) -> Option<hir::Mutability> {
|
||||
match self.kind() {
|
||||
Ref(_, _, mutability) => Some(*mutability),
|
||||
_ => None,
|
||||
@ -1916,18 +1916,18 @@ impl<'tcx> TyS<'tcx> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_unsafe_ptr(&self) -> bool {
|
||||
pub fn is_unsafe_ptr(self) -> bool {
|
||||
matches!(self.kind(), RawPtr(_))
|
||||
}
|
||||
|
||||
/// Tests if this is any kind of primitive pointer type (reference, raw pointer, fn pointer).
|
||||
#[inline]
|
||||
pub fn is_any_ptr(&self) -> bool {
|
||||
pub fn is_any_ptr(self) -> bool {
|
||||
self.is_region_ptr() || self.is_unsafe_ptr() || self.is_fn_ptr()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_box(&self) -> bool {
|
||||
pub fn is_box(self) -> bool {
|
||||
match self.kind() {
|
||||
Adt(def, _) => def.is_box(),
|
||||
_ => false,
|
||||
@ -1935,7 +1935,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
}
|
||||
|
||||
/// Panics if called on any type other than `Box<T>`.
|
||||
pub fn boxed_ty(&self) -> Ty<'tcx> {
|
||||
pub fn boxed_ty(self) -> Ty<'tcx> {
|
||||
match self.kind() {
|
||||
Adt(def, substs) if def.is_box() => substs.type_at(0),
|
||||
_ => bug!("`boxed_ty` is called on non-box type {:?}", self),
|
||||
@ -1946,7 +1946,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
/// (A RawPtr is scalar because it represents a non-managed pointer, so its
|
||||
/// contents are abstract to rustc.)
|
||||
#[inline]
|
||||
pub fn is_scalar(&self) -> bool {
|
||||
pub fn is_scalar(self) -> bool {
|
||||
matches!(
|
||||
self.kind(),
|
||||
Bool | Char
|
||||
@ -1962,72 +1962,72 @@ impl<'tcx> TyS<'tcx> {
|
||||
|
||||
/// Returns `true` if this type is a floating point type.
|
||||
#[inline]
|
||||
pub fn is_floating_point(&self) -> bool {
|
||||
pub fn is_floating_point(self) -> bool {
|
||||
matches!(self.kind(), Float(_) | Infer(FloatVar(_)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_trait(&self) -> bool {
|
||||
pub fn is_trait(self) -> bool {
|
||||
matches!(self.kind(), Dynamic(..))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_enum(&self) -> bool {
|
||||
pub fn is_enum(self) -> bool {
|
||||
matches!(self.kind(), Adt(adt_def, _) if adt_def.is_enum())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_union(&self) -> bool {
|
||||
pub fn is_union(self) -> bool {
|
||||
matches!(self.kind(), Adt(adt_def, _) if adt_def.is_union())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_closure(&self) -> bool {
|
||||
pub fn is_closure(self) -> bool {
|
||||
matches!(self.kind(), Closure(..))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_generator(&self) -> bool {
|
||||
pub fn is_generator(self) -> bool {
|
||||
matches!(self.kind(), Generator(..))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_integral(&self) -> bool {
|
||||
pub fn is_integral(self) -> bool {
|
||||
matches!(self.kind(), Infer(IntVar(_)) | Int(_) | Uint(_))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_fresh_ty(&self) -> bool {
|
||||
pub fn is_fresh_ty(self) -> bool {
|
||||
matches!(self.kind(), Infer(FreshTy(_)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_fresh(&self) -> bool {
|
||||
pub fn is_fresh(self) -> bool {
|
||||
matches!(self.kind(), Infer(FreshTy(_) | FreshIntTy(_) | FreshFloatTy(_)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_char(&self) -> bool {
|
||||
pub fn is_char(self) -> bool {
|
||||
matches!(self.kind(), Char)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_numeric(&self) -> bool {
|
||||
pub fn is_numeric(self) -> bool {
|
||||
self.is_integral() || self.is_floating_point()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_signed(&self) -> bool {
|
||||
pub fn is_signed(self) -> bool {
|
||||
matches!(self.kind(), Int(_))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_ptr_sized_integral(&self) -> bool {
|
||||
pub fn is_ptr_sized_integral(self) -> bool {
|
||||
matches!(self.kind(), Int(ty::IntTy::Isize) | Uint(ty::UintTy::Usize))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_concrete_skeleton(&self) -> bool {
|
||||
pub fn has_concrete_skeleton(self) -> bool {
|
||||
!matches!(self.kind(), Param(_) | Infer(_) | Error(_))
|
||||
}
|
||||
|
||||
@ -2035,26 +2035,26 @@ impl<'tcx> TyS<'tcx> {
|
||||
///
|
||||
/// The parameter `explicit` indicates if this is an *explicit* dereference.
|
||||
/// Some types -- notably unsafe ptrs -- can only be dereferenced explicitly.
|
||||
pub fn builtin_deref(&self, explicit: bool) -> Option<TypeAndMut<'tcx>> {
|
||||
pub fn builtin_deref(self, explicit: bool) -> Option<TypeAndMut<'tcx>> {
|
||||
match self.kind() {
|
||||
Adt(def, _) if def.is_box() => {
|
||||
Some(TypeAndMut { ty: self.boxed_ty(), mutbl: hir::Mutability::Not })
|
||||
}
|
||||
Ref(_, ty, mutbl) => Some(TypeAndMut { ty, mutbl: *mutbl }),
|
||||
Ref(_, ty, mutbl) => Some(TypeAndMut { ty: *ty, mutbl: *mutbl }),
|
||||
RawPtr(mt) if explicit => Some(*mt),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the type of `ty[i]`.
|
||||
pub fn builtin_index(&self) -> Option<Ty<'tcx>> {
|
||||
pub fn builtin_index(self) -> Option<Ty<'tcx>> {
|
||||
match self.kind() {
|
||||
Array(ty, _) | Slice(ty) => Some(ty),
|
||||
Array(ty, _) | Slice(ty) => Some(*ty),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fn_sig(&self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> {
|
||||
pub fn fn_sig(self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> {
|
||||
match self.kind() {
|
||||
FnDef(def_id, substs) => tcx.fn_sig(*def_id).subst(tcx, substs),
|
||||
FnPtr(f) => *f,
|
||||
@ -2070,22 +2070,22 @@ impl<'tcx> TyS<'tcx> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_fn(&self) -> bool {
|
||||
pub fn is_fn(self) -> bool {
|
||||
matches!(self.kind(), FnDef(..) | FnPtr(_))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_fn_ptr(&self) -> bool {
|
||||
pub fn is_fn_ptr(self) -> bool {
|
||||
matches!(self.kind(), FnPtr(_))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_impl_trait(&self) -> bool {
|
||||
pub fn is_impl_trait(self) -> bool {
|
||||
matches!(self.kind(), Opaque(..))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> {
|
||||
pub fn ty_adt_def(self) -> Option<&'tcx AdtDef> {
|
||||
match self.kind() {
|
||||
Adt(adt, _) => Some(adt),
|
||||
_ => None,
|
||||
@ -2094,7 +2094,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
|
||||
/// Iterates over tuple fields.
|
||||
/// Panics when called on anything but a tuple.
|
||||
pub fn tuple_fields(&self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> {
|
||||
pub fn tuple_fields(self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> {
|
||||
match self.kind() {
|
||||
Tuple(substs) => substs.iter().map(|field| field.expect_ty()),
|
||||
_ => bug!("tuple_fields called on non-tuple"),
|
||||
@ -2103,7 +2103,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
|
||||
/// Get the `i`-th element of a tuple.
|
||||
/// Panics when called on anything but a tuple.
|
||||
pub fn tuple_element_ty(&self, i: usize) -> Option<Ty<'tcx>> {
|
||||
pub fn tuple_element_ty(self, i: usize) -> Option<Ty<'tcx>> {
|
||||
match self.kind() {
|
||||
Tuple(substs) => substs.iter().nth(i).map(|field| field.expect_ty()),
|
||||
_ => bug!("tuple_fields called on non-tuple"),
|
||||
@ -2114,7 +2114,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
//
|
||||
// FIXME: This requires the optimized MIR in the case of generators.
|
||||
#[inline]
|
||||
pub fn variant_range(&self, tcx: TyCtxt<'tcx>) -> Option<Range<VariantIdx>> {
|
||||
pub fn variant_range(self, tcx: TyCtxt<'tcx>) -> Option<Range<VariantIdx>> {
|
||||
match self.kind() {
|
||||
TyKind::Adt(adt, _) => Some(adt.variant_range()),
|
||||
TyKind::Generator(def_id, substs, _) => {
|
||||
@ -2130,7 +2130,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
// FIXME: This requires the optimized MIR in the case of generators.
|
||||
#[inline]
|
||||
pub fn discriminant_for_variant(
|
||||
&self,
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
variant_index: VariantIdx,
|
||||
) -> Option<Discr<'tcx>> {
|
||||
@ -2151,7 +2151,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
}
|
||||
|
||||
/// Returns the type of the discriminant of this type.
|
||||
pub fn discriminant_ty(&'tcx self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
pub fn discriminant_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
match self.kind() {
|
||||
ty::Adt(adt, _) if adt.is_enum() => adt.repr.discr_type().to_ty(tcx),
|
||||
ty::Generator(_, substs, _) => substs.as_generator().discr_ty(tcx),
|
||||
@ -2195,7 +2195,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
|
||||
/// Returns the type of metadata for (potentially fat) pointers to this type.
|
||||
pub fn ptr_metadata_ty(
|
||||
&'tcx self,
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
@ -2256,7 +2256,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
/// to represent the closure kind, because it has not yet been
|
||||
/// inferred. Once upvar inference (in `rustc_typeck/src/check/upvar.rs`)
|
||||
/// is complete, that type variable will be unified.
|
||||
pub fn to_opt_closure_kind(&self) -> Option<ty::ClosureKind> {
|
||||
pub fn to_opt_closure_kind(self) -> Option<ty::ClosureKind> {
|
||||
match self.kind() {
|
||||
Int(int_ty) => match int_ty {
|
||||
ty::IntTy::I8 => Some(ty::ClosureKind::Fn),
|
||||
@ -2285,7 +2285,7 @@ impl<'tcx> TyS<'tcx> {
|
||||
/// bound such as `[_]: Copy`. A function with such a bound obviously never
|
||||
/// can be called, but that doesn't mean it shouldn't typecheck. This is why
|
||||
/// this method doesn't return `Option<bool>`.
|
||||
pub fn is_trivially_sized(&self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
pub fn is_trivially_sized(self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
match self.kind() {
|
||||
ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
|
||||
| ty::Uint(_)
|
||||
|
@ -6,6 +6,7 @@ use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeVisitor}
|
||||
use crate::ty::sty::{ClosureSubsts, GeneratorSubsts, InlineConstSubsts};
|
||||
use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt};
|
||||
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_serialize::{self, Decodable, Encodable};
|
||||
@ -49,17 +50,17 @@ impl<'tcx> GenericArgKind<'tcx> {
|
||||
GenericArgKind::Lifetime(lt) => {
|
||||
// Ensure we can use the tag bits.
|
||||
assert_eq!(mem::align_of_val(lt) & TAG_MASK, 0);
|
||||
(REGION_TAG, lt as *const _ as usize)
|
||||
(REGION_TAG, lt as *const ty::RegionKind as usize)
|
||||
}
|
||||
GenericArgKind::Type(ty) => {
|
||||
// Ensure we can use the tag bits.
|
||||
assert_eq!(mem::align_of_val(ty) & TAG_MASK, 0);
|
||||
(TYPE_TAG, ty as *const _ as usize)
|
||||
assert_eq!(mem::align_of_val(ty.0.0) & TAG_MASK, 0);
|
||||
(TYPE_TAG, ty.0.0 as *const ty::TyS<'tcx> as usize)
|
||||
}
|
||||
GenericArgKind::Const(ct) => {
|
||||
// Ensure we can use the tag bits.
|
||||
assert_eq!(mem::align_of_val(ct) & TAG_MASK, 0);
|
||||
(CONST_TAG, ct as *const _ as usize)
|
||||
(CONST_TAG, ct as *const ty::Const<'tcx> as usize)
|
||||
}
|
||||
};
|
||||
|
||||
@ -111,11 +112,18 @@ impl<'tcx> GenericArg<'tcx> {
|
||||
#[inline]
|
||||
pub fn unpack(self) -> GenericArgKind<'tcx> {
|
||||
let ptr = self.ptr.get();
|
||||
// SAFETY: use of `Interned::new_unchecked` here is ok because these
|
||||
// pointers were originally created from `Interned` types in `pack()`,
|
||||
// and this is just going in the other direction.
|
||||
unsafe {
|
||||
match ptr & TAG_MASK {
|
||||
REGION_TAG => GenericArgKind::Lifetime(&*((ptr & !TAG_MASK) as *const _)),
|
||||
TYPE_TAG => GenericArgKind::Type(&*((ptr & !TAG_MASK) as *const _)),
|
||||
CONST_TAG => GenericArgKind::Const(&*((ptr & !TAG_MASK) as *const _)),
|
||||
REGION_TAG => {
|
||||
GenericArgKind::Lifetime(&*((ptr & !TAG_MASK) as *const ty::RegionKind))
|
||||
}
|
||||
TYPE_TAG => GenericArgKind::Type(Ty(Interned::new_unchecked(
|
||||
&*((ptr & !TAG_MASK) as *const ty::TyS<'tcx>),
|
||||
))),
|
||||
CONST_TAG => GenericArgKind::Const(&*((ptr & !TAG_MASK) as *const ty::Const<'tcx>)),
|
||||
_ => intrinsics::unreachable(),
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ use rustc_apfloat::Float as _;
|
||||
use rustc_ast as ast;
|
||||
use rustc_attr::{self as attr, SignedInt, UnsignedInt};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_hir as hir;
|
||||
@ -392,9 +393,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
GenericArgKind::Lifetime(&ty::RegionKind::ReEarlyBound(ref ebr)) => {
|
||||
!impl_generics.region_param(ebr, self).pure_wrt_drop
|
||||
}
|
||||
GenericArgKind::Type(&ty::TyS { kind: ty::Param(ref pt), .. }) => {
|
||||
!impl_generics.type_param(pt, self).pure_wrt_drop
|
||||
}
|
||||
GenericArgKind::Type(Ty(Interned(
|
||||
ty::TyS { kind: ty::Param(ref pt), .. },
|
||||
_,
|
||||
))) => !impl_generics.type_param(pt, self).pure_wrt_drop,
|
||||
GenericArgKind::Const(&ty::Const {
|
||||
val: ty::ConstKind::Param(ref pc), ..
|
||||
}) => !impl_generics.const_param(pc, self).pure_wrt_drop,
|
||||
@ -577,7 +579,7 @@ impl<'tcx> OpaqueTypeExpander<'tcx> {
|
||||
let substs = substs.fold_with(self);
|
||||
if !self.check_recursion || self.seen_opaque_tys.insert(def_id) {
|
||||
let expanded_ty = match self.expanded_cache.get(&(def_id, substs)) {
|
||||
Some(expanded_ty) => expanded_ty,
|
||||
Some(expanded_ty) => *expanded_ty,
|
||||
None => {
|
||||
let generic_ty = self.tcx.type_of(def_id);
|
||||
let concrete_ty = generic_ty.subst(self.tcx, substs);
|
||||
@ -606,7 +608,7 @@ impl<'tcx> TypeFolder<'tcx> for OpaqueTypeExpander<'tcx> {
|
||||
}
|
||||
|
||||
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
|
||||
if let ty::Opaque(def_id, substs) = t.kind {
|
||||
if let ty::Opaque(def_id, substs) = *t.kind() {
|
||||
self.expand_opaque_ty(def_id, substs).unwrap_or(t)
|
||||
} else if t.has_opaque_types() {
|
||||
t.super_fold_with(self)
|
||||
@ -616,10 +618,10 @@ impl<'tcx> TypeFolder<'tcx> for OpaqueTypeExpander<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ty::TyS<'tcx> {
|
||||
impl<'tcx> Ty<'tcx> {
|
||||
/// Returns the maximum value for the given numeric type (including `char`s)
|
||||
/// or returns `None` if the type is not numeric.
|
||||
pub fn numeric_max_val(&'tcx self, tcx: TyCtxt<'tcx>) -> Option<&'tcx ty::Const<'tcx>> {
|
||||
pub fn numeric_max_val(self, tcx: TyCtxt<'tcx>) -> Option<&'tcx ty::Const<'tcx>> {
|
||||
let val = match self.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => {
|
||||
let (size, signed) = int_size_and_signed(tcx, self);
|
||||
@ -639,7 +641,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
|
||||
/// Returns the minimum value for the given numeric type (including `char`s)
|
||||
/// or returns `None` if the type is not numeric.
|
||||
pub fn numeric_min_val(&'tcx self, tcx: TyCtxt<'tcx>) -> Option<&'tcx ty::Const<'tcx>> {
|
||||
pub fn numeric_min_val(self, tcx: TyCtxt<'tcx>) -> Option<&'tcx ty::Const<'tcx>> {
|
||||
let val = match self.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => {
|
||||
let (size, signed) = int_size_and_signed(tcx, self);
|
||||
@ -664,7 +666,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
/// full requirements for the `Copy` trait (cc #29149) -- this
|
||||
/// winds up being reported as an error during NLL borrow check.
|
||||
pub fn is_copy_modulo_regions(
|
||||
&'tcx self,
|
||||
self,
|
||||
tcx_at: TyCtxtAt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> bool {
|
||||
@ -677,7 +679,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
/// over-approximation in generic contexts, where one can have
|
||||
/// strange rules like `<T as Foo<'static>>::Bar: Sized` that
|
||||
/// actually carry lifetime requirements.
|
||||
pub fn is_sized(&'tcx self, tcx_at: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
|
||||
pub fn is_sized(self, tcx_at: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
|
||||
self.is_trivially_sized(tcx_at.tcx) || tcx_at.is_sized_raw(param_env.and(self))
|
||||
}
|
||||
|
||||
@ -688,7 +690,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
/// optimization as well as the rules around static values. Note
|
||||
/// that the `Freeze` trait is not exposed to end users and is
|
||||
/// effectively an implementation detail.
|
||||
pub fn is_freeze(&'tcx self, tcx_at: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
|
||||
pub fn is_freeze(self, tcx_at: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
|
||||
self.is_trivially_freeze() || tcx_at.is_freeze_raw(param_env.and(self))
|
||||
}
|
||||
|
||||
@ -696,7 +698,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
///
|
||||
/// Returning true means the type is known to be `Freeze`. Returning
|
||||
/// `false` means nothing -- could be `Freeze`, might not be.
|
||||
fn is_trivially_freeze(&self) -> bool {
|
||||
fn is_trivially_freeze(self) -> bool {
|
||||
match self.kind() {
|
||||
ty::Int(_)
|
||||
| ty::Uint(_)
|
||||
@ -710,7 +712,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
| ty::FnDef(..)
|
||||
| ty::Error(_)
|
||||
| ty::FnPtr(_) => true,
|
||||
ty::Tuple(_) => self.tuple_fields().all(Self::is_trivially_freeze),
|
||||
ty::Tuple(_) => self.tuple_fields().all(|f| Self::is_trivially_freeze(f)),
|
||||
ty::Slice(elem_ty) | ty::Array(elem_ty, _) => elem_ty.is_trivially_freeze(),
|
||||
ty::Adt(..)
|
||||
| ty::Bound(..)
|
||||
@ -728,7 +730,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
}
|
||||
|
||||
/// Checks whether values of this type `T` implement the `Unpin` trait.
|
||||
pub fn is_unpin(&'tcx self, tcx_at: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
|
||||
pub fn is_unpin(self, tcx_at: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
|
||||
self.is_trivially_unpin() || tcx_at.is_unpin_raw(param_env.and(self))
|
||||
}
|
||||
|
||||
@ -736,7 +738,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
///
|
||||
/// Returning true means the type is known to be `Unpin`. Returning
|
||||
/// `false` means nothing -- could be `Unpin`, might not be.
|
||||
fn is_trivially_unpin(&self) -> bool {
|
||||
fn is_trivially_unpin(self) -> bool {
|
||||
match self.kind() {
|
||||
ty::Int(_)
|
||||
| ty::Uint(_)
|
||||
@ -750,7 +752,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
| ty::FnDef(..)
|
||||
| ty::Error(_)
|
||||
| ty::FnPtr(_) => true,
|
||||
ty::Tuple(_) => self.tuple_fields().all(Self::is_trivially_unpin),
|
||||
ty::Tuple(_) => self.tuple_fields().all(|f| Self::is_trivially_unpin(f)),
|
||||
ty::Slice(elem_ty) | ty::Array(elem_ty, _) => elem_ty.is_trivially_unpin(),
|
||||
ty::Adt(..)
|
||||
| ty::Bound(..)
|
||||
@ -776,7 +778,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
///
|
||||
/// Note that this method is used to check eligible types in unions.
|
||||
#[inline]
|
||||
pub fn needs_drop(&'tcx self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
|
||||
pub fn needs_drop(self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
|
||||
// Avoid querying in simple cases.
|
||||
match needs_drop_components(self, &tcx.data_layout) {
|
||||
Err(AlwaysRequiresDrop) => true,
|
||||
@ -809,11 +811,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
/// Note that this method is used to check for change in drop order for
|
||||
/// 2229 drop reorder migration analysis.
|
||||
#[inline]
|
||||
pub fn has_significant_drop(
|
||||
&'tcx self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> bool {
|
||||
pub fn has_significant_drop(self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
|
||||
// Avoid querying in simple cases.
|
||||
match needs_drop_components(self, &tcx.data_layout) {
|
||||
Err(AlwaysRequiresDrop) => true,
|
||||
@ -858,7 +856,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
/// want to know whether a given call to `PartialEq::eq` will proceed structurally all the way
|
||||
/// down, you will need to use a type visitor.
|
||||
#[inline]
|
||||
pub fn is_structural_eq_shallow(&'tcx self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
pub fn is_structural_eq_shallow(self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
match self.kind() {
|
||||
// Look for an impl of both `PartialStructuralEq` and `StructuralEq`.
|
||||
Adt(..) => tcx.has_structural_eq_impls(self),
|
||||
@ -903,16 +901,16 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
/// - `&'a mut u8` -> `u8`
|
||||
/// - `&'a &'b u8` -> `u8`
|
||||
/// - `&'a *const &'b u8 -> *const &'b u8`
|
||||
pub fn peel_refs(&'tcx self) -> Ty<'tcx> {
|
||||
pub fn peel_refs(self) -> Ty<'tcx> {
|
||||
let mut ty = self;
|
||||
while let Ref(_, inner_ty, _) = ty.kind() {
|
||||
ty = inner_ty;
|
||||
ty = *inner_ty;
|
||||
}
|
||||
ty
|
||||
}
|
||||
|
||||
pub fn outer_exclusive_binder(&'tcx self) -> DebruijnIndex {
|
||||
self.outer_exclusive_binder
|
||||
pub fn outer_exclusive_binder(self) -> DebruijnIndex {
|
||||
self.0.outer_exclusive_binder
|
||||
}
|
||||
}
|
||||
|
||||
@ -993,9 +991,9 @@ pub fn needs_drop_components<'tcx>(
|
||||
|
||||
ty::Dynamic(..) | ty::Error(_) => Err(AlwaysRequiresDrop),
|
||||
|
||||
ty::Slice(ty) => needs_drop_components(ty, target_layout),
|
||||
ty::Slice(ty) => needs_drop_components(*ty, target_layout),
|
||||
ty::Array(elem_ty, size) => {
|
||||
match needs_drop_components(elem_ty, target_layout) {
|
||||
match needs_drop_components(*elem_ty, target_layout) {
|
||||
Ok(v) if v.is_empty() => Ok(v),
|
||||
res => match size.val.try_to_bits(target_layout.pointer_size) {
|
||||
// Arrays of size zero don't need drop, even if their element
|
||||
|
@ -1,8 +1,8 @@
|
||||
//! An iterator over the type substructure.
|
||||
//! WARNING: this does not keep track of the region depth.
|
||||
|
||||
use crate::ty;
|
||||
use crate::ty::subst::{GenericArg, GenericArgKind};
|
||||
use crate::ty::{self, Ty};
|
||||
use rustc_data_structures::sso::SsoHashSet;
|
||||
use smallvec::{self, SmallVec};
|
||||
|
||||
@ -96,7 +96,7 @@ impl<'tcx> GenericArg<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> super::TyS<'tcx> {
|
||||
impl<'tcx> Ty<'tcx> {
|
||||
/// Iterator that walks `self` and any types reachable from
|
||||
/// `self`, in depth-first order. Note that just walks the types
|
||||
/// that appear in `self`, it does not descend into the fields of
|
||||
@ -107,7 +107,7 @@ impl<'tcx> super::TyS<'tcx> {
|
||||
/// Foo<Bar<isize>> => { Foo<Bar<isize>>, Bar<isize>, isize }
|
||||
/// [isize] => { [isize], isize }
|
||||
/// ```
|
||||
pub fn walk(&'tcx self) -> TypeWalker<'tcx> {
|
||||
pub fn walk(self) -> TypeWalker<'tcx> {
|
||||
TypeWalker::new(self.into())
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
let place_builder = place_builder.clone();
|
||||
this.consume_by_copy_or_move(
|
||||
place_builder
|
||||
.field(n, ty)
|
||||
.field(n, *ty)
|
||||
.into_place(this.tcx, this.typeck_results),
|
||||
)
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
(Some((region, elem_ty, _)), _) | (None, Some((region, elem_ty, _))) => {
|
||||
let tcx = self.tcx;
|
||||
// make both a slice
|
||||
ty = tcx.mk_imm_ref(region, tcx.mk_slice(elem_ty));
|
||||
ty = tcx.mk_imm_ref(region, tcx.mk_slice(*elem_ty));
|
||||
if opt_ref_ty.is_some() {
|
||||
let temp = self.temp(ty, source_info.span);
|
||||
self.cfg.push_assign(
|
||||
|
@ -903,7 +903,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
let mut closure_ty = self.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty;
|
||||
if let ty::Ref(_, ty, _) = closure_ty.kind() {
|
||||
closure_env_projs.push(ProjectionElem::Deref);
|
||||
closure_ty = ty;
|
||||
closure_ty = *ty;
|
||||
}
|
||||
let upvar_substs = match closure_ty.kind() {
|
||||
ty::Closure(_, substs) => ty::UpvarSubsts::Closure(substs),
|
||||
|
@ -556,7 +556,7 @@ fn non_exhaustive_match<'p, 'tcx>(
|
||||
}
|
||||
}
|
||||
if let ty::Ref(_, sub_ty, _) = scrut_ty.kind() {
|
||||
if cx.tcx.is_ty_uninhabited_from(cx.module, sub_ty, cx.param_env) {
|
||||
if cx.tcx.is_ty_uninhabited_from(cx.module, *sub_ty, cx.param_env) {
|
||||
err.note("references are always considered inhabited");
|
||||
}
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
|
||||
suffix: vec![],
|
||||
}),
|
||||
span,
|
||||
ty: pointee_ty,
|
||||
ty: *pointee_ty,
|
||||
},
|
||||
};
|
||||
self.behind_reference.set(old);
|
||||
@ -457,7 +457,7 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
|
||||
// this pattern to a `PartialEq::eq` comparison and `PartialEq::eq` takes a
|
||||
// reference. This makes the rest of the matching logic simpler as it doesn't have
|
||||
// to figure out how to get a reference again.
|
||||
ty::Adt(adt_def, _) if !self.type_marked_structural(pointee_ty) => {
|
||||
ty::Adt(adt_def, _) if !self.type_marked_structural(*pointee_ty) => {
|
||||
if self.behind_reference.get() {
|
||||
if self.include_lint_checks
|
||||
&& !self.saw_const_match_error.get()
|
||||
|
@ -929,7 +929,7 @@ impl<'tcx> SplitWildcard<'tcx> {
|
||||
ty::Bool => smallvec![make_range(0, 1)],
|
||||
ty::Array(sub_ty, len) if len.try_eval_usize(cx.tcx, cx.param_env).is_some() => {
|
||||
let len = len.eval_usize(cx.tcx, cx.param_env) as usize;
|
||||
if len != 0 && cx.is_uninhabited(sub_ty) {
|
||||
if len != 0 && cx.is_uninhabited(*sub_ty) {
|
||||
smallvec![]
|
||||
} else {
|
||||
smallvec![Slice(Slice::new(Some(len), VarLen(0, 0)))]
|
||||
@ -937,7 +937,7 @@ impl<'tcx> SplitWildcard<'tcx> {
|
||||
}
|
||||
// Treat arrays of a constant but unknown length like slices.
|
||||
ty::Array(sub_ty, _) | ty::Slice(sub_ty) => {
|
||||
let kind = if cx.is_uninhabited(sub_ty) { FixedLen(0) } else { VarLen(0, 0) };
|
||||
let kind = if cx.is_uninhabited(*sub_ty) { FixedLen(0) } else { VarLen(0, 0) };
|
||||
smallvec![Slice(Slice::new(None, kind))]
|
||||
}
|
||||
ty::Adt(def, substs) if def.is_enum() => {
|
||||
@ -1386,7 +1386,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
||||
// fields.
|
||||
// Note: `t` is `str`, not `&str`.
|
||||
let subpattern =
|
||||
DeconstructedPat::new(Str(value), Fields::empty(), t, pat.span);
|
||||
DeconstructedPat::new(Str(value), Fields::empty(), *t, pat.span);
|
||||
ctor = Single;
|
||||
fields = Fields::singleton(cx, subpattern)
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
||||
debug!("{:?}: wrapping pattern with type {:?}", pat, ref_ty);
|
||||
Pat {
|
||||
span: pat.span,
|
||||
ty: ref_ty,
|
||||
ty: *ref_ty,
|
||||
kind: Box::new(PatKind::Deref { subpattern: pat }),
|
||||
}
|
||||
},
|
||||
@ -275,7 +275,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
||||
let var_ty = ty;
|
||||
if let ty::BindByReference(_) = bm {
|
||||
if let ty::Ref(_, rty, _) = ty.kind() {
|
||||
ty = rty;
|
||||
ty = *rty;
|
||||
} else {
|
||||
bug!("`ref {}` has wrong type {}", ident, ty);
|
||||
}
|
||||
|
@ -880,9 +880,9 @@ where
|
||||
ty::Dynamic(..) => self.complete_drop(self.succ, self.unwind),
|
||||
ty::Array(ety, size) => {
|
||||
let size = size.try_eval_usize(self.tcx(), self.elaborator.param_env());
|
||||
self.open_drop_for_array(ety, size)
|
||||
self.open_drop_for_array(*ety, size)
|
||||
}
|
||||
ty::Slice(ety) => self.open_drop_for_array(ety, None),
|
||||
ty::Slice(ety) => self.open_drop_for_array(*ety, None),
|
||||
|
||||
_ => bug!("open drop from non-ADT `{:?}`", ty),
|
||||
}
|
||||
|
@ -841,7 +841,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
// Found a value represented as a pair. For now only do const-prop if the type
|
||||
// of `rvalue` is also a tuple with two scalars.
|
||||
// FIXME: enable the general case stated above ^.
|
||||
let ty = &value.layout.ty;
|
||||
let ty = value.layout.ty;
|
||||
// Only do it for tuples
|
||||
if let ty::Tuple(substs) = ty.kind() {
|
||||
// Only do it if tuple is also a pair with two scalars
|
||||
|
@ -37,24 +37,12 @@ use rustc_data_structures::graph::WithSuccessors;
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_middle::mir::coverage::CoverageKind;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{self, DebruijnIndex, TyS, TypeFlags};
|
||||
use rustc_middle::ty::{self, BOOL_TY};
|
||||
use rustc_span::{self, BytePos, Pos, Span, DUMMY_SP};
|
||||
|
||||
// All `TEMP_BLOCK` targets should be replaced before calling `to_body() -> mir::Body`.
|
||||
const TEMP_BLOCK: BasicBlock = BasicBlock::MAX;
|
||||
|
||||
fn dummy_ty() -> &'static TyS<'static> {
|
||||
thread_local! {
|
||||
static DUMMY_TYS: &'static TyS<'static> = Box::leak(Box::new(TyS::make_for_test(
|
||||
ty::Bool,
|
||||
TypeFlags::empty(),
|
||||
DebruijnIndex::from_usize(0),
|
||||
)));
|
||||
}
|
||||
|
||||
&DUMMY_TYS.with(|tys| *tys)
|
||||
}
|
||||
|
||||
struct MockBlocks<'tcx> {
|
||||
blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
|
||||
dummy_place: Place<'tcx>,
|
||||
@ -166,7 +154,7 @@ impl<'tcx> MockBlocks<'tcx> {
|
||||
fn switchint(&mut self, some_from_block: Option<BasicBlock>) -> BasicBlock {
|
||||
let switchint_kind = TerminatorKind::SwitchInt {
|
||||
discr: Operand::Move(Place::from(self.new_temp())),
|
||||
switch_ty: dummy_ty(),
|
||||
switch_ty: BOOL_TY, // just a dummy value
|
||||
targets: SwitchTargets::static_if(0, TEMP_BLOCK, TEMP_BLOCK),
|
||||
};
|
||||
self.add_block_from(some_from_block, switchint_kind)
|
||||
|
@ -153,7 +153,7 @@ impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
|
||||
// create temp to store inequality comparison between the two discriminants, `_t` in
|
||||
// example above
|
||||
let nequal = BinOp::Ne;
|
||||
let comp_res_type = nequal.ty(tcx, parent_ty, opt_data.child_ty);
|
||||
let comp_res_type = nequal.ty(tcx, *parent_ty, opt_data.child_ty);
|
||||
let comp_temp = patch.new_temp(comp_res_type, opt_data.child_source.span);
|
||||
patch.add_statement(parent_end, StatementKind::StorageLive(comp_temp));
|
||||
|
||||
@ -343,7 +343,7 @@ fn evaluate_candidate<'tcx>(
|
||||
Some(OptimizationData {
|
||||
destination,
|
||||
child_place: *child_place,
|
||||
child_ty,
|
||||
child_ty: *child_ty,
|
||||
child_source: child_terminator.source_info,
|
||||
})
|
||||
}
|
||||
|
@ -39,6 +39,6 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
|
||||
// We have to use `try_normalize_erasing_regions` here, since it's
|
||||
// possible that we visit impossible-to-satisfy where clauses here,
|
||||
// see #91745
|
||||
*ty = self.tcx.try_normalize_erasing_regions(self.param_env, *ty).unwrap_or(ty);
|
||||
*ty = self.tcx.try_normalize_erasing_regions(self.param_env, *ty).unwrap_or(*ty);
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
|
||||
ty::InstanceDef::DropGlue(def_id, ty) => {
|
||||
// FIXME(#91576): Drop shims for generators aren't subject to the MIR passes at the end
|
||||
// of this function. Is this intentional?
|
||||
if let Some(ty::Generator(gen_def_id, substs, _)) = ty.map(ty::TyS::kind) {
|
||||
if let Some(ty::Generator(gen_def_id, substs, _)) = ty.map(Ty::kind) {
|
||||
let body = tcx.optimized_mir(*gen_def_id).generator_drop().unwrap();
|
||||
let body = body.clone().subst(tcx, substs);
|
||||
debug!("make_shim({:?}) = {:?}", instance, body);
|
||||
@ -137,7 +137,7 @@ fn local_decls_for_sig<'tcx>(
|
||||
span: Span,
|
||||
) -> IndexVec<Local, LocalDecl<'tcx>> {
|
||||
iter::once(LocalDecl::new(sig.output(), span))
|
||||
.chain(sig.inputs().iter().map(|ity| LocalDecl::new(ity, span).immutable()))
|
||||
.chain(sig.inputs().iter().map(|ity| LocalDecl::new(*ity, span).immutable()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
@ -1042,7 +1042,7 @@ fn find_vtable_types_for_unsizing<'tcx>(
|
||||
match (&source_ty.kind(), &target_ty.kind()) {
|
||||
(&ty::Ref(_, a, _), &ty::Ref(_, b, _) | &ty::RawPtr(ty::TypeAndMut { ty: b, .. }))
|
||||
| (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => {
|
||||
ptr_vtable(a, b)
|
||||
ptr_vtable(*a, *b)
|
||||
}
|
||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => {
|
||||
ptr_vtable(source_ty.boxed_ty(), target_ty.boxed_ty())
|
||||
|
@ -1,5 +1,5 @@
|
||||
use super::QueryCtxt;
|
||||
use rustc_middle::ty::{self, AdtSizedConstraint, Ty, TyS};
|
||||
use rustc_middle::ty::{self, AdtSizedConstraint, Ty};
|
||||
|
||||
pub(super) trait Value<'tcx>: Sized {
|
||||
fn from_cycle_error(tcx: QueryCtxt<'tcx>) -> Self;
|
||||
@ -12,7 +12,7 @@ impl<'tcx, T> Value<'tcx> for T {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Value<'tcx> for &'_ TyS<'_> {
|
||||
impl<'tcx> Value<'tcx> for Ty<'_> {
|
||||
fn from_cycle_error(tcx: QueryCtxt<'tcx>) -> Self {
|
||||
// SAFETY: This is never called when `Self` is not `Ty<'tcx>`.
|
||||
// FIXME: Represent the above fact in the trait system somehow.
|
||||
|
@ -626,7 +626,7 @@ fn orphan_check_trait_ref<'tcx>(
|
||||
.substs
|
||||
.types()
|
||||
.flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate))
|
||||
.find(|ty| ty_is_local_constructor(ty, in_crate));
|
||||
.find(|ty| ty_is_local_constructor(*ty, in_crate));
|
||||
|
||||
debug!("orphan_check_trait_ref: uncovered ty local_type: `{:?}`", local_type);
|
||||
|
||||
|
@ -1251,7 +1251,7 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
|
||||
|
||||
fn is_recursive_obligation(
|
||||
&self,
|
||||
obligated_types: &mut Vec<&ty::TyS<'tcx>>,
|
||||
obligated_types: &mut Vec<Ty<'tcx>>,
|
||||
cause_code: &ObligationCauseCode<'tcx>,
|
||||
) -> bool;
|
||||
}
|
||||
@ -1506,7 +1506,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
||||
loop {
|
||||
match t.kind() {
|
||||
ty::Ref(_, inner, _) | ty::RawPtr(ty::TypeAndMut { ty: inner, .. }) => {
|
||||
t = inner
|
||||
t = *inner
|
||||
}
|
||||
_ => break t,
|
||||
}
|
||||
@ -2054,7 +2054,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
if let ty::Param(ty::ParamTy { name, .. }) = *ty.kind() {
|
||||
let infcx = self.infcx;
|
||||
self.var_map.entry(ty).or_insert_with(|| {
|
||||
*self.var_map.entry(ty).or_insert_with(|| {
|
||||
infcx.next_ty_var(TypeVariableOrigin {
|
||||
kind: TypeVariableOriginKind::TypeParameterDefinition(name, None),
|
||||
span: DUMMY_SP,
|
||||
@ -2245,7 +2245,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
||||
|
||||
fn is_recursive_obligation(
|
||||
&self,
|
||||
obligated_types: &mut Vec<&ty::TyS<'tcx>>,
|
||||
obligated_types: &mut Vec<Ty<'tcx>>,
|
||||
cause_code: &ObligationCauseCode<'tcx>,
|
||||
) -> bool {
|
||||
if let ObligationCauseCode::BuiltinDerivedObligation(ref data) = cause_code {
|
||||
|
@ -167,7 +167,7 @@ pub trait InferCtxtExt<'tcx> {
|
||||
predicate: &T,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
cause_code: &ObligationCauseCode<'tcx>,
|
||||
obligated_types: &mut Vec<&ty::TyS<'tcx>>,
|
||||
obligated_types: &mut Vec<Ty<'tcx>>,
|
||||
seen_requirements: &mut FxHashSet<DefId>,
|
||||
) where
|
||||
T: fmt::Display;
|
||||
@ -839,7 +839,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
let ty::Ref(_, inner_ty, _) = suggested_ty.kind() else {
|
||||
break;
|
||||
};
|
||||
suggested_ty = inner_ty;
|
||||
suggested_ty = *inner_ty;
|
||||
|
||||
let new_obligation = self.mk_trait_obligation_with_new_self_ty(
|
||||
obligation.param_env,
|
||||
@ -1597,7 +1597,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
if let Some(cause) =
|
||||
typeck_results.generator_interior_types.as_ref().skip_binder().iter().find(
|
||||
|ty::GeneratorInteriorTypeCause { ty, .. }| {
|
||||
ty_matches(typeck_results.generator_interior_types.rebind(ty))
|
||||
ty_matches(typeck_results.generator_interior_types.rebind(*ty))
|
||||
},
|
||||
)
|
||||
{
|
||||
@ -1904,7 +1904,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
predicate: &T,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
cause_code: &ObligationCauseCode<'tcx>,
|
||||
obligated_types: &mut Vec<&ty::TyS<'tcx>>,
|
||||
obligated_types: &mut Vec<Ty<'tcx>>,
|
||||
seen_requirements: &mut FxHashSet<DefId>,
|
||||
) where
|
||||
T: fmt::Display,
|
||||
|
@ -104,7 +104,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
| ty::Error(_) => true,
|
||||
|
||||
// [T; N] and [T] have same properties as T.
|
||||
ty::Array(ty, _) | ty::Slice(ty) => trivial_dropck_outlives(tcx, ty),
|
||||
ty::Array(ty, _) | ty::Slice(ty) => trivial_dropck_outlives(tcx, *ty),
|
||||
|
||||
// (T1..Tn) and closures have same properties as T1..Tn --
|
||||
// check if *any* of those are trivial.
|
||||
|
@ -188,7 +188,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
if let Some(ty) = self.cache.get(&ty) {
|
||||
return Ok(ty);
|
||||
return Ok(*ty);
|
||||
}
|
||||
|
||||
// See note in `rustc_trait_selection::traits::project` about why we
|
||||
|
@ -2033,7 +2033,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
.skip_binder() // binder moved -\
|
||||
.iter()
|
||||
.flat_map(|ty| {
|
||||
let ty: ty::Binder<'tcx, Ty<'tcx>> = types.rebind(ty); // <----/
|
||||
let ty: ty::Binder<'tcx, Ty<'tcx>> = types.rebind(*ty); // <----/
|
||||
|
||||
self.infcx.commit_unconditionally(|_| {
|
||||
let placeholder_ty = self.infcx.replace_bound_vars_with_placeholders(ty);
|
||||
|
@ -510,7 +510,7 @@ crate fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Option<St
|
||||
for (mut p, _) in predicates {
|
||||
if let Some(poly_trait_ref) = p.to_opt_poly_trait_pred() {
|
||||
if Some(poly_trait_ref.def_id()) == sized_trait {
|
||||
types_without_default_bounds.remove(poly_trait_ref.self_ty().skip_binder());
|
||||
types_without_default_bounds.remove(&poly_trait_ref.self_ty().skip_binder());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ fn dtorck_constraint_for_ty<'tcx>(
|
||||
ty::Array(ety, _) | ty::Slice(ety) => {
|
||||
// single-element containers, behave like their element
|
||||
rustc_data_structures::stack::ensure_sufficient_stack(|| {
|
||||
dtorck_constraint_for_ty(tcx, span, for_ty, depth + 1, ety, constraints)
|
||||
dtorck_constraint_for_ty(tcx, span, for_ty, depth + 1, *ety, constraints)
|
||||
})?;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ fn are_inner_types_recursive<'tcx>(
|
||||
seen,
|
||||
shadow_seen,
|
||||
representable_cache,
|
||||
ty,
|
||||
*ty,
|
||||
force_result,
|
||||
),
|
||||
ty::Adt(def, substs) => {
|
||||
@ -255,7 +255,7 @@ fn is_type_structurally_recursive<'tcx>(
|
||||
force_result: &mut bool,
|
||||
) -> Representability {
|
||||
debug!("is_type_structurally_recursive: {:?} {:?}", ty, sp);
|
||||
if let Some(representability) = representable_cache.get(ty) {
|
||||
if let Some(representability) = representable_cache.get(&ty) {
|
||||
debug!(
|
||||
"is_type_structurally_recursive: {:?} {:?} - (cached) {:?}",
|
||||
ty, sp, representability
|
||||
|
@ -474,7 +474,7 @@ pub fn conservative_is_privately_uninhabited_raw<'tcx>(
|
||||
Some(0) | None => false,
|
||||
// If the array is definitely non-empty, it's uninhabited if
|
||||
// the type of its elements is uninhabited.
|
||||
Some(1..) => tcx.conservative_is_privately_uninhabited(param_env.and(ty)),
|
||||
Some(1..) => tcx.conservative_is_privately_uninhabited(param_env.and(*ty)),
|
||||
}
|
||||
}
|
||||
ty::Ref(..) => {
|
||||
|
@ -4,7 +4,7 @@ use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_hir::{self as hir, ExprKind};
|
||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use rustc_infer::traits::Obligation;
|
||||
use rustc_middle::ty::{self, ToPredicate, Ty, TyS};
|
||||
use rustc_middle::ty::{self, ToPredicate, Ty};
|
||||
use rustc_span::{MultiSpan, Span};
|
||||
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
|
||||
use rustc_trait_selection::traits::{
|
||||
@ -505,7 +505,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
pub(crate) fn opt_suggest_box_span(
|
||||
&self,
|
||||
span: Span,
|
||||
outer_ty: &'tcx TyS<'tcx>,
|
||||
outer_ty: Ty<'tcx>,
|
||||
orig_expected: Expectation<'tcx>,
|
||||
) -> Option<Span> {
|
||||
match (orig_expected, self.ret_coercion_impl_trait.map(|ty| (self.body_id.owner, ty))) {
|
||||
|
@ -628,7 +628,7 @@ impl<'a, 'tcx> DeferredCallResolution<'tcx> {
|
||||
for (method_arg_ty, self_arg_ty) in
|
||||
iter::zip(method_sig.inputs().iter().skip(1), self.fn_sig.inputs())
|
||||
{
|
||||
fcx.demand_eqtype(self.call_expr.span, &self_arg_ty, &method_arg_ty);
|
||||
fcx.demand_eqtype(self.call_expr.span, *self_arg_ty, *method_arg_ty);
|
||||
}
|
||||
|
||||
fcx.demand_eqtype(self.call_expr.span, method_sig.output(), self.fn_sig.output());
|
||||
|
@ -885,7 +885,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
});
|
||||
|
||||
// this will report a type mismatch if needed
|
||||
fcx.demand_eqtype(self.span, ety, m_cast.ty);
|
||||
fcx.demand_eqtype(self.span, *ety, m_cast.ty);
|
||||
return Ok(CastKind::ArrayPtrCast);
|
||||
}
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
.skip_binder()
|
||||
.inputs()
|
||||
.iter()
|
||||
.map(|ty| ArgKind::from_expected_ty(ty, None))
|
||||
.map(|ty| ArgKind::from_expected_ty(*ty, None))
|
||||
.collect();
|
||||
let (closure_span, found_args) = match self.get_fn_like_arguments(expr_map_node) {
|
||||
Some((sp, args)) => (Some(sp), args),
|
||||
|
@ -142,7 +142,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||
where
|
||||
F: FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>>,
|
||||
{
|
||||
self.unify(&a, &b)
|
||||
self.unify(a, b)
|
||||
.and_then(|InferOk { value: ty, obligations }| success(f(ty), ty, obligations))
|
||||
}
|
||||
|
||||
|
@ -734,7 +734,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, ref expr),
|
||||
_,
|
||||
&ty::Ref(_, checked, _),
|
||||
) if self.infcx.can_sub(self.param_env, checked, &expected).is_ok() => {
|
||||
) if self.infcx.can_sub(self.param_env, checked, expected).is_ok() => {
|
||||
// We have `&T`, check if what was expected was `T`. If so,
|
||||
// we may want to suggest removing a `&`.
|
||||
if sm.is_imported(expr.span) {
|
||||
|
@ -421,9 +421,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// Places may legitimately have unsized types.
|
||||
// For example, dereferences of a fat pointer and
|
||||
// the last field of a struct can be unsized.
|
||||
ExpectHasType(ty)
|
||||
ExpectHasType(*ty)
|
||||
} else {
|
||||
Expectation::rvalue_hint(self, ty)
|
||||
Expectation::rvalue_hint(self, *ty)
|
||||
}
|
||||
}
|
||||
_ => NoExpectation,
|
||||
@ -2216,7 +2216,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
fn no_such_field_err(
|
||||
&self,
|
||||
field: Ident,
|
||||
expr_t: &'tcx ty::TyS<'tcx>,
|
||||
expr_t: Ty<'tcx>,
|
||||
id: HirId,
|
||||
) -> DiagnosticBuilder<'_> {
|
||||
let span = field.span;
|
||||
@ -2233,7 +2233,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
);
|
||||
|
||||
// try to add a suggestion in case the field is a nested field of a field of the Adt
|
||||
if let Some((fields, substs)) = self.get_field_candidates(span, &expr_t) {
|
||||
if let Some((fields, substs)) = self.get_field_candidates(span, expr_t) {
|
||||
for candidate_field in fields.iter() {
|
||||
if let Some(field_path) = self.check_for_nested_field(
|
||||
span,
|
||||
@ -2312,7 +2312,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
field_path.push(candidate_field.ident(self.tcx).normalize_to_macros_2_0());
|
||||
let field_ty = candidate_field.ty(self.tcx, subst);
|
||||
if let Some((nested_fields, subst)) = self.get_field_candidates(span, &field_ty) {
|
||||
if let Some((nested_fields, subst)) = self.get_field_candidates(span, field_ty) {
|
||||
for field in nested_fields.iter() {
|
||||
let accessible = field.vis.is_accessible_from(id, self.tcx);
|
||||
if accessible {
|
||||
@ -2449,7 +2449,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// allows them to be inferred based on how they are used later in the
|
||||
// function.
|
||||
if is_input {
|
||||
let ty = self.structurally_resolved_type(expr.span, &ty);
|
||||
let ty = self.structurally_resolved_type(expr.span, ty);
|
||||
match *ty.kind() {
|
||||
ty::FnDef(..) => {
|
||||
let fnptr_ty = self.tcx.mk_fn_ptr(ty.fn_sig(self.tcx));
|
||||
|
@ -70,7 +70,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
|
||||
// unconstrained opaque type variables, in addition to performing
|
||||
// other kinds of fallback.
|
||||
for ty in &self.unsolved_variables() {
|
||||
fallback_has_occurred |= self.fallback_opaque_type_vars(ty);
|
||||
fallback_has_occurred |= self.fallback_opaque_type_vars(*ty);
|
||||
}
|
||||
|
||||
// See if we can make any more progress.
|
||||
@ -176,7 +176,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
|
||||
.type_var_origin(ty)
|
||||
.map(|origin| origin.span)
|
||||
.unwrap_or(rustc_span::DUMMY_SP);
|
||||
let oty = self.inner.borrow().opaque_types_vars.get(ty).copied();
|
||||
let oty = self.inner.borrow().opaque_types_vars.get(&ty).copied();
|
||||
if let Some(opaque_ty) = oty {
|
||||
debug!(
|
||||
"fallback_opaque_type_vars(ty={:?}): falling back to opaque type {:?}",
|
||||
|
@ -605,7 +605,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
field: &'tcx ty::FieldDef,
|
||||
substs: SubstsRef<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
self.normalize_associated_types_in(span, &field.ty(self.tcx, substs))
|
||||
self.normalize_associated_types_in(span, field.ty(self.tcx, substs))
|
||||
}
|
||||
|
||||
pub(in super::super) fn resolve_generator_interiors(&self, def_id: DefId) {
|
||||
@ -756,7 +756,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// is polymorphic) and the expected return type.
|
||||
// No argument expectations are produced if unification fails.
|
||||
let origin = self.misc(call_span);
|
||||
let ures = self.at(&origin, self.param_env).sup(ret_ty, &formal_ret);
|
||||
let ures = self.at(&origin, self.param_env).sup(ret_ty, formal_ret);
|
||||
|
||||
// FIXME(#27336) can't use ? here, Try::from_error doesn't default
|
||||
// to identity so the resulting type is not constrained.
|
||||
|
@ -282,7 +282,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
|
||||
if ty.has_escaping_bound_vars() {
|
||||
ty // FIXME: normalization and escaping regions
|
||||
} else {
|
||||
self.normalize_associated_types_in(span, &ty)
|
||||
self.normalize_associated_types_in(span, ty)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
|
||||
debug!(
|
||||
"local variable {:?} is assigned type {}",
|
||||
decl.pat,
|
||||
self.fcx.ty_to_string(&*self.fcx.locals.borrow().get(&decl.hir_id).unwrap().decl_ty)
|
||||
self.fcx.ty_to_string(self.fcx.locals.borrow().get(&decl.hir_id).unwrap().decl_ty)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -137,7 +137,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
|
||||
debug!(
|
||||
"pattern binding {} is assigned to {} with type {:?}",
|
||||
ident,
|
||||
self.fcx.ty_to_string(&*self.fcx.locals.borrow().get(&p.hir_id).unwrap().decl_ty),
|
||||
self.fcx.ty_to_string(self.fcx.locals.borrow().get(&p.hir_id).unwrap().decl_ty),
|
||||
var_ty
|
||||
);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
|
||||
|
||||
self.types.insert(ty::GeneratorInteriorTypeCause {
|
||||
span: source_span,
|
||||
ty: &ty,
|
||||
ty,
|
||||
scope_span,
|
||||
yield_span: yield_data.span,
|
||||
expr: expr.map(|e| e.hir_id),
|
||||
|
@ -185,7 +185,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
||||
|
||||
if unsize {
|
||||
let unsized_ty = if let ty::Array(elem_ty, _) = base_ty.kind() {
|
||||
self.tcx.mk_slice(elem_ty)
|
||||
self.tcx.mk_slice(*elem_ty)
|
||||
} else {
|
||||
bug!(
|
||||
"AutorefOrPtrAdjustment's unsize flag should only be set for array ty, found {}",
|
||||
@ -201,8 +201,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
||||
}
|
||||
Some(probe::AutorefOrPtrAdjustment::ToConstPtr) => {
|
||||
target = match target.kind() {
|
||||
ty::RawPtr(ty::TypeAndMut { ty, mutbl }) => {
|
||||
assert_eq!(*mutbl, hir::Mutability::Mut);
|
||||
&ty::RawPtr(ty::TypeAndMut { ty, mutbl }) => {
|
||||
assert_eq!(mutbl, hir::Mutability::Mut);
|
||||
self.tcx.mk_ptr(ty::TypeAndMut { mutbl: hir::Mutability::Not, ty })
|
||||
}
|
||||
other => panic!("Cannot adjust receiver type {:?} to const ptr", other),
|
||||
|
@ -227,7 +227,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
if let ty::Ref(region, t_type, mutability) = self_ty.kind() {
|
||||
let trait_type = self
|
||||
.tcx
|
||||
.mk_ref(region, ty::TypeAndMut { ty: t_type, mutbl: mutability.invert() });
|
||||
.mk_ref(region, ty::TypeAndMut { ty: *t_type, mutbl: mutability.invert() });
|
||||
// We probe again to see if there might be a borrow mutability discrepancy.
|
||||
match self.lookup_probe(
|
||||
span,
|
||||
|
@ -515,7 +515,7 @@ fn method_autoderef_steps<'tcx>(
|
||||
steps.push(CandidateStep {
|
||||
self_ty: infcx.make_query_response_ignoring_pending_obligations(
|
||||
inference_vars,
|
||||
infcx.tcx.mk_slice(elem_ty),
|
||||
infcx.tcx.mk_slice(*elem_ty),
|
||||
),
|
||||
autoderefs: dereferences,
|
||||
// this could be from an unsafe deref if we had
|
||||
@ -1247,7 +1247,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
let ty = match self_ty.kind() {
|
||||
ty::RawPtr(ty::TypeAndMut { ty, mutbl: hir::Mutability::Mut }) => ty,
|
||||
&ty::RawPtr(ty::TypeAndMut { ty, mutbl: hir::Mutability::Mut }) => ty,
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
|
@ -1087,7 +1087,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
if needs_mut {
|
||||
let trait_type = self.tcx.mk_ref(
|
||||
region,
|
||||
ty::TypeAndMut { ty: t_type, mutbl: mutability.invert() },
|
||||
ty::TypeAndMut { ty: *t_type, mutbl: mutability.invert() },
|
||||
);
|
||||
err.note(&format!("you need `{}` instead of `{}`", trait_type, rcvr_ty));
|
||||
}
|
||||
@ -1468,7 +1468,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
if let Ok(pick) = self.lookup_probe(
|
||||
span,
|
||||
item_name,
|
||||
rcvr_ty,
|
||||
*rcvr_ty,
|
||||
rcvr,
|
||||
crate::check::method::probe::ProbeScope::AllTraits,
|
||||
) {
|
||||
@ -1487,10 +1487,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
break;
|
||||
}
|
||||
for (rcvr_ty, pre) in &[
|
||||
(self.tcx.mk_lang_item(rcvr_ty, LangItem::OwnedBox), "Box::new"),
|
||||
(self.tcx.mk_lang_item(rcvr_ty, LangItem::Pin), "Pin::new"),
|
||||
(self.tcx.mk_diagnostic_item(rcvr_ty, sym::Arc), "Arc::new"),
|
||||
(self.tcx.mk_diagnostic_item(rcvr_ty, sym::Rc), "Rc::new"),
|
||||
(self.tcx.mk_lang_item(*rcvr_ty, LangItem::OwnedBox), "Box::new"),
|
||||
(self.tcx.mk_lang_item(*rcvr_ty, LangItem::Pin), "Pin::new"),
|
||||
(self.tcx.mk_diagnostic_item(*rcvr_ty, sym::Arc), "Arc::new"),
|
||||
(self.tcx.mk_diagnostic_item(*rcvr_ty, sym::Rc), "Rc::new"),
|
||||
] {
|
||||
if let Some(new_rcvr_t) = *rcvr_ty {
|
||||
if let Ok(pick) = self.lookup_probe(
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user