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.
This commit is contained in:
parent
db4770f699
commit
88f8f07794
17 changed files with 55 additions and 56 deletions
|
|
@ -9,6 +9,15 @@ use crate::ty;
|
|||
|
||||
use self::Namespace::*;
|
||||
|
||||
/// Encodes if a `Def::Ctor` is the constructor of an enum variant or a struct.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, HashStable)]
|
||||
pub enum CtorOf {
|
||||
/// This `Def::Ctor` is a synthesized constructor of a tuple or unit struct.
|
||||
Struct,
|
||||
/// This `Def::Ctor` is a synthesized constructor of a tuple or unit variant.
|
||||
Variant,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, HashStable)]
|
||||
pub enum CtorKind {
|
||||
/// Constructor function automatically created by a tuple struct/variant.
|
||||
|
|
@ -64,7 +73,7 @@ pub enum Def {
|
|||
ConstParam(DefId),
|
||||
Static(DefId, bool /* is_mutbl */),
|
||||
/// `DefId` refers to the struct or enum variant's constructor.
|
||||
Ctor(hir::CtorOf, DefId, CtorKind),
|
||||
Ctor(CtorOf, DefId, CtorKind),
|
||||
SelfCtor(DefId /* impl */), // `DefId` refers to the impl
|
||||
Method(DefId),
|
||||
AssociatedConst(DefId),
|
||||
|
|
@ -306,13 +315,13 @@ impl Def {
|
|||
Def::Static(..) => "static",
|
||||
Def::Enum(..) => "enum",
|
||||
Def::Variant(..) => "variant",
|
||||
Def::Ctor(hir::CtorOf::Variant, _, CtorKind::Fn) => "tuple variant",
|
||||
Def::Ctor(hir::CtorOf::Variant, _, CtorKind::Const) => "unit variant",
|
||||
Def::Ctor(hir::CtorOf::Variant, _, CtorKind::Fictive) => "struct variant",
|
||||
Def::Ctor(CtorOf::Variant, _, CtorKind::Fn) => "tuple variant",
|
||||
Def::Ctor(CtorOf::Variant, _, CtorKind::Const) => "unit variant",
|
||||
Def::Ctor(CtorOf::Variant, _, CtorKind::Fictive) => "struct variant",
|
||||
Def::Struct(..) => "struct",
|
||||
Def::Ctor(hir::CtorOf::Struct, _, CtorKind::Fn) => "tuple struct",
|
||||
Def::Ctor(hir::CtorOf::Struct, _, CtorKind::Const) => "unit struct",
|
||||
Def::Ctor(hir::CtorOf::Struct, _, CtorKind::Fictive) =>
|
||||
Def::Ctor(CtorOf::Struct, _, CtorKind::Fn) => "tuple struct",
|
||||
Def::Ctor(CtorOf::Struct, _, CtorKind::Const) => "unit struct",
|
||||
Def::Ctor(CtorOf::Struct, _, CtorKind::Fictive) =>
|
||||
bug!("impossible struct constructor"),
|
||||
Def::Existential(..) => "existential type",
|
||||
Def::TyAlias(..) => "type alias",
|
||||
|
|
|
|||
|
|
@ -371,8 +371,8 @@ impl<'hir> Map<'hir> {
|
|||
}
|
||||
Node::Ctor(variant_data) => {
|
||||
let ctor_of = match self.find(self.get_parent_node(node_id)) {
|
||||
Some(Node::Item(..)) => CtorOf::Struct,
|
||||
Some(Node::Variant(..)) => CtorOf::Variant,
|
||||
Some(Node::Item(..)) => def::CtorOf::Struct,
|
||||
Some(Node::Variant(..)) => def::CtorOf::Variant,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
variant_data.ctor_hir_id()
|
||||
|
|
|
|||
|
|
@ -2559,15 +2559,6 @@ impl CodegenFnAttrs {
|
|||
}
|
||||
}
|
||||
|
||||
/// Encodes if a `Node::Ctor` is the constructor of an enum variant or a struct.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, HashStable)]
|
||||
pub enum CtorOf {
|
||||
/// This `Node::Ctor` is a synthesized constructor of a tuple or unit struct.
|
||||
Struct,
|
||||
/// This `Node::Ctor` is a synthesized constructor of a tuple or unit variant.
|
||||
Variant,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum Node<'hir> {
|
||||
Item(&'hir Item),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::hir::def::Def;
|
||||
use crate::hir::def::{CtorOf, Def};
|
||||
use crate::hir::def_id::DefId;
|
||||
use crate::hir::{self, HirId, PatKind};
|
||||
use syntax::ast;
|
||||
|
|
@ -126,7 +126,7 @@ impl hir::Pat {
|
|||
PatKind::Struct(hir::QPath::Resolved(_, ref path), ..) => {
|
||||
match path.def {
|
||||
Def::Variant(id) => variants.push(id),
|
||||
Def::Ctor(hir::CtorOf::Variant, id, _) => variants.push(id),
|
||||
Def::Ctor(CtorOf::Variant, id, _) => variants.push(id),
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use crate::hir::{self, PatKind, TyKind};
|
|||
use crate::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use crate::hir::itemlikevisit::ItemLikeVisitor;
|
||||
|
||||
use crate::hir::def::Def;
|
||||
use crate::hir::def::{CtorOf, Def};
|
||||
use crate::hir::CodegenFnAttrFlags;
|
||||
use crate::hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use crate::lint;
|
||||
|
|
@ -76,7 +76,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
_ if self.in_pat => (),
|
||||
Def::PrimTy(..) | Def::SelfTy(..) | Def::SelfCtor(..) |
|
||||
Def::Local(..) | Def::Upvar(..) => {}
|
||||
Def::Ctor(hir::CtorOf::Variant, ctor_def_id, ..) => {
|
||||
Def::Ctor(CtorOf::Variant, ctor_def_id, ..) => {
|
||||
let variant_id = self.tcx.parent(ctor_def_id).unwrap();
|
||||
let enum_id = self.tcx.parent(variant_id).unwrap();
|
||||
self.check_def_id(enum_id);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ pub use self::MatchMode::*;
|
|||
use self::TrackMatchMode::*;
|
||||
use self::OverloadedCallType::*;
|
||||
|
||||
use crate::hir::def::Def;
|
||||
use crate::hir::def::{CtorOf, Def};
|
||||
use crate::hir::def_id::DefId;
|
||||
use crate::infer::InferCtxt;
|
||||
use crate::middle::mem_categorization as mc;
|
||||
|
|
@ -902,7 +902,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
|||
};
|
||||
let def = mc.tables.qpath_def(qpath, pat.hir_id);
|
||||
match def {
|
||||
Def::Ctor(hir::CtorOf::Variant, variant_ctor_did, ..) => {
|
||||
Def::Ctor(CtorOf::Variant, variant_ctor_did, ..) => {
|
||||
let variant_did = mc.tcx.parent(variant_ctor_did).unwrap();
|
||||
let downcast_cmt = mc.cat_downcast_if_needed(pat, cmt_pat, variant_did);
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ use crate::middle::region;
|
|||
use crate::hir::def_id::{DefId, LocalDefId};
|
||||
use crate::hir::Node;
|
||||
use crate::infer::InferCtxt;
|
||||
use crate::hir::def::{Def, CtorKind};
|
||||
use crate::hir::def::{CtorOf, Def, CtorKind};
|
||||
use crate::ty::adjustment;
|
||||
use crate::ty::{self, DefIdTree, Ty, TyCtxt};
|
||||
use crate::ty::fold::TypeFoldable;
|
||||
|
|
@ -1274,14 +1274,14 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
debug!("access to unresolvable pattern {:?}", pat);
|
||||
return Err(())
|
||||
}
|
||||
Def::Ctor(hir::CtorOf::Variant, variant_ctor_did, CtorKind::Fn) => {
|
||||
Def::Ctor(CtorOf::Variant, variant_ctor_did, CtorKind::Fn) => {
|
||||
let variant_did = self.tcx.parent(variant_ctor_did).unwrap();
|
||||
let enum_did = self.tcx.parent(variant_did).unwrap();
|
||||
(self.cat_downcast_if_needed(pat, cmt, variant_did),
|
||||
self.tcx.adt_def(enum_did)
|
||||
.variant_with_ctor_id(variant_ctor_did).fields.len())
|
||||
}
|
||||
Def::Ctor(hir::CtorOf::Struct, _, CtorKind::Fn) | Def::SelfCtor(..) => {
|
||||
Def::Ctor(CtorOf::Struct, _, CtorKind::Fn) | Def::SelfCtor(..) => {
|
||||
let ty = self.pat_ty_unadjusted(&pat)?;
|
||||
match ty.sty {
|
||||
ty::Adt(adt_def, _) => {
|
||||
|
|
@ -1316,7 +1316,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
|||
debug!("access to unresolvable pattern {:?}", pat);
|
||||
return Err(())
|
||||
}
|
||||
Def::Ctor(hir::CtorOf::Variant, variant_ctor_did, _) => {
|
||||
Def::Ctor(CtorOf::Variant, variant_ctor_did, _) => {
|
||||
let variant_did = self.tcx.parent(variant_ctor_did).unwrap();
|
||||
self.cat_downcast_if_needed(pat, cmt, variant_did)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ pub use self::fold::TypeFoldable;
|
|||
|
||||
use crate::hir::{map as hir_map, FreevarMap, GlobMap, TraitMap};
|
||||
use crate::hir::{HirId, Node};
|
||||
use crate::hir::def::{Def, CtorKind, ExportMap};
|
||||
use crate::hir::def::{Def, CtorOf, CtorKind, ExportMap};
|
||||
use crate::hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_macros::HashStable;
|
||||
|
|
@ -2941,12 +2941,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
Def::Struct(did) | Def::Union(did) => {
|
||||
self.adt_def(did).non_enum_variant()
|
||||
}
|
||||
Def::Ctor(hir::CtorOf::Variant, variant_ctor_did, ..) => {
|
||||
Def::Ctor(CtorOf::Variant, variant_ctor_did, ..) => {
|
||||
let variant_did = self.parent(variant_ctor_did).unwrap();
|
||||
let enum_did = self.parent(variant_did).unwrap();
|
||||
self.adt_def(enum_did).variant_with_ctor_id(variant_ctor_did)
|
||||
}
|
||||
Def::Ctor(hir::CtorOf::Struct, ctor_did, ..) => {
|
||||
Def::Ctor(CtorOf::Struct, ctor_did, ..) => {
|
||||
let struct_did = self.parent(ctor_did).expect("struct ctor has no parent");
|
||||
self.adt_def(struct_did).non_enum_variant()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use rustc::hir::map::{DefKey, DefPath, DefPathData, DefPathHash, Definitions};
|
|||
use rustc::hir;
|
||||
use rustc::middle::cstore::LinkagePreference;
|
||||
use rustc::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
|
||||
use rustc::hir::def::{self, Def, CtorKind};
|
||||
use rustc::hir::def::{self, Def, CtorOf, CtorKind};
|
||||
use rustc::hir::def_id::{CrateNum, DefId, DefIndex, DefIndexAddressSpace,
|
||||
CRATE_DEF_INDEX, LOCAL_CRATE, LocalDefId};
|
||||
use rustc::hir::map::definitions::DefPathTable;
|
||||
|
|
@ -817,7 +817,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
if let Some(ctor_def_id) = self.get_ctor_def_id(child_index) {
|
||||
let ctor_kind = self.get_ctor_kind(child_index);
|
||||
let ctor_def = Def::Ctor(
|
||||
hir::CtorOf::Struct, ctor_def_id, ctor_kind);
|
||||
hir::def::CtorOf::Struct, ctor_def_id, ctor_kind);
|
||||
let vis = self.get_visibility(ctor_def_id.index);
|
||||
callback(def::Export { def: ctor_def, vis, ident, span });
|
||||
}
|
||||
|
|
@ -829,7 +829,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
// error will be reported on any use of such resolution anyway.
|
||||
let ctor_def_id = self.get_ctor_def_id(child_index).unwrap_or(def_id);
|
||||
let ctor_kind = self.get_ctor_kind(child_index);
|
||||
let ctor_def = Def::Ctor(hir::CtorOf::Variant, ctor_def_id, ctor_kind);
|
||||
let ctor_def = Def::Ctor(CtorOf::Variant, ctor_def_id, ctor_kind);
|
||||
let vis = self.get_visibility(ctor_def_id.index);
|
||||
callback(def::Export { def: ctor_def, ident, vis, span });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::hair::cx::block;
|
|||
use crate::hair::cx::to_ref::ToRef;
|
||||
use crate::hair::util::UserAnnotatedTyHelpers;
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
use rustc::hir::def::{Def, CtorKind};
|
||||
use rustc::hir::def::{CtorOf, Def, CtorKind};
|
||||
use rustc::mir::interpret::{GlobalId, ErrorHandled, ConstValue};
|
||||
use rustc::ty::{self, AdtKind, Ty};
|
||||
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>,
|
|||
.ty_adt_def()
|
||||
.and_then(|adt_def| {
|
||||
match def {
|
||||
Def::Ctor(hir::CtorOf::Variant, variant_ctor_id, CtorKind::Const) => {
|
||||
Def::Ctor(CtorOf::Variant, variant_ctor_id, CtorKind::Const) => {
|
||||
let idx = adt_def.variant_index_with_ctor_id(variant_ctor_id);
|
||||
let (d, o) = adt_def.discriminant_def_for_variant(idx);
|
||||
use rustc::ty::util::IntTypeExt;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use rustc::ty::{CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTyp
|
|||
use rustc::ty::subst::{SubstsRef, Kind};
|
||||
use rustc::ty::layout::VariantIdx;
|
||||
use rustc::hir::{self, PatKind, RangeEnd};
|
||||
use rustc::hir::def::{Def, CtorKind};
|
||||
use rustc::hir::def::{CtorOf, Def, CtorKind};
|
||||
use rustc::hir::pat_util::EnumerateAndAdjustIterator;
|
||||
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
|
|
@ -734,7 +734,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
subpatterns: Vec<FieldPattern<'tcx>>,
|
||||
) -> PatternKind<'tcx> {
|
||||
let def = match def {
|
||||
Def::Ctor(hir::CtorOf::Variant, variant_ctor_id, ..) => {
|
||||
Def::Ctor(CtorOf::Variant, variant_ctor_id, ..) => {
|
||||
let variant_id = self.tcx.parent(variant_ctor_id).unwrap();
|
||||
Def::Variant(variant_id)
|
||||
},
|
||||
|
|
@ -765,7 +765,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
Def::Struct(..) | Def::Ctor(hir::CtorOf::Struct, ..) | Def::Union(..) |
|
||||
Def::Struct(..) | Def::Ctor(CtorOf::Struct, ..) | Def::Union(..) |
|
||||
Def::TyAlias(..) | Def::AssociatedTy(..) | Def::SelfTy(..) | Def::SelfCtor(..) => {
|
||||
PatternKind::Leaf { subpatterns }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use crate::Namespace::{self, TypeNS, ValueNS, MacroNS};
|
|||
use crate::{resolve_error, resolve_struct_error, ResolutionError};
|
||||
|
||||
use rustc::bug;
|
||||
use rustc::hir::{self, def::*};
|
||||
use rustc::hir::def::*;
|
||||
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, LOCAL_CRATE, DefId};
|
||||
use rustc::ty;
|
||||
use rustc::middle::cstore::CrateStore;
|
||||
|
|
@ -533,7 +533,7 @@ impl<'a> Resolver<'a> {
|
|||
// If this is a tuple or unit struct, define a name
|
||||
// in the value namespace as well.
|
||||
if let Some(ctor_node_id) = struct_def.ctor_id() {
|
||||
let ctor_def = Def::Ctor(hir::CtorOf::Struct,
|
||||
let ctor_def = Def::Ctor(CtorOf::Struct,
|
||||
self.definitions.local_def_id(ctor_node_id),
|
||||
CtorKind::from_ast(struct_def));
|
||||
self.define(parent, ident, ValueNS, (ctor_def, ctor_vis, sp, expansion));
|
||||
|
|
@ -596,7 +596,7 @@ impl<'a> Resolver<'a> {
|
|||
let ctor_node_id = variant.node.data.ctor_id().unwrap_or(variant.node.id);
|
||||
let ctor_def_id = self.definitions.local_def_id(ctor_node_id);
|
||||
let ctor_kind = CtorKind::from_ast(&variant.node.data);
|
||||
let ctor_def = Def::Ctor(hir::CtorOf::Variant, ctor_def_id, ctor_kind);
|
||||
let ctor_def = Def::Ctor(CtorOf::Variant, ctor_def_id, ctor_kind);
|
||||
self.define(parent, ident, ValueNS, (ctor_def, vis, variant.span, expansion));
|
||||
}
|
||||
|
||||
|
|
@ -654,10 +654,10 @@ impl<'a> Resolver<'a> {
|
|||
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion));
|
||||
}
|
||||
Def::Fn(..) | Def::Static(..) | Def::Const(..) |
|
||||
Def::Ctor(hir::CtorOf::Variant, ..) => {
|
||||
Def::Ctor(CtorOf::Variant, ..) => {
|
||||
self.define(parent, ident, ValueNS, (def, vis, DUMMY_SP, expansion));
|
||||
}
|
||||
Def::Ctor(hir::CtorOf::Struct, def_id, ..) => {
|
||||
Def::Ctor(CtorOf::Struct, def_id, ..) => {
|
||||
self.define(parent, ident, ValueNS, (def, vis, DUMMY_SP, expansion));
|
||||
|
||||
if let Some(struct_def_id) =
|
||||
|
|
|
|||
|
|
@ -1360,7 +1360,7 @@ impl<'a> NameBinding<'a> {
|
|||
fn is_variant(&self) -> bool {
|
||||
match self.kind {
|
||||
NameBindingKind::Def(Def::Variant(..), _) |
|
||||
NameBindingKind::Def(Def::Ctor(hir::CtorOf::Variant, ..), _) => true,
|
||||
NameBindingKind::Def(Def::Ctor(CtorOf::Variant, ..), _) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ mod span_utils;
|
|||
mod sig;
|
||||
|
||||
use rustc::hir;
|
||||
use rustc::hir::def::Def as HirDef;
|
||||
use rustc::hir::def::{CtorOf, Def as HirDef};
|
||||
use rustc::hir::Node;
|
||||
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc::middle::privacy::AccessLevels;
|
||||
|
|
@ -757,7 +757,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
ref_id: id_from_def_id(def_id),
|
||||
})
|
||||
}
|
||||
HirDef::Ctor(hir::CtorOf::Struct, def_id, _) => {
|
||||
HirDef::Ctor(CtorOf::Struct, def_id, _) => {
|
||||
// This is a reference to a tuple struct where the def_id points
|
||||
// to an invisible constructor function. That is not a very useful
|
||||
// def, so adjust to point to the tuple struct itself.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use errors::{Applicability, DiagnosticId};
|
||||
use crate::hir::{self, GenericArg, GenericArgs, ExprKind};
|
||||
use crate::hir::def::Def;
|
||||
use crate::hir::def::{CtorOf, Def};
|
||||
use crate::hir::def_id::DefId;
|
||||
use crate::hir::HirVec;
|
||||
use crate::lint;
|
||||
|
|
@ -1596,7 +1596,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
|||
|
||||
match def {
|
||||
// Case 1. Reference to a struct constructor.
|
||||
Def::Ctor(hir::CtorOf::Struct, def_id, ..) |
|
||||
Def::Ctor(CtorOf::Struct, def_id, ..) |
|
||||
Def::SelfCtor(.., def_id) => {
|
||||
// Everything but the final segment should have no
|
||||
// parameters at all.
|
||||
|
|
@ -1608,7 +1608,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
|||
}
|
||||
|
||||
// Case 2. Reference to a variant constructor.
|
||||
Def::Ctor(hir::CtorOf::Variant, def_id, ..) | Def::Variant(def_id, ..) => {
|
||||
Def::Ctor(CtorOf::Variant, def_id, ..) | Def::Variant(def_id, ..) => {
|
||||
let adt_def = self_ty.map(|t| t.ty_adt_def().unwrap());
|
||||
let (generics_def_id, index) = if let Some(adt_def) = adt_def {
|
||||
debug_assert!(adt_def.is_enum());
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use crate::namespace::Namespace;
|
|||
use errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc::hir;
|
||||
use rustc::hir::def::Def;
|
||||
use rustc::hir::def::{CtorOf, Def};
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::traits;
|
||||
use rustc::ty::subst::{InternalSubsts, SubstsRef};
|
||||
|
|
@ -422,8 +422,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
// them as well. It's ok to use the variant's id as a ctor id since an
|
||||
// error will be reported on any use of such resolution anyway.
|
||||
let ctor_def_id = variant_def.ctor_def_id.unwrap_or(variant_def.def_id);
|
||||
let def = Def::Ctor(hir::CtorOf::Variant, ctor_def_id, variant_def.ctor_kind);
|
||||
|
||||
let def = Def::Ctor(CtorOf::Variant, ctor_def_id, variant_def.ctor_kind);
|
||||
tcx.check_stability(def.def_id(), Some(expr_id), span);
|
||||
return Ok(def);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ mod op;
|
|||
use crate::astconv::{AstConv, PathSeg};
|
||||
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
|
||||
use rustc::hir::{self, ExprKind, GenericArg, ItemKind, Node, PatKind, QPath};
|
||||
use rustc::hir::def::{CtorKind, Def};
|
||||
use rustc::hir::def::{CtorOf, CtorKind, Def};
|
||||
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||
|
|
@ -5345,7 +5345,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
Some(adt_def) if adt_def.has_ctor() => {
|
||||
let variant = adt_def.non_enum_variant();
|
||||
let ctor_def_id = variant.ctor_def_id.unwrap();
|
||||
let def = Def::Ctor(hir::CtorOf::Struct, ctor_def_id, variant.ctor_kind);
|
||||
let def = Def::Ctor(CtorOf::Struct, ctor_def_id, variant.ctor_kind);
|
||||
(def, ctor_def_id, tcx.type_of(ctor_def_id))
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -5418,7 +5418,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
let mut user_self_ty = None;
|
||||
let mut is_alias_variant_ctor = false;
|
||||
match def {
|
||||
Def::Ctor(hir::CtorOf::Variant, _, _) => {
|
||||
Def::Ctor(CtorOf::Variant, _, _) => {
|
||||
if let Some(self_ty) = self_ty {
|
||||
let adt_def = self_ty.ty_adt_def().unwrap();
|
||||
user_self_ty = Some(UserSelfTy {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue