diff options
Diffstat (limited to 'compiler/rustc_lint')
| -rw-r--r-- | compiler/rustc_lint/src/array_into_iter.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/builtin.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/context.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/types.rs | 22 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/unused.rs | 2 | 
5 files changed, 24 insertions, 24 deletions
| diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index 9d74ad3b2f5..1d27bdcb282 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { } // Make sure we found an array after peeling the boxes. - if !matches!(recv_ty.kind, ty::Array(..)) { + if !matches!(recv_ty.kind(), ty::Array(..)) { return; } @@ -66,9 +66,9 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { } // Emit lint diagnostic. - let target = match cx.typeck_results().expr_ty_adjusted(receiver_arg).kind { - ty::Ref(_, ty::TyS { kind: ty::Array(..), .. }, _) => "[T; N]", - ty::Ref(_, ty::TyS { kind: ty::Slice(..), .. }, _) => "[T]", + let target = match *cx.typeck_results().expr_ty_adjusted(receiver_arg).kind() { + ty::Ref(_, inner_ty, _) if inner_ty.is_array() => "[T; N]", + ty::Ref(_, inner_ty, _) if matches!(inner_ty.kind(), ty::Slice(..)) => "[T]", // We know the original first argument type is an array type, // we know that the first adjustment was an autoref coercion diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 2b14d09671e..d18d89ed641 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -893,7 +893,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableTransmutes { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &hir::Expr<'_>) { use rustc_target::spec::abi::Abi::RustIntrinsic; if let Some((&ty::Ref(_, _, from_mt), &ty::Ref(_, _, to_mt))) = - get_transmute_from_to(cx, expr).map(|(ty1, ty2)| (&ty1.kind, &ty2.kind)) + get_transmute_from_to(cx, expr).map(|(ty1, ty2)| (ty1.kind(), ty2.kind())) { if to_mt == hir::Mutability::Mut && from_mt == hir::Mutability::Not { let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \ @@ -1940,13 +1940,13 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue { init: InitKind, ) -> Option<InitError> { use rustc_middle::ty::TyKind::*; - match ty.kind { + match ty.kind() { // Primitive types that don't like 0 as a value. Ref(..) => Some(("references must be non-null".to_string(), None)), Adt(..) if ty.is_box() => Some(("`Box` must be non-null".to_string(), None)), FnPtr(..) => Some(("function pointers must be non-null".to_string(), None)), Never => Some(("the `!` type has no valid value".to_string(), None)), - RawPtr(tm) if matches!(tm.ty.kind, Dynamic(..)) => + RawPtr(tm) if matches!(tm.ty.kind(), Dynamic(..)) => // raw ptr to dyn Trait { Some(("the vtable of a wide raw pointer must be non-null".to_string(), None)) @@ -2173,7 +2173,7 @@ impl ClashingExternDeclarations { let non_transparent_ty = |ty: Ty<'tcx>| -> Ty<'tcx> { let mut ty = ty; loop { - if let ty::Adt(def, substs) = ty.kind { + if let ty::Adt(def, substs) = *ty.kind() { let is_transparent = def.subst(tcx, substs).repr.transparent(); let is_non_null = crate::types::nonnull_optimization_guaranteed(tcx, &def); debug!( @@ -2212,8 +2212,8 @@ impl ClashingExternDeclarations { } else { // Do a full, depth-first comparison between the two. use rustc_middle::ty::TyKind::*; - let a_kind = &a.kind; - let b_kind = &b.kind; + let a_kind = a.kind(); + let b_kind = b.kind(); let compare_layouts = |a, b| -> Result<bool, LayoutError<'tcx>> { debug!("compare_layouts({:?}, {:?})", a, b); @@ -2335,7 +2335,7 @@ impl ClashingExternDeclarations { if is_primitive_or_pointer(other_kind) => { let (primitive, adt) = - if is_primitive_or_pointer(&a.kind) { (a, b) } else { (b, a) }; + if is_primitive_or_pointer(a.kind()) { (a, b) } else { (b, a) }; if let Some(ty) = crate::types::repr_nullable_ptr(cx, adt, ckind) { ty == primitive } else { diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index d1f50e1e84d..f0342b69c92 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -790,7 +790,7 @@ impl<'tcx> LateContext<'tcx> { trait_ref: Option<ty::TraitRef<'tcx>>, ) -> Result<Self::Path, Self::Error> { if trait_ref.is_none() { - if let ty::Adt(def, substs) = self_ty.kind { + if let ty::Adt(def, substs) = self_ty.kind() { return self.print_def_path(def.did, substs); } } diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 35c462c24c8..af32c16bfe8 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -217,7 +217,7 @@ fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option<&'static } } } - match t.kind { + match t.kind() { ty::Int(i) => find_fit!(i, val, negative, I8 => [U8] => [I16, I32, I64, I128], I16 => [U16] => [I32, I64, I128], @@ -303,7 +303,7 @@ fn lint_uint_literal<'tcx>( if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) { match par_e.kind { hir::ExprKind::Cast(..) => { - if let ty::Char = cx.typeck_results().expr_ty(par_e).kind { + if let ty::Char = cx.typeck_results().expr_ty(par_e).kind() { cx.struct_span_lint(OVERFLOWING_LITERALS, par_e.span, |lint| { lint.build("only `u8` can be cast into `char`") .span_suggestion( @@ -354,7 +354,7 @@ fn lint_literal<'tcx>( e: &'tcx hir::Expr<'tcx>, lit: &hir::Lit, ) { - match cx.typeck_results().node_type(e.hir_id).kind { + match *cx.typeck_results().node_type(e.hir_id).kind() { ty::Int(t) => { match lit.node { ast::LitKind::Int(v, ast::LitIntType::Signed(_) | ast::LitIntType::Unsuffixed) => { @@ -450,7 +450,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits { // Normalize the binop so that the literal is always on the RHS in // the comparison let norm_binop = if swap { rev_binop(binop) } else { binop }; - match cx.typeck_results().node_type(expr.hir_id).kind { + match *cx.typeck_results().node_type(expr.hir_id).kind() { ty::Int(int_ty) => { let (min, max) = int_ty_range(int_ty); let lit_val: i128 = match lit.kind { @@ -536,7 +536,7 @@ crate fn nonnull_optimization_guaranteed<'tcx>(tcx: TyCtxt<'tcx>, def: &ty::AdtD /// Is type known to be non-null? crate fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKind) -> bool { let tcx = cx.tcx; - match ty.kind { + match ty.kind() { ty::FnPtr(_) => true, ty::Ref(..) => true, ty::Adt(def, _) if def.is_box() && matches!(mode, CItemKind::Definition) => true, @@ -565,7 +565,7 @@ crate fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: C /// If the type passed in was not scalar, returns None. fn get_nullable_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> { let tcx = cx.tcx; - Some(match ty.kind { + Some(match *ty.kind() { ty::Adt(field_def, field_substs) => { let inner_field_ty = { let first_non_zst_ty = @@ -617,7 +617,7 @@ crate fn repr_nullable_ptr<'tcx>( ckind: CItemKind, ) -> Option<Ty<'tcx>> { debug!("is_repr_nullable_ptr(cx, ty = {:?})", ty); - if let ty::Adt(ty_def, substs) = ty.kind { + if let ty::Adt(ty_def, substs) = ty.kind() { if ty_def.variants.len() != 2 { return None; } @@ -667,7 +667,7 @@ crate fn repr_nullable_ptr<'tcx>( impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { /// Check if the type is array and emit an unsafe type lint. fn check_for_array_ty(&mut self, sp: Span, ty: Ty<'tcx>) -> bool { - if let ty::Array(..) = ty.kind { + if let ty::Array(..) = ty.kind() { self.emit_ffi_unsafe_type_lint( ty, sp, @@ -755,7 +755,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { return FfiSafe; } - match ty.kind { + match ty.kind() { ty::Adt(def, _) if def.is_box() && matches!(self.mode, CItemKind::Definition) => { FfiSafe } @@ -994,7 +994,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { diag.help(help); } diag.note(note); - if let ty::Adt(def, _) = ty.kind { + if let ty::Adt(def, _) = ty.kind() { if let Some(sp) = self.cx.tcx.hir().span_if_local(def.did) { diag.span_note(sp, "the type is defined here"); } @@ -1011,7 +1011,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { impl<'a, 'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueTypes<'a, 'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { - match ty.kind { + match ty.kind() { ty::Opaque(..) => { self.ty = Some(ty); true diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index c793e81ebe3..0c06b063e41 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -135,7 +135,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { let plural_suffix = pluralize!(plural_len); - match ty.kind { + match *ty.kind() { ty::Adt(..) if ty.is_box() => { let boxed_ty = ty.boxed_ty(); let descr_pre = &format!("{}boxed ", descr_pre); | 
