about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-24 05:12:01 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-01-04 18:43:05 +0100
commitc19ed3bc5b281fa5e74e70e008a154204fbfd814 (patch)
treeef8e70513bde02f17698638a52baa747e5584ba4 /src
parentcd8377d37e9bc47f9a5a982c41705a7800cbb51d (diff)
downloadrust-c19ed3bc5b281fa5e74e70e008a154204fbfd814.tar.gz
rust-c19ed3bc5b281fa5e74e70e008a154204fbfd814.zip
fn adt_kind -> wfcheck
Diffstat (limited to 'src')
-rw-r--r--src/librustc/hir/mod.rs10
-rw-r--r--src/librustc_typeck/check/wfcheck.rs16
2 files changed, 13 insertions, 13 deletions
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index d0cc87f7506..b7609fa0898 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<AdtKind> {
-        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 e0ce95aa46b..5e2178cf910 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<AdtKind> {
+    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!(),
                             },