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

@ -124,7 +124,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
}
fn handle_field_access(&mut self, lhs: &hir::Expr<'_>, hir_id: hir::HirId) {
match self.typeck_results().expr_ty_adjusted(lhs).kind {
match self.typeck_results().expr_ty_adjusted(lhs).kind() {
ty::Adt(def, _) => {
let index = self.tcx.field_index(hir_id, self.typeck_results());
self.insert_def_id(def.non_enum_variant().fields[index].did);
@ -140,7 +140,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
res: Res,
pats: &[hir::FieldPat<'_>],
) {
let variant = match self.typeck_results().node_type(lhs.hir_id).kind {
let variant = match self.typeck_results().node_type(lhs.hir_id).kind() {
ty::Adt(adt, _) => adt.variant_of_res(res),
_ => span_bug!(lhs.span, "non-ADT in struct pattern"),
};
@ -269,7 +269,7 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
hir::ExprKind::Struct(ref qpath, ref fields, _) => {
let res = self.typeck_results().qpath_res(qpath, expr.hir_id);
self.handle_res(res);
if let ty::Adt(ref adt, _) = self.typeck_results().expr_ty(expr).kind {
if let ty::Adt(ref adt, _) = self.typeck_results().expr_ty(expr).kind() {
self.mark_as_used_if_union(adt, fields);
}
}

View file

@ -35,7 +35,7 @@ struct ExprVisitor<'tcx> {
/// If the type is `Option<T>`, it will return `T`, otherwise
/// the type itself. Works on most `Option`-like types.
fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
let (def, substs) = match ty.kind {
let (def, substs) = match *ty.kind() {
ty::Adt(def, substs) => (def, substs),
_ => return ty,
};
@ -81,7 +81,7 @@ impl ExprVisitor<'tcx> {
// Special-case transmutting from `typeof(function)` and
// `Option<typeof(function)>` to present a clearer error.
let from = unpack_option_like(self.tcx, from);
if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (&from.kind, sk_to) {
if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (from.kind(), sk_to) {
if size_to == Pointer.size(&self.tcx) {
struct_span_err!(self.tcx.sess, span, E0591, "can't transmute zero-sized type")
.note(&format!("source type: {}", from))
@ -127,7 +127,7 @@ impl ExprVisitor<'tcx> {
if ty.is_sized(self.tcx.at(DUMMY_SP), self.param_env) {
return true;
}
if let ty::Foreign(..) = ty.kind {
if let ty::Foreign(..) = ty.kind() {
return true;
}
false
@ -149,7 +149,7 @@ impl ExprVisitor<'tcx> {
64 => InlineAsmType::I64,
_ => unreachable!(),
};
let asm_ty = match ty.kind {
let asm_ty = match *ty.kind() {
ty::Never | ty::Error(_) => return None,
ty::Int(IntTy::I8) | ty::Uint(UintTy::U8) => Some(InlineAsmType::I8),
ty::Int(IntTy::I16) | ty::Uint(UintTy::U16) => Some(InlineAsmType::I16),
@ -166,7 +166,7 @@ impl ExprVisitor<'tcx> {
ty::Adt(adt, substs) if adt.repr.simd() => {
let fields = &adt.non_enum_variant().fields;
let elem_ty = fields[0].ty(self.tcx, substs);
match elem_ty.kind {
match elem_ty.kind() {
ty::Never | ty::Error(_) => return None,
ty::Int(IntTy::I8) | ty::Uint(UintTy::U8) => {
Some(InlineAsmType::VecI8(fields.len() as u64))
@ -374,7 +374,7 @@ impl ExprVisitor<'tcx> {
}
hir::InlineAsmOperand::Const { ref expr } => {
let ty = self.typeck_results.expr_ty_adjusted(expr);
match ty.kind {
match ty.kind() {
ty::Int(_) | ty::Uint(_) | ty::Float(_) => {}
_ => {
let msg =

View file

@ -958,7 +958,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
let ty = self.typeck_results.node_type(id);
match ty.kind {
match ty.kind() {
ty::Closure(_def_id, substs) => match substs.as_closure().kind() {
ty::ClosureKind::Fn => {}
ty::ClosureKind::FnMut => {}