Skip to content

Commit 88f8f07

Browse files
committed
Move CtorOf into hir::def.
This commit moves the definition of `CtorOf` from `rustc::hir` to `rustc::hir::def` and adds imports wherever it is used.
1 parent db4770f commit 88f8f07

File tree

17 files changed

+55
-56
lines changed

17 files changed

+55
-56
lines changed

src/librustc/hir/def.rs

+16-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ use crate::ty;
99

1010
use self::Namespace::*;
1111

12+
/// Encodes if a `Def::Ctor` is the constructor of an enum variant or a struct.
13+
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, HashStable)]
14+
pub enum CtorOf {
15+
/// This `Def::Ctor` is a synthesized constructor of a tuple or unit struct.
16+
Struct,
17+
/// This `Def::Ctor` is a synthesized constructor of a tuple or unit variant.
18+
Variant,
19+
}
20+
1221
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, HashStable)]
1322
pub enum CtorKind {
1423
/// Constructor function automatically created by a tuple struct/variant.
@@ -64,7 +73,7 @@ pub enum Def {
6473
ConstParam(DefId),
6574
Static(DefId, bool /* is_mutbl */),
6675
/// `DefId` refers to the struct or enum variant's constructor.
67-
Ctor(hir::CtorOf, DefId, CtorKind),
76+
Ctor(CtorOf, DefId, CtorKind),
6877
SelfCtor(DefId /* impl */), // `DefId` refers to the impl
6978
Method(DefId),
7079
AssociatedConst(DefId),
@@ -306,13 +315,13 @@ impl Def {
306315
Def::Static(..) => "static",
307316
Def::Enum(..) => "enum",
308317
Def::Variant(..) => "variant",
309-
Def::Ctor(hir::CtorOf::Variant, _, CtorKind::Fn) => "tuple variant",
310-
Def::Ctor(hir::CtorOf::Variant, _, CtorKind::Const) => "unit variant",
311-
Def::Ctor(hir::CtorOf::Variant, _, CtorKind::Fictive) => "struct variant",
318+
Def::Ctor(CtorOf::Variant, _, CtorKind::Fn) => "tuple variant",
319+
Def::Ctor(CtorOf::Variant, _, CtorKind::Const) => "unit variant",
320+
Def::Ctor(CtorOf::Variant, _, CtorKind::Fictive) => "struct variant",
312321
Def::Struct(..) => "struct",
313-
Def::Ctor(hir::CtorOf::Struct, _, CtorKind::Fn) => "tuple struct",
314-
Def::Ctor(hir::CtorOf::Struct, _, CtorKind::Const) => "unit struct",
315-
Def::Ctor(hir::CtorOf::Struct, _, CtorKind::Fictive) =>
322+
Def::Ctor(CtorOf::Struct, _, CtorKind::Fn) => "tuple struct",
323+
Def::Ctor(CtorOf::Struct, _, CtorKind::Const) => "unit struct",
324+
Def::Ctor(CtorOf::Struct, _, CtorKind::Fictive) =>
316325
bug!("impossible struct constructor"),
317326
Def::Existential(..) => "existential type",
318327
Def::TyAlias(..) => "type alias",

src/librustc/hir/map/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ impl<'hir> Map<'hir> {
371371
}
372372
Node::Ctor(variant_data) => {
373373
let ctor_of = match self.find(self.get_parent_node(node_id)) {
374-
Some(Node::Item(..)) => CtorOf::Struct,
375-
Some(Node::Variant(..)) => CtorOf::Variant,
374+
Some(Node::Item(..)) => def::CtorOf::Struct,
375+
Some(Node::Variant(..)) => def::CtorOf::Variant,
376376
_ => unreachable!(),
377377
};
378378
variant_data.ctor_hir_id()

src/librustc/hir/mod.rs

-9
Original file line numberDiff line numberDiff line change
@@ -2559,15 +2559,6 @@ impl CodegenFnAttrs {
25592559
}
25602560
}
25612561

2562-
/// Encodes if a `Node::Ctor` is the constructor of an enum variant or a struct.
2563-
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, HashStable)]
2564-
pub enum CtorOf {
2565-
/// This `Node::Ctor` is a synthesized constructor of a tuple or unit struct.
2566-
Struct,
2567-
/// This `Node::Ctor` is a synthesized constructor of a tuple or unit variant.
2568-
Variant,
2569-
}
2570-
25712562
#[derive(Copy, Clone, Debug)]
25722563
pub enum Node<'hir> {
25732564
Item(&'hir Item),

src/librustc/hir/pat_util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::hir::def::Def;
1+
use crate::hir::def::{CtorOf, Def};
22
use crate::hir::def_id::DefId;
33
use crate::hir::{self, HirId, PatKind};
44
use syntax::ast;
@@ -126,7 +126,7 @@ impl hir::Pat {
126126
PatKind::Struct(hir::QPath::Resolved(_, ref path), ..) => {
127127
match path.def {
128128
Def::Variant(id) => variants.push(id),
129-
Def::Ctor(hir::CtorOf::Variant, id, _) => variants.push(id),
129+
Def::Ctor(CtorOf::Variant, id, _) => variants.push(id),
130130
_ => ()
131131
}
132132
}

src/librustc/middle/dead.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::hir::{self, PatKind, TyKind};
77
use crate::hir::intravisit::{self, Visitor, NestedVisitorMap};
88
use crate::hir::itemlikevisit::ItemLikeVisitor;
99

10-
use crate::hir::def::Def;
10+
use crate::hir::def::{CtorOf, Def};
1111
use crate::hir::CodegenFnAttrFlags;
1212
use crate::hir::def_id::{DefId, LOCAL_CRATE};
1313
use crate::lint;
@@ -76,7 +76,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
7676
_ if self.in_pat => (),
7777
Def::PrimTy(..) | Def::SelfTy(..) | Def::SelfCtor(..) |
7878
Def::Local(..) | Def::Upvar(..) => {}
79-
Def::Ctor(hir::CtorOf::Variant, ctor_def_id, ..) => {
79+
Def::Ctor(CtorOf::Variant, ctor_def_id, ..) => {
8080
let variant_id = self.tcx.parent(ctor_def_id).unwrap();
8181
let enum_id = self.tcx.parent(variant_id).unwrap();
8282
self.check_def_id(enum_id);

src/librustc/middle/expr_use_visitor.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub use self::MatchMode::*;
99
use self::TrackMatchMode::*;
1010
use self::OverloadedCallType::*;
1111

12-
use crate::hir::def::Def;
12+
use crate::hir::def::{CtorOf, Def};
1313
use crate::hir::def_id::DefId;
1414
use crate::infer::InferCtxt;
1515
use crate::middle::mem_categorization as mc;
@@ -902,7 +902,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
902902
};
903903
let def = mc.tables.qpath_def(qpath, pat.hir_id);
904904
match def {
905-
Def::Ctor(hir::CtorOf::Variant, variant_ctor_did, ..) => {
905+
Def::Ctor(CtorOf::Variant, variant_ctor_did, ..) => {
906906
let variant_did = mc.tcx.parent(variant_ctor_did).unwrap();
907907
let downcast_cmt = mc.cat_downcast_if_needed(pat, cmt_pat, variant_did);
908908

src/librustc/middle/mem_categorization.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use crate::middle::region;
6262
use crate::hir::def_id::{DefId, LocalDefId};
6363
use crate::hir::Node;
6464
use crate::infer::InferCtxt;
65-
use crate::hir::def::{Def, CtorKind};
65+
use crate::hir::def::{CtorOf, Def, CtorKind};
6666
use crate::ty::adjustment;
6767
use crate::ty::{self, DefIdTree, Ty, TyCtxt};
6868
use crate::ty::fold::TypeFoldable;
@@ -1274,14 +1274,14 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
12741274
debug!("access to unresolvable pattern {:?}", pat);
12751275
return Err(())
12761276
}
1277-
Def::Ctor(hir::CtorOf::Variant, variant_ctor_did, CtorKind::Fn) => {
1277+
Def::Ctor(CtorOf::Variant, variant_ctor_did, CtorKind::Fn) => {
12781278
let variant_did = self.tcx.parent(variant_ctor_did).unwrap();
12791279
let enum_did = self.tcx.parent(variant_did).unwrap();
12801280
(self.cat_downcast_if_needed(pat, cmt, variant_did),
12811281
self.tcx.adt_def(enum_did)
12821282
.variant_with_ctor_id(variant_ctor_did).fields.len())
12831283
}
1284-
Def::Ctor(hir::CtorOf::Struct, _, CtorKind::Fn) | Def::SelfCtor(..) => {
1284+
Def::Ctor(CtorOf::Struct, _, CtorKind::Fn) | Def::SelfCtor(..) => {
12851285
let ty = self.pat_ty_unadjusted(&pat)?;
12861286
match ty.sty {
12871287
ty::Adt(adt_def, _) => {
@@ -1316,7 +1316,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
13161316
debug!("access to unresolvable pattern {:?}", pat);
13171317
return Err(())
13181318
}
1319-
Def::Ctor(hir::CtorOf::Variant, variant_ctor_did, _) => {
1319+
Def::Ctor(CtorOf::Variant, variant_ctor_did, _) => {
13201320
let variant_did = self.tcx.parent(variant_ctor_did).unwrap();
13211321
self.cat_downcast_if_needed(pat, cmt, variant_did)
13221322
}

src/librustc/ty/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub use self::fold::TypeFoldable;
66

77
use crate::hir::{map as hir_map, FreevarMap, GlobMap, TraitMap};
88
use crate::hir::{HirId, Node};
9-
use crate::hir::def::{Def, CtorKind, ExportMap};
9+
use crate::hir::def::{Def, CtorOf, CtorKind, ExportMap};
1010
use crate::hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
1111
use rustc_data_structures::svh::Svh;
1212
use rustc_macros::HashStable;
@@ -2941,12 +2941,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
29412941
Def::Struct(did) | Def::Union(did) => {
29422942
self.adt_def(did).non_enum_variant()
29432943
}
2944-
Def::Ctor(hir::CtorOf::Variant, variant_ctor_did, ..) => {
2944+
Def::Ctor(CtorOf::Variant, variant_ctor_did, ..) => {
29452945
let variant_did = self.parent(variant_ctor_did).unwrap();
29462946
let enum_did = self.parent(variant_did).unwrap();
29472947
self.adt_def(enum_did).variant_with_ctor_id(variant_ctor_did)
29482948
}
2949-
Def::Ctor(hir::CtorOf::Struct, ctor_did, ..) => {
2949+
Def::Ctor(CtorOf::Struct, ctor_did, ..) => {
29502950
let struct_did = self.parent(ctor_did).expect("struct ctor has no parent");
29512951
self.adt_def(struct_did).non_enum_variant()
29522952
}

src/librustc_metadata/decoder.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc::hir::map::{DefKey, DefPath, DefPathData, DefPathHash, Definitions};
88
use rustc::hir;
99
use rustc::middle::cstore::LinkagePreference;
1010
use rustc::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
11-
use rustc::hir::def::{self, Def, CtorKind};
11+
use rustc::hir::def::{self, Def, CtorOf, CtorKind};
1212
use rustc::hir::def_id::{CrateNum, DefId, DefIndex, DefIndexAddressSpace,
1313
CRATE_DEF_INDEX, LOCAL_CRATE, LocalDefId};
1414
use rustc::hir::map::definitions::DefPathTable;
@@ -817,7 +817,7 @@ impl<'a, 'tcx> CrateMetadata {
817817
if let Some(ctor_def_id) = self.get_ctor_def_id(child_index) {
818818
let ctor_kind = self.get_ctor_kind(child_index);
819819
let ctor_def = Def::Ctor(
820-
hir::CtorOf::Struct, ctor_def_id, ctor_kind);
820+
hir::def::CtorOf::Struct, ctor_def_id, ctor_kind);
821821
let vis = self.get_visibility(ctor_def_id.index);
822822
callback(def::Export { def: ctor_def, vis, ident, span });
823823
}
@@ -829,7 +829,7 @@ impl<'a, 'tcx> CrateMetadata {
829829
// error will be reported on any use of such resolution anyway.
830830
let ctor_def_id = self.get_ctor_def_id(child_index).unwrap_or(def_id);
831831
let ctor_kind = self.get_ctor_kind(child_index);
832-
let ctor_def = Def::Ctor(hir::CtorOf::Variant, ctor_def_id, ctor_kind);
832+
let ctor_def = Def::Ctor(CtorOf::Variant, ctor_def_id, ctor_kind);
833833
let vis = self.get_visibility(ctor_def_id.index);
834834
callback(def::Export { def: ctor_def, ident, vis, span });
835835
}

src/librustc_mir/hair/cx/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::hair::cx::block;
44
use crate::hair::cx::to_ref::ToRef;
55
use crate::hair::util::UserAnnotatedTyHelpers;
66
use rustc_data_structures::indexed_vec::Idx;
7-
use rustc::hir::def::{Def, CtorKind};
7+
use rustc::hir::def::{CtorOf, Def, CtorKind};
88
use rustc::mir::interpret::{GlobalId, ErrorHandled, ConstValue};
99
use rustc::ty::{self, AdtKind, Ty};
1010
use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability};
@@ -675,7 +675,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
675675
.ty_adt_def()
676676
.and_then(|adt_def| {
677677
match def {
678-
Def::Ctor(hir::CtorOf::Variant, variant_ctor_id, CtorKind::Const) => {
678+
Def::Ctor(CtorOf::Variant, variant_ctor_id, CtorKind::Const) => {
679679
let idx = adt_def.variant_index_with_ctor_id(variant_ctor_id);
680680
let (d, o) = adt_def.discriminant_def_for_variant(idx);
681681
use rustc::ty::util::IntTypeExt;

src/librustc_mir/hair/pattern/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc::ty::{CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTyp
1818
use rustc::ty::subst::{SubstsRef, Kind};
1919
use rustc::ty::layout::VariantIdx;
2020
use rustc::hir::{self, PatKind, RangeEnd};
21-
use rustc::hir::def::{Def, CtorKind};
21+
use rustc::hir::def::{CtorOf, Def, CtorKind};
2222
use rustc::hir::pat_util::EnumerateAndAdjustIterator;
2323

2424
use rustc_data_structures::indexed_vec::Idx;
@@ -734,7 +734,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
734734
subpatterns: Vec<FieldPattern<'tcx>>,
735735
) -> PatternKind<'tcx> {
736736
let def = match def {
737-
Def::Ctor(hir::CtorOf::Variant, variant_ctor_id, ..) => {
737+
Def::Ctor(CtorOf::Variant, variant_ctor_id, ..) => {
738738
let variant_id = self.tcx.parent(variant_ctor_id).unwrap();
739739
Def::Variant(variant_id)
740740
},
@@ -765,7 +765,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
765765
}
766766
}
767767

768-
Def::Struct(..) | Def::Ctor(hir::CtorOf::Struct, ..) | Def::Union(..) |
768+
Def::Struct(..) | Def::Ctor(CtorOf::Struct, ..) | Def::Union(..) |
769769
Def::TyAlias(..) | Def::AssociatedTy(..) | Def::SelfTy(..) | Def::SelfCtor(..) => {
770770
PatternKind::Leaf { subpatterns }
771771
}

src/librustc_resolve/build_reduced_graph.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::Namespace::{self, TypeNS, ValueNS, MacroNS};
1212
use crate::{resolve_error, resolve_struct_error, ResolutionError};
1313

1414
use rustc::bug;
15-
use rustc::hir::{self, def::*};
15+
use rustc::hir::def::*;
1616
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, LOCAL_CRATE, DefId};
1717
use rustc::ty;
1818
use rustc::middle::cstore::CrateStore;
@@ -533,7 +533,7 @@ impl<'a> Resolver<'a> {
533533
// If this is a tuple or unit struct, define a name
534534
// in the value namespace as well.
535535
if let Some(ctor_node_id) = struct_def.ctor_id() {
536-
let ctor_def = Def::Ctor(hir::CtorOf::Struct,
536+
let ctor_def = Def::Ctor(CtorOf::Struct,
537537
self.definitions.local_def_id(ctor_node_id),
538538
CtorKind::from_ast(struct_def));
539539
self.define(parent, ident, ValueNS, (ctor_def, ctor_vis, sp, expansion));
@@ -596,7 +596,7 @@ impl<'a> Resolver<'a> {
596596
let ctor_node_id = variant.node.data.ctor_id().unwrap_or(variant.node.id);
597597
let ctor_def_id = self.definitions.local_def_id(ctor_node_id);
598598
let ctor_kind = CtorKind::from_ast(&variant.node.data);
599-
let ctor_def = Def::Ctor(hir::CtorOf::Variant, ctor_def_id, ctor_kind);
599+
let ctor_def = Def::Ctor(CtorOf::Variant, ctor_def_id, ctor_kind);
600600
self.define(parent, ident, ValueNS, (ctor_def, vis, variant.span, expansion));
601601
}
602602

@@ -654,10 +654,10 @@ impl<'a> Resolver<'a> {
654654
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
655655
}
656656
Def::Fn(..) | Def::Static(..) | Def::Const(..) |
657-
Def::Ctor(hir::CtorOf::Variant, ..) => {
657+
Def::Ctor(CtorOf::Variant, ..) => {
658658
self.define(parent, ident, ValueNS, (def, vis, DUMMY_SP, expansion));
659659
}
660-
Def::Ctor(hir::CtorOf::Struct, def_id, ..) => {
660+
Def::Ctor(CtorOf::Struct, def_id, ..) => {
661661
self.define(parent, ident, ValueNS, (def, vis, DUMMY_SP, expansion));
662662

663663
if let Some(struct_def_id) =

src/librustc_resolve/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ impl<'a> NameBinding<'a> {
13601360
fn is_variant(&self) -> bool {
13611361
match self.kind {
13621362
NameBindingKind::Def(Def::Variant(..), _) |
1363-
NameBindingKind::Def(Def::Ctor(hir::CtorOf::Variant, ..), _) => true,
1363+
NameBindingKind::Def(Def::Ctor(CtorOf::Variant, ..), _) => true,
13641364
_ => false,
13651365
}
13661366
}

src/librustc_save_analysis/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod span_utils;
1414
mod sig;
1515

1616
use rustc::hir;
17-
use rustc::hir::def::Def as HirDef;
17+
use rustc::hir::def::{CtorOf, Def as HirDef};
1818
use rustc::hir::Node;
1919
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
2020
use rustc::middle::privacy::AccessLevels;
@@ -757,7 +757,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
757757
ref_id: id_from_def_id(def_id),
758758
})
759759
}
760-
HirDef::Ctor(hir::CtorOf::Struct, def_id, _) => {
760+
HirDef::Ctor(CtorOf::Struct, def_id, _) => {
761761
// This is a reference to a tuple struct where the def_id points
762762
// to an invisible constructor function. That is not a very useful
763763
// def, so adjust to point to the tuple struct itself.

src/librustc_typeck/astconv.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use errors::{Applicability, DiagnosticId};
66
use crate::hir::{self, GenericArg, GenericArgs, ExprKind};
7-
use crate::hir::def::Def;
7+
use crate::hir::def::{CtorOf, Def};
88
use crate::hir::def_id::DefId;
99
use crate::hir::HirVec;
1010
use crate::lint;
@@ -1596,7 +1596,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
15961596

15971597
match def {
15981598
// Case 1. Reference to a struct constructor.
1599-
Def::Ctor(hir::CtorOf::Struct, def_id, ..) |
1599+
Def::Ctor(CtorOf::Struct, def_id, ..) |
16001600
Def::SelfCtor(.., def_id) => {
16011601
// Everything but the final segment should have no
16021602
// parameters at all.
@@ -1608,7 +1608,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
16081608
}
16091609

16101610
// Case 2. Reference to a variant constructor.
1611-
Def::Ctor(hir::CtorOf::Variant, def_id, ..) | Def::Variant(def_id, ..) => {
1611+
Def::Ctor(CtorOf::Variant, def_id, ..) | Def::Variant(def_id, ..) => {
16121612
let adt_def = self_ty.map(|t| t.ty_adt_def().unwrap());
16131613
let (generics_def_id, index) = if let Some(adt_def) = adt_def {
16141614
debug_assert!(adt_def.is_enum());

src/librustc_typeck/check/method/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::namespace::Namespace;
1515
use errors::{Applicability, DiagnosticBuilder};
1616
use rustc_data_structures::sync::Lrc;
1717
use rustc::hir;
18-
use rustc::hir::def::Def;
18+
use rustc::hir::def::{CtorOf, Def};
1919
use rustc::hir::def_id::DefId;
2020
use rustc::traits;
2121
use rustc::ty::subst::{InternalSubsts, SubstsRef};
@@ -422,8 +422,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
422422
// them as well. It's ok to use the variant's id as a ctor id since an
423423
// error will be reported on any use of such resolution anyway.
424424
let ctor_def_id = variant_def.ctor_def_id.unwrap_or(variant_def.def_id);
425-
let def = Def::Ctor(hir::CtorOf::Variant, ctor_def_id, variant_def.ctor_kind);
426-
425+
let def = Def::Ctor(CtorOf::Variant, ctor_def_id, variant_def.ctor_kind);
427426
tcx.check_stability(def.def_id(), Some(expr_id), span);
428427
return Ok(def);
429428
}

src/librustc_typeck/check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ mod op;
8686
use crate::astconv::{AstConv, PathSeg};
8787
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
8888
use rustc::hir::{self, ExprKind, GenericArg, ItemKind, Node, PatKind, QPath};
89-
use rustc::hir::def::{CtorKind, Def};
89+
use rustc::hir::def::{CtorOf, CtorKind, Def};
9090
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
9191
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
9292
use rustc::hir::itemlikevisit::ItemLikeVisitor;
@@ -5345,7 +5345,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
53455345
Some(adt_def) if adt_def.has_ctor() => {
53465346
let variant = adt_def.non_enum_variant();
53475347
let ctor_def_id = variant.ctor_def_id.unwrap();
5348-
let def = Def::Ctor(hir::CtorOf::Struct, ctor_def_id, variant.ctor_kind);
5348+
let def = Def::Ctor(CtorOf::Struct, ctor_def_id, variant.ctor_kind);
53495349
(def, ctor_def_id, tcx.type_of(ctor_def_id))
53505350
}
53515351
_ => {
@@ -5418,7 +5418,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
54185418
let mut user_self_ty = None;
54195419
let mut is_alias_variant_ctor = false;
54205420
match def {
5421-
Def::Ctor(hir::CtorOf::Variant, _, _) => {
5421+
Def::Ctor(CtorOf::Variant, _, _) => {
54225422
if let Some(self_ty) = self_ty {
54235423
let adt_def = self_ty.ty_adt_def().unwrap();
54245424
user_self_ty = Some(UserSelfTy {

0 commit comments

Comments
 (0)