Change ty.kind to a method

This commit is contained in:
LeSeulArtichaut
2020-08-03 00:49:11 +02:00
parent ef55a0a92f
commit 3e14b684dd
189 changed files with 947 additions and 899 deletions

View File

@@ -923,25 +923,25 @@ impl<'tcx> TypeFoldable<'tcx> for interpret::GlobalId<'tcx> {
impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
let kind = match self.kind {
let kind = match self.kind() {
ty::RawPtr(tm) => ty::RawPtr(tm.fold_with(folder)),
ty::Array(typ, sz) => ty::Array(typ.fold_with(folder), sz.fold_with(folder)),
ty::Slice(typ) => ty::Slice(typ.fold_with(folder)),
ty::Adt(tid, substs) => ty::Adt(tid, substs.fold_with(folder)),
ty::Adt(tid, substs) => ty::Adt(*tid, substs.fold_with(folder)),
ty::Dynamic(ref trait_ty, ref region) => {
ty::Dynamic(trait_ty.fold_with(folder), region.fold_with(folder))
}
ty::Tuple(ts) => ty::Tuple(ts.fold_with(folder)),
ty::FnDef(def_id, substs) => ty::FnDef(def_id, substs.fold_with(folder)),
ty::FnDef(def_id, substs) => ty::FnDef(*def_id, substs.fold_with(folder)),
ty::FnPtr(f) => ty::FnPtr(f.fold_with(folder)),
ty::Ref(ref r, ty, mutbl) => ty::Ref(r.fold_with(folder), ty.fold_with(folder), mutbl),
ty::Ref(ref r, ty, mutbl) => ty::Ref(r.fold_with(folder), ty.fold_with(folder), *mutbl),
ty::Generator(did, substs, movability) => {
ty::Generator(did, substs.fold_with(folder), movability)
ty::Generator(*did, substs.fold_with(folder), *movability)
}
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.fold_with(folder)),
ty::Closure(did, substs) => ty::Closure(did, substs.fold_with(folder)),
ty::Closure(did, substs) => ty::Closure(*did, substs.fold_with(folder)),
ty::Projection(ref data) => ty::Projection(data.fold_with(folder)),
ty::Opaque(did, substs) => ty::Opaque(did, substs.fold_with(folder)),
ty::Opaque(did, substs) => ty::Opaque(*did, substs.fold_with(folder)),
ty::Bool
| ty::Char
@@ -958,7 +958,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
| ty::Foreign(..) => return self,
};
if self.kind == kind { self } else { folder.tcx().mk_ty(kind) }
if *self.kind() == kind { self } else { folder.tcx().mk_ty(kind) }
}
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
@@ -966,7 +966,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
match self.kind {
match self.kind() {
ty::RawPtr(ref tm) => tm.visit_with(visitor),
ty::Array(typ, sz) => typ.visit_with(visitor) || sz.visit_with(visitor),
ty::Slice(typ) => typ.visit_with(visitor),