diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index d0cc87f7506a..b7609fa0898e 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -12,7 +12,6 @@ use crate::hir::def::{DefKind, Res}; use crate::hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX}; use crate::mir::mono::Linkage; use crate::ty::query::Providers; -use crate::ty::AdtKind; use crate::util::nodemap::{FxHashSet, NodeMap}; use errors::FatalError; @@ -2550,15 +2549,6 @@ impl ItemKind<'_> { } } - pub fn adt_kind(&self) -> Option { - match *self { - ItemKind::Struct(..) => Some(AdtKind::Struct), - ItemKind::Union(..) => Some(AdtKind::Union), - ItemKind::Enum(..) => Some(AdtKind::Enum), - _ => None, - } - } - pub fn generics(&self) -> Option<&Generics<'_>> { Some(match *self { ItemKind::Fn(_, ref generics, _) diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index e0ce95aa46b8..5e2178cf9106 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -1,12 +1,13 @@ use crate::check::{FnCtxt, Inherited}; use crate::constrained_generic_params::{identify_constrained_generic_params, Parameter}; -use crate::hir::def_id::DefId; +use rustc::hir::def_id::DefId; +use rustc::hir::ItemKind; use rustc::infer::opaque_types::may_define_opaque_type; use rustc::middle::lang_items; use rustc::traits::{self, ObligationCause, ObligationCauseCode}; use rustc::ty::subst::{InternalSubsts, Subst}; -use rustc::ty::{self, GenericParamDefKind, ToPredicate, Ty, TyCtxt, TypeFoldable}; +use rustc::ty::{self, AdtKind, GenericParamDefKind, ToPredicate, Ty, TyCtxt, TypeFoldable}; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use errors::DiagnosticBuilder; @@ -252,6 +253,15 @@ fn for_id(tcx: TyCtxt<'_>, id: hir::HirId, span: Span) -> CheckWfFcxBuilder<'_> } } +fn item_adt_kind(kind: &ItemKind<'_>) -> Option { + match kind { + ItemKind::Struct(..) => Some(AdtKind::Struct), + ItemKind::Union(..) => Some(AdtKind::Union), + ItemKind::Enum(..) => Some(AdtKind::Enum), + _ => None, + } +} + /// In a type definition, we check that to ensure that the types of the fields are well-formed. fn check_type_defn<'tcx, F>( tcx: TyCtxt<'tcx>, @@ -297,7 +307,7 @@ fn check_type_defn<'tcx, F>( field.span, fcx.body_id, traits::FieldSized { - adt_kind: match item.kind.adt_kind() { + adt_kind: match item_adt_kind(&item.kind) { Some(i) => i, None => bug!(), },