diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-03-24 17:49:58 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-03-24 17:59:18 +0300 |
| commit | 2cbc25e6fce9bb594ea78ccfd58ef1b6ea42ea38 (patch) | |
| tree | 96398c53c365693a2e0a0843b957478e22803139 /src/librustc/ty | |
| parent | 5bcf9f4f119b8109c6c642dcfeb63fb39c26950a (diff) | |
| download | rust-2cbc25e6fce9bb594ea78ccfd58ef1b6ea42ea38.tar.gz rust-2cbc25e6fce9bb594ea78ccfd58ef1b6ea42ea38.zip | |
Merge `DefPathData::VariantCtor` and `DefPathData::StructCtor`
Diffstat (limited to 'src/librustc/ty')
| -rw-r--r-- | src/librustc/ty/instance.rs | 3 | ||||
| -rw-r--r-- | src/librustc/ty/mod.rs | 4 | ||||
| -rw-r--r-- | src/librustc/ty/print/pretty.rs | 11 | ||||
| -rw-r--r-- | src/librustc/ty/util.rs | 4 |
4 files changed, 10 insertions, 12 deletions
diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index 84ce826c6a5..f54e69f352a 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -150,8 +150,7 @@ impl<'tcx> InstanceDef<'tcx> { _ => return true }; match tcx.def_key(def_id).disambiguated_data.data { - DefPathData::StructCtor | DefPathData::VariantCtor | - DefPathData::ClosureExpr => true, + DefPathData::Ctor | DefPathData::ClosureExpr => true, _ => false } } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 3ab3ae0c537..880f75ab9dd 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2960,8 +2960,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } else { let def_key = self.def_key(id); match def_key.disambiguated_data.data { - // The name of a `StructCtor` or `VariantCtor` is that of its parent. - hir_map::DefPathData::StructCtor | hir_map::DefPathData::VariantCtor => + // The name of a constructor is that of its parent. + hir_map::DefPathData::Ctor => self.item_name(DefId { krate: id.krate, index: def_key.parent.unwrap() diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index 3d6a2cf9224..c9a4961a8e0 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -285,13 +285,13 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>: let mut cur_def_key = self.tcx().def_key(def_id); debug!("try_print_visible_def_path: cur_def_key={:?}", cur_def_key); - // For a UnitStruct or TupleStruct we want the name of its parent rather than <unnamed>. + // For a constructor we want the name of its parent rather than <unnamed>. match cur_def_key.disambiguated_data.data { - DefPathData::StructCtor | DefPathData::VariantCtor => { + DefPathData::Ctor => { let parent = DefId { krate: def_id.krate, index: cur_def_key.parent - .expect("DefPathData::StructCtor/VariantData missing a parent"), + .expect("DefPathData::Ctor/VariantData missing a parent"), }; cur_def_key = self.tcx().def_key(parent); @@ -864,8 +864,7 @@ impl TyCtxt<'_, '_, '_> { DefPathData::AnonConst | DefPathData::ConstParam(..) | DefPathData::ClosureExpr | - DefPathData::VariantCtor | - DefPathData::StructCtor => Namespace::ValueNS, + DefPathData::Ctor => Namespace::ValueNS, DefPathData::MacroDef(..) => Namespace::MacroNS, @@ -1029,7 +1028,7 @@ impl<F: fmt::Write> Printer<'gcx, 'tcx> for FmtPrinter<'_, 'gcx, 'tcx, F> { // Skip `::{{constructor}}` on tuple/unit structs. match disambiguated_data.data { - DefPathData::StructCtor | DefPathData::VariantCtor => return Ok(self), + DefPathData::Ctor => return Ok(self), _ => {} } diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 4fb2bfb075c..ccead14e76b 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -549,8 +549,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// Returns `true` if this `DefId` refers to the implicit constructor for /// a tuple struct like `struct Foo(u32)`, and `false` otherwise. - pub fn is_struct_constructor(self, def_id: DefId) -> bool { - self.def_key(def_id).disambiguated_data.data == DefPathData::StructCtor + pub fn is_constructor(self, def_id: DefId) -> bool { + self.def_key(def_id).disambiguated_data.data == DefPathData::Ctor } /// Given the `DefId` of a fn or closure, returns the `DefId` of |
