Change ty.kind to a method
This commit is contained in:
@@ -33,7 +33,7 @@ pub struct Discr<'tcx> {
|
||||
|
||||
impl<'tcx> fmt::Display for Discr<'tcx> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.ty.kind {
|
||||
match *self.ty.kind() {
|
||||
ty::Int(ity) => {
|
||||
let size = ty::tls::with(|tcx| Integer::from_attr(&tcx, SignedInt(ity)).size());
|
||||
let x = self.val;
|
||||
@@ -59,7 +59,7 @@ fn unsigned_max(size: Size) -> u128 {
|
||||
}
|
||||
|
||||
fn int_size_and_signed<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> (Size, bool) {
|
||||
let (int, signed) = match ty.kind {
|
||||
let (int, signed) = match *ty.kind() {
|
||||
Int(ity) => (Integer::from_attr(&tcx, SignedInt(ity)), true),
|
||||
Uint(uty) => (Integer::from_attr(&tcx, UnsignedInt(uty)), false),
|
||||
_ => bug!("non integer discriminant"),
|
||||
@@ -174,10 +174,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn has_error_field(self, ty: Ty<'tcx>) -> bool {
|
||||
if let ty::Adt(def, substs) = ty.kind {
|
||||
if let ty::Adt(def, substs) = *ty.kind() {
|
||||
for field in def.all_fields() {
|
||||
let field_ty = field.ty(self, substs);
|
||||
if let Error(_) = field_ty.kind {
|
||||
if let Error(_) = field_ty.kind() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
normalize: impl Fn(Ty<'tcx>) -> Ty<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
loop {
|
||||
match ty.kind {
|
||||
match *ty.kind() {
|
||||
ty::Adt(def, substs) => {
|
||||
if !def.is_struct() {
|
||||
break;
|
||||
@@ -298,7 +298,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
) -> (Ty<'tcx>, Ty<'tcx>) {
|
||||
let (mut a, mut b) = (source, target);
|
||||
loop {
|
||||
match (&a.kind, &b.kind) {
|
||||
match (&a.kind(), &b.kind()) {
|
||||
(&Adt(a_def, a_substs), &Adt(b_def, b_substs))
|
||||
if a_def == b_def && a_def.is_struct() =>
|
||||
{
|
||||
@@ -401,12 +401,12 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
// <P1, P2, P0>, and then look up which of the impl substs refer to
|
||||
// parameters marked as pure.
|
||||
|
||||
let impl_substs = match self.type_of(impl_def_id).kind {
|
||||
let impl_substs = match *self.type_of(impl_def_id).kind() {
|
||||
ty::Adt(def_, substs) if def_ == def => substs,
|
||||
_ => bug!(),
|
||||
};
|
||||
|
||||
let item_substs = match self.type_of(def.did).kind {
|
||||
let item_substs = match *self.type_of(def.did).kind() {
|
||||
ty::Adt(def_, substs) if def_ == def => substs,
|
||||
_ => bug!(),
|
||||
};
|
||||
@@ -640,7 +640,7 @@ impl<'tcx> ty::TyS<'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>> {
|
||||
let val = match self.kind {
|
||||
let val = match self.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => {
|
||||
let (size, signed) = int_size_and_signed(tcx, self);
|
||||
let val = if signed { signed_max(size) as u128 } else { unsigned_max(size) };
|
||||
@@ -659,7 +659,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>> {
|
||||
let val = match self.kind {
|
||||
let val = match self.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => {
|
||||
let (size, signed) = int_size_and_signed(tcx, self);
|
||||
let val = if signed { truncate(signed_min(size) as u128, size) } else { 0 };
|
||||
@@ -717,7 +717,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 {
|
||||
match self.kind {
|
||||
match self.kind() {
|
||||
ty::Int(_)
|
||||
| ty::Uint(_)
|
||||
| ty::Float(_)
|
||||
@@ -793,7 +793,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
/// down, you will need to use a type visitor.
|
||||
#[inline]
|
||||
pub fn is_structural_eq_shallow(&'tcx self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
match self.kind {
|
||||
match self.kind() {
|
||||
// Look for an impl of both `PartialStructuralEq` and `StructuralEq`.
|
||||
Adt(..) => tcx.has_structural_eq_impls(self),
|
||||
|
||||
@@ -828,7 +828,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
}
|
||||
|
||||
pub fn same_type(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
|
||||
match (&a.kind, &b.kind) {
|
||||
match (&a.kind(), &b.kind()) {
|
||||
(&Adt(did_a, substs_a), &Adt(did_b, substs_b)) => {
|
||||
if did_a != did_b {
|
||||
return false;
|
||||
@@ -860,7 +860,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Representability {
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
Tuple(..) => {
|
||||
// Find non representable
|
||||
fold_repr(ty.tuple_fields().map(|ty| {
|
||||
@@ -909,7 +909,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
}
|
||||
|
||||
fn same_struct_or_enum<'tcx>(ty: Ty<'tcx>, def: &'tcx ty::AdtDef) -> bool {
|
||||
match ty.kind {
|
||||
match *ty.kind() {
|
||||
Adt(ty_def, _) => ty_def == def,
|
||||
_ => false,
|
||||
}
|
||||
@@ -947,7 +947,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Representability {
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
Adt(def, _) => {
|
||||
{
|
||||
// Iterate through stack of previously seen types.
|
||||
@@ -962,7 +962,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
// struct Bar<T> { x: Bar<Foo> }
|
||||
|
||||
if let Some(&seen_type) = iter.next() {
|
||||
if same_struct_or_enum(seen_type, def) {
|
||||
if same_struct_or_enum(seen_type, *def) {
|
||||
debug!("SelfRecursive: {:?} contains {:?}", seen_type, ty);
|
||||
return Representability::SelfRecursive(vec![sp]);
|
||||
}
|
||||
@@ -1024,7 +1024,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
/// - `&'a *const &'b u8 -> *const &'b u8`
|
||||
pub fn peel_refs(&'tcx self) -> Ty<'tcx> {
|
||||
let mut ty = self;
|
||||
while let Ref(_, inner_ty, _) = ty.kind {
|
||||
while let Ref(_, inner_ty, _) = ty.kind() {
|
||||
ty = inner_ty;
|
||||
}
|
||||
ty
|
||||
@@ -1070,7 +1070,7 @@ impl<'tcx> ExplicitSelf<'tcx> {
|
||||
{
|
||||
use self::ExplicitSelf::*;
|
||||
|
||||
match self_arg_ty.kind {
|
||||
match *self_arg_ty.kind() {
|
||||
_ if is_self_ty(self_arg_ty) => ByValue,
|
||||
ty::Ref(region, ty, mutbl) if is_self_ty(ty) => ByReference(region, mutbl),
|
||||
ty::RawPtr(ty::TypeAndMut { ty, mutbl }) if is_self_ty(ty) => ByRawPointer(mutbl),
|
||||
@@ -1087,7 +1087,7 @@ pub fn needs_drop_components(
|
||||
ty: Ty<'tcx>,
|
||||
target_layout: &TargetDataLayout,
|
||||
) -> Result<SmallVec<[Ty<'tcx>; 2]>, AlwaysRequiresDrop> {
|
||||
match ty.kind {
|
||||
match ty.kind() {
|
||||
ty::Infer(ty::FreshIntTy(_))
|
||||
| ty::Infer(ty::FreshFloatTy(_))
|
||||
| ty::Bool
|
||||
|
||||
Reference in New Issue
Block a user