Skip to content

Commit 1242639

Browse files
committed
change syntax of newtype_index to look like a struct decl
1 parent 5a3292f commit 1242639

File tree

13 files changed

+108
-37
lines changed

13 files changed

+108
-37
lines changed

src/librustc/dep_graph/graph.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ pub struct DepGraph {
3939
fingerprints: Lrc<Lock<IndexVec<DepNodeIndex, Fingerprint>>>
4040
}
4141

42-
newtype_index!(DepNodeIndex);
42+
newtype_index! {
43+
pub struct DepNodeIndex { .. }
44+
}
4345

4446
impl DepNodeIndex {
4547
const INVALID: DepNodeIndex = DepNodeIndex(::std::u32::MAX);

src/librustc/dep_graph/serialized.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use dep_graph::DepNode;
1414
use ich::Fingerprint;
1515
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
1616

17-
newtype_index!(SerializedDepNodeIndex);
17+
newtype_index! {
18+
pub struct SerializedDepNodeIndex { .. }
19+
}
1820

1921
/// Data for use when recompiling the **current crate**.
2022
#[derive(Debug, RustcEncodable, RustcDecodable)]

src/librustc/hir/def_id.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use serialize;
1515
use std::fmt;
1616
use std::u32;
1717

18-
newtype_index!(CrateNum
19-
{
18+
newtype_index! {
19+
pub struct CrateNum {
2020
ENCODABLE = custom
2121
DEBUG_FORMAT = "crate{}",
2222

@@ -35,7 +35,8 @@ newtype_index!(CrateNum
3535
/// A special CrateNum that we use for the tcx.rcache when decoding from
3636
/// the incr. comp. cache.
3737
const RESERVED_FOR_INCR_COMP_CACHE = u32::MAX - 2,
38-
});
38+
}
39+
}
3940

4041
impl CrateNum {
4142
pub fn new(x: usize) -> CrateNum {

src/librustc/middle/region.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,12 @@ pub struct BlockRemainder {
159159
pub first_statement_index: FirstStatementIndex,
160160
}
161161

162-
newtype_index!(FirstStatementIndex
163-
{
162+
newtype_index! {
163+
pub struct FirstStatementIndex {
164164
pub idx
165165
MAX = SCOPE_DATA_REMAINDER_MAX
166-
});
166+
}
167+
}
167168

168169
impl From<ScopeData> for Scope {
169170
#[inline]

src/librustc/mir/mod.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,12 @@ impl BorrowKind {
523523
///////////////////////////////////////////////////////////////////////////
524524
// Variables and temps
525525

526-
newtype_index!(Local
527-
{
526+
newtype_index! {
527+
pub struct Local {
528528
DEBUG_FORMAT = "_{}",
529529
const RETURN_PLACE = 0,
530-
});
530+
}
531+
}
531532

532533
/// Classifies locals into categories. See `Mir::local_kind`.
533534
#[derive(PartialEq, Eq, Debug)]
@@ -852,7 +853,11 @@ pub struct UpvarDecl {
852853
///////////////////////////////////////////////////////////////////////////
853854
// BasicBlock
854855

855-
newtype_index!(BasicBlock { DEBUG_FORMAT = "bb{}" });
856+
newtype_index! {
857+
pub struct BasicBlock {
858+
DEBUG_FORMAT = "bb{}"
859+
}
860+
}
856861

857862
impl BasicBlock {
858863
pub fn start_location(self) -> Location {
@@ -1822,7 +1827,11 @@ pub type PlaceProjection<'tcx> = Projection<'tcx, Place<'tcx>, Local, Ty<'tcx>>;
18221827
/// and the index is a local.
18231828
pub type PlaceElem<'tcx> = ProjectionElem<'tcx, Local, Ty<'tcx>>;
18241829

1825-
newtype_index!(Field { DEBUG_FORMAT = "field[{}]" });
1830+
newtype_index! {
1831+
pub struct Field {
1832+
DEBUG_FORMAT = "field[{}]"
1833+
}
1834+
}
18261835

18271836
impl<'tcx> Place<'tcx> {
18281837
pub fn field(self, f: Field, ty: Ty<'tcx>) -> Place<'tcx> {
@@ -1895,11 +1904,12 @@ impl<'tcx> Debug for Place<'tcx> {
18951904
///////////////////////////////////////////////////////////////////////////
18961905
// Scopes
18971906

1898-
newtype_index!(SourceScope
1899-
{
1907+
newtype_index! {
1908+
pub struct SourceScope {
19001909
DEBUG_FORMAT = "scope[{}]",
19011910
const OUTERMOST_SOURCE_SCOPE = 0,
1902-
});
1911+
}
1912+
}
19031913

19041914
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
19051915
pub struct SourceScopeData {
@@ -2271,7 +2281,11 @@ pub struct Constant<'tcx> {
22712281
pub literal: &'tcx ty::Const<'tcx>,
22722282
}
22732283

2274-
newtype_index!(Promoted { DEBUG_FORMAT = "promoted[{}]" });
2284+
newtype_index! {
2285+
pub struct Promoted {
2286+
DEBUG_FORMAT = "promoted[{}]"
2287+
}
2288+
}
22752289

22762290
impl<'tcx> Debug for Constant<'tcx> {
22772291
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {

src/librustc/ty/sty.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,11 +1034,12 @@ impl<'a, 'gcx, 'tcx> ParamTy {
10341034
/// is the outer fn.
10351035
///
10361036
/// [dbi]: http://en.wikipedia.org/wiki/De_Bruijn_index
1037-
newtype_index!(DebruijnIndex
1038-
{
1037+
newtype_index! {
1038+
pub struct DebruijnIndex {
10391039
DEBUG_FORMAT = "DebruijnIndex({})",
10401040
const INNERMOST = 0,
1041-
});
1041+
}
1042+
}
10421043

10431044
pub type Region<'tcx> = &'tcx RegionKind;
10441045

@@ -1176,11 +1177,12 @@ pub struct FloatVid {
11761177
pub index: u32,
11771178
}
11781179

1179-
newtype_index!(RegionVid
1180-
{
1180+
newtype_index! {
1181+
pub struct RegionVid {
11811182
pub idx
11821183
DEBUG_FORMAT = custom,
1183-
});
1184+
}
1185+
}
11841186

11851187
impl Atom for RegionVid {
11861188
fn index(self) -> usize {
@@ -1217,7 +1219,9 @@ pub enum InferTy {
12171219
CanonicalTy(CanonicalVar),
12181220
}
12191221

1220-
newtype_index!(CanonicalVar);
1222+
newtype_index! {
1223+
pub struct CanonicalVar { .. }
1224+
}
12211225

12221226
/// A `ProjectionPredicate` for an `ExistentialTraitRef`.
12231227
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]

0 commit comments

Comments
 (0)