diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-07-25 13:41:32 +0300 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2018-09-07 11:34:41 -0400 |
| commit | 1242639b88b0dee9ebb0f103efe017826c5b334e (patch) | |
| tree | 1bcce301506858bebdc7fd949ec2430db46586a0 /src/librustc | |
| parent | 5a3292f163da3327523ddec5bc44d17c2378ec37 (diff) | |
| download | rust-1242639b88b0dee9ebb0f103efe017826c5b334e.tar.gz rust-1242639b88b0dee9ebb0f103efe017826c5b334e.zip | |
change syntax of `newtype_index` to look like a struct decl
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/dep_graph/graph.rs | 4 | ||||
| -rw-r--r-- | src/librustc/dep_graph/serialized.rs | 4 | ||||
| -rw-r--r-- | src/librustc/hir/def_id.rs | 7 | ||||
| -rw-r--r-- | src/librustc/middle/region.rs | 7 | ||||
| -rw-r--r-- | src/librustc/mir/mod.rs | 32 | ||||
| -rw-r--r-- | src/librustc/ty/sty.rs | 18 |
6 files changed, 48 insertions, 24 deletions
diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 4df0fc443a2..ff8bf3ca9f4 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -39,7 +39,9 @@ pub struct DepGraph { fingerprints: Lrc<Lock<IndexVec<DepNodeIndex, Fingerprint>>> } -newtype_index!(DepNodeIndex); +newtype_index! { + pub struct DepNodeIndex { .. } +} impl DepNodeIndex { const INVALID: DepNodeIndex = DepNodeIndex(::std::u32::MAX); diff --git a/src/librustc/dep_graph/serialized.rs b/src/librustc/dep_graph/serialized.rs index 60fc813a25d..4c896a33e59 100644 --- a/src/librustc/dep_graph/serialized.rs +++ b/src/librustc/dep_graph/serialized.rs @@ -14,7 +14,9 @@ use dep_graph::DepNode; use ich::Fingerprint; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; -newtype_index!(SerializedDepNodeIndex); +newtype_index! { + pub struct SerializedDepNodeIndex { .. } +} /// Data for use when recompiling the **current crate**. #[derive(Debug, RustcEncodable, RustcDecodable)] diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs index be37ea18457..0feeb01adba 100644 --- a/src/librustc/hir/def_id.rs +++ b/src/librustc/hir/def_id.rs @@ -15,8 +15,8 @@ use serialize; use std::fmt; use std::u32; -newtype_index!(CrateNum - { +newtype_index! { + pub struct CrateNum { ENCODABLE = custom DEBUG_FORMAT = "crate{}", @@ -35,7 +35,8 @@ newtype_index!(CrateNum /// A special CrateNum that we use for the tcx.rcache when decoding from /// the incr. comp. cache. const RESERVED_FOR_INCR_COMP_CACHE = u32::MAX - 2, - }); + } +} impl CrateNum { pub fn new(x: usize) -> CrateNum { diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index e281cbf9488..fceab160192 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -159,11 +159,12 @@ pub struct BlockRemainder { pub first_statement_index: FirstStatementIndex, } -newtype_index!(FirstStatementIndex - { +newtype_index! { + pub struct FirstStatementIndex { pub idx MAX = SCOPE_DATA_REMAINDER_MAX - }); + } +} impl From<ScopeData> for Scope { #[inline] diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index f66be6dc54d..3ab8de6de44 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -523,11 +523,12 @@ impl BorrowKind { /////////////////////////////////////////////////////////////////////////// // Variables and temps -newtype_index!(Local - { +newtype_index! { + pub struct Local { DEBUG_FORMAT = "_{}", const RETURN_PLACE = 0, - }); + } +} /// Classifies locals into categories. See `Mir::local_kind`. #[derive(PartialEq, Eq, Debug)] @@ -852,7 +853,11 @@ pub struct UpvarDecl { /////////////////////////////////////////////////////////////////////////// // BasicBlock -newtype_index!(BasicBlock { DEBUG_FORMAT = "bb{}" }); +newtype_index! { + pub struct BasicBlock { + DEBUG_FORMAT = "bb{}" + } +} impl BasicBlock { pub fn start_location(self) -> Location { @@ -1822,7 +1827,11 @@ pub type PlaceProjection<'tcx> = Projection<'tcx, Place<'tcx>, Local, Ty<'tcx>>; /// and the index is a local. pub type PlaceElem<'tcx> = ProjectionElem<'tcx, Local, Ty<'tcx>>; -newtype_index!(Field { DEBUG_FORMAT = "field[{}]" }); +newtype_index! { + pub struct Field { + DEBUG_FORMAT = "field[{}]" + } +} impl<'tcx> Place<'tcx> { pub fn field(self, f: Field, ty: Ty<'tcx>) -> Place<'tcx> { @@ -1895,11 +1904,12 @@ impl<'tcx> Debug for Place<'tcx> { /////////////////////////////////////////////////////////////////////////// // Scopes -newtype_index!(SourceScope - { +newtype_index! { + pub struct SourceScope { DEBUG_FORMAT = "scope[{}]", const OUTERMOST_SOURCE_SCOPE = 0, - }); + } +} #[derive(Clone, Debug, RustcEncodable, RustcDecodable)] pub struct SourceScopeData { @@ -2271,7 +2281,11 @@ pub struct Constant<'tcx> { pub literal: &'tcx ty::Const<'tcx>, } -newtype_index!(Promoted { DEBUG_FORMAT = "promoted[{}]" }); +newtype_index! { + pub struct Promoted { + DEBUG_FORMAT = "promoted[{}]" + } +} impl<'tcx> Debug for Constant<'tcx> { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 7c7ee9b330e..f15f7093d94 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1034,11 +1034,12 @@ impl<'a, 'gcx, 'tcx> ParamTy { /// is the outer fn. /// /// [dbi]: http://en.wikipedia.org/wiki/De_Bruijn_index -newtype_index!(DebruijnIndex - { +newtype_index! { + pub struct DebruijnIndex { DEBUG_FORMAT = "DebruijnIndex({})", const INNERMOST = 0, - }); + } +} pub type Region<'tcx> = &'tcx RegionKind; @@ -1176,11 +1177,12 @@ pub struct FloatVid { pub index: u32, } -newtype_index!(RegionVid - { +newtype_index! { + pub struct RegionVid { pub idx DEBUG_FORMAT = custom, - }); + } +} impl Atom for RegionVid { fn index(self) -> usize { @@ -1217,7 +1219,9 @@ pub enum InferTy { CanonicalTy(CanonicalVar), } -newtype_index!(CanonicalVar); +newtype_index! { + pub struct CanonicalVar { .. } +} /// A `ProjectionPredicate` for an `ExistentialTraitRef`. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] |
