diff options
| -rw-r--r-- | src/librustc/hir/def.rs | 8 | ||||
| -rw-r--r-- | src/librustc/ty/mod.rs | 4 | ||||
| -rw-r--r-- | src/librustc_mir/hair/cx/expr.rs | 6 | ||||
| -rw-r--r-- | src/librustc_resolve/error_reporting.rs | 4 | ||||
| -rw-r--r-- | src/librustc_typeck/check/_match.rs | 8 | ||||
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 2 |
6 files changed, 14 insertions, 18 deletions
diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index 87a6065bb75..6567d9e8c7a 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -37,13 +37,11 @@ pub enum NonMacroAttrKind { pub enum Def { // Type namespace Mod(DefId), - /// `DefId` refers to `NodeId` of the struct. `Def::VariantCtor` represents the constructor of - /// a struct. + /// `DefId` refers to the struct itself, `Def::Ctor` refers to its constructor if it exists. Struct(DefId), Union(DefId), Enum(DefId), - /// `DefId` refers to the `NodeId` of the variant. `Def::VariantCtor` represents the - /// constructor of an enum variant. + /// `DefId` refers to the variant itself, `Def::Ctor` refers to its constructor if it exists. Variant(DefId), Trait(DefId), /// `existential type Foo: Bar;` @@ -65,7 +63,7 @@ pub enum Def { Const(DefId), ConstParam(DefId), Static(DefId, bool /* is_mutbl */), - /// `DefId` refers to `NodeId` of the struct or enum variant's constructor. + /// `DefId` refers to the struct or enum variant's constructor. Ctor(hir::CtorOf, DefId, CtorKind), SelfCtor(DefId /* impl */), // `DefId` refers to the impl Method(DefId), diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 10755a9c021..3ab3ae0c537 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2322,8 +2322,8 @@ impl<'a, 'gcx, 'tcx> AdtDef { pub fn variant_of_def(&self, def: Def) -> &VariantDef { match def { Def::Variant(vid) => self.variant_with_id(vid), - Def::Ctor(hir::CtorOf::Variant, cid, ..) => self.variant_with_ctor_id(cid), - Def::Struct(..) | Def::Ctor(..) | Def::Union(..) | + Def::Ctor(_, cid, ..) => self.variant_with_ctor_id(cid), + Def::Struct(..) | Def::Union(..) | Def::TyAlias(..) | Def::AssociatedTy(..) | Def::SelfTy(..) | Def::SelfCtor(..) => self.non_enum_variant(), _ => bug!("unexpected def {:?} in variant_of_def", def) diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 610c63b208c..27dba512dfb 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -261,10 +261,8 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, // Tuple-like ADTs are represented as ExprKind::Call. We convert them here. expr_ty.ty_adt_def().and_then(|adt_def| { match path.def { - Def::Ctor(hir::CtorOf::Variant, variant_ctor_id, CtorKind::Fn) => { - Some((adt_def, adt_def.variant_index_with_ctor_id(variant_ctor_id))) - } - Def::Ctor(hir::CtorOf::Struct, _, CtorKind::Fn) | + Def::Ctor(_, ctor_id, CtorKind::Fn) => + Some((adt_def, adt_def.variant_index_with_ctor_id(ctor_id))), Def::SelfCtor(..) => Some((adt_def, VariantIdx::new(0))), _ => None, } diff --git a/src/librustc_resolve/error_reporting.rs b/src/librustc_resolve/error_reporting.rs index 6426ca12c6c..dbd32382194 100644 --- a/src/librustc_resolve/error_reporting.rs +++ b/src/librustc_resolve/error_reporting.rs @@ -2,7 +2,7 @@ use std::cmp::Reverse; use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; use log::debug; -use rustc::hir::{self, def::*}; +use rustc::hir::def::{Def, CtorKind}; use rustc::hir::def::Namespace::*; use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId}; use rustc::session::config::nightly_options; @@ -417,7 +417,7 @@ impl<'a> Resolver<'a> { } (Def::Union(..), _) | (Def::Variant(..), _) | - (Def::Ctor(hir::CtorOf::Variant, _, CtorKind::Fictive), _) if ns == ValueNS => { + (Def::Ctor(_, _, CtorKind::Fictive), _) if ns == ValueNS => { err.span_label(span, format!("did you mean `{} {{ /* fields */ }}`?", path_str)); } diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index d56a0dcc044..5f46a5a1652 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -807,13 +807,13 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); report_unexpected_variant_def(tcx, &def, pat.span, qpath); return tcx.types.err; } - Def::Ctor(hir::CtorOf::Variant, _, CtorKind::Fictive) | - Def::Ctor(hir::CtorOf::Variant, _, CtorKind::Fn) => { + Def::Ctor(_, _, CtorKind::Fictive) | + Def::Ctor(_, _, CtorKind::Fn) => { report_unexpected_variant_def(tcx, &def, pat.span, qpath); return tcx.types.err; } - Def::Ctor(_, _, CtorKind::Const) | Def::SelfCtor(..) | Def::Const(..) | - Def::AssociatedConst(..) => {} // OK + Def::Ctor(_, _, CtorKind::Const) | Def::SelfCtor(..) | + Def::Const(..) | Def::AssociatedConst(..) => {} // OK _ => bug!("unexpected pattern definition: {:?}", def) } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b6bfa9ce27b..e842be0d7e1 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4238,7 +4238,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.set_tainted_by_errors(); tcx.types.err } - Def::Ctor(hir::CtorOf::Variant, _, CtorKind::Fictive) => { + Def::Ctor(_, _, CtorKind::Fictive) => { report_unexpected_variant_def(tcx, &def, expr.span, qpath); tcx.types.err } |
