Skip to content

Commit c19ed3b

Browse files
committed
fn adt_kind -> wfcheck
1 parent cd8377d commit c19ed3b

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/librustc/hir/mod.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::hir::def::{DefKind, Res};
1212
use crate::hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX};
1313
use crate::mir::mono::Linkage;
1414
use crate::ty::query::Providers;
15-
use crate::ty::AdtKind;
1615
use crate::util::nodemap::{FxHashSet, NodeMap};
1716

1817
use errors::FatalError;
@@ -2550,15 +2549,6 @@ impl ItemKind<'_> {
25502549
}
25512550
}
25522551

2553-
pub fn adt_kind(&self) -> Option<AdtKind> {
2554-
match *self {
2555-
ItemKind::Struct(..) => Some(AdtKind::Struct),
2556-
ItemKind::Union(..) => Some(AdtKind::Union),
2557-
ItemKind::Enum(..) => Some(AdtKind::Enum),
2558-
_ => None,
2559-
}
2560-
}
2561-
25622552
pub fn generics(&self) -> Option<&Generics<'_>> {
25632553
Some(match *self {
25642554
ItemKind::Fn(_, ref generics, _)

src/librustc_typeck/check/wfcheck.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use crate::check::{FnCtxt, Inherited};
22
use crate::constrained_generic_params::{identify_constrained_generic_params, Parameter};
33

4-
use crate::hir::def_id::DefId;
4+
use rustc::hir::def_id::DefId;
5+
use rustc::hir::ItemKind;
56
use rustc::infer::opaque_types::may_define_opaque_type;
67
use rustc::middle::lang_items;
78
use rustc::traits::{self, ObligationCause, ObligationCauseCode};
89
use rustc::ty::subst::{InternalSubsts, Subst};
9-
use rustc::ty::{self, GenericParamDefKind, ToPredicate, Ty, TyCtxt, TypeFoldable};
10+
use rustc::ty::{self, AdtKind, GenericParamDefKind, ToPredicate, Ty, TyCtxt, TypeFoldable};
1011
use rustc::util::nodemap::{FxHashMap, FxHashSet};
1112

1213
use errors::DiagnosticBuilder;
@@ -252,6 +253,15 @@ fn for_id(tcx: TyCtxt<'_>, id: hir::HirId, span: Span) -> CheckWfFcxBuilder<'_>
252253
}
253254
}
254255

256+
fn item_adt_kind(kind: &ItemKind<'_>) -> Option<AdtKind> {
257+
match kind {
258+
ItemKind::Struct(..) => Some(AdtKind::Struct),
259+
ItemKind::Union(..) => Some(AdtKind::Union),
260+
ItemKind::Enum(..) => Some(AdtKind::Enum),
261+
_ => None,
262+
}
263+
}
264+
255265
/// In a type definition, we check that to ensure that the types of the fields are well-formed.
256266
fn check_type_defn<'tcx, F>(
257267
tcx: TyCtxt<'tcx>,
@@ -297,7 +307,7 @@ fn check_type_defn<'tcx, F>(
297307
field.span,
298308
fcx.body_id,
299309
traits::FieldSized {
300-
adt_kind: match item.kind.adt_kind() {
310+
adt_kind: match item_adt_kind(&item.kind) {
301311
Some(i) => i,
302312
None => bug!(),
303313
},

0 commit comments

Comments
 (0)