Skip to content

Commit 5aee959

Browse files
committed
make field always private, add From impls
1 parent c46f185 commit 5aee959

File tree

30 files changed

+64
-126
lines changed

30 files changed

+64
-126
lines changed

src/librustc/hir/def_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl CrateNum {
5353
}
5454

5555
pub fn as_u32(&self) -> u32 {
56-
self.0
56+
u32::from(*self)
5757
}
5858

5959
pub fn as_def_id(&self) -> DefId { DefId { krate: *self, index: CRATE_DEF_INDEX } }

src/librustc/ich/impls_mir.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for mir::Local {
102102
fn hash_stable<W: StableHasherResult>(&self,
103103
hcx: &mut StableHashingContext<'a>,
104104
hasher: &mut StableHasher<W>) {
105-
use rustc_data_structures::indexed_vec::Idx;
106105
self.index().hash_stable(hcx, hasher);
107106
}
108107
}
@@ -112,7 +111,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for mir::BasicBlock {
112111
fn hash_stable<W: StableHasherResult>(&self,
113112
hcx: &mut StableHashingContext<'a>,
114113
hasher: &mut StableHasher<W>) {
115-
use rustc_data_structures::indexed_vec::Idx;
116114
self.index().hash_stable(hcx, hasher);
117115
}
118116
}
@@ -122,7 +120,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for mir::Field {
122120
fn hash_stable<W: StableHasherResult>(&self,
123121
hcx: &mut StableHashingContext<'a>,
124122
hasher: &mut StableHasher<W>) {
125-
use rustc_data_structures::indexed_vec::Idx;
126123
self.index().hash_stable(hcx, hasher);
127124
}
128125
}
@@ -133,7 +130,6 @@ for mir::SourceScope {
133130
fn hash_stable<W: StableHasherResult>(&self,
134131
hcx: &mut StableHashingContext<'a>,
135132
hasher: &mut StableHasher<W>) {
136-
use rustc_data_structures::indexed_vec::Idx;
137133
self.index().hash_stable(hcx, hasher);
138134
}
139135
}
@@ -143,7 +139,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for mir::Promoted {
143139
fn hash_stable<W: StableHasherResult>(&self,
144140
hcx: &mut StableHashingContext<'a>,
145141
hasher: &mut StableHasher<W>) {
146-
use rustc_data_structures::indexed_vec::Idx;
147142
self.index().hash_stable(hcx, hasher);
148143
}
149144
}

src/librustc/ich/impls_ty.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::RegionVid {
143143
fn hash_stable<W: StableHasherResult>(&self,
144144
hcx: &mut StableHashingContext<'a>,
145145
hasher: &mut StableHasher<W>) {
146-
use rustc_data_structures::indexed_vec::Idx;
147146
self.index().hash_stable(hcx, hasher);
148147
}
149148
}
@@ -153,7 +152,6 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::CanonicalVar {
153152
fn hash_stable<W: StableHasherResult>(&self,
154153
hcx: &mut StableHashingContext<'gcx>,
155154
hasher: &mut StableHasher<W>) {
156-
use rustc_data_structures::indexed_vec::Idx;
157155
self.index().hash_stable(hcx, hasher);
158156
}
159157
}
@@ -774,7 +772,6 @@ impl_stable_hash_for!(enum ty::cast::CastKind {
774772
FnPtrAddrCast
775773
});
776774

777-
impl_stable_hash_for!(tuple_struct ::middle::region::FirstStatementIndex { idx });
778775
impl_stable_hash_for!(struct ::middle::region::Scope { id, code });
779776

780777
impl<'a> ToStableHashKey<StableHashingContext<'a>> for region::Scope {

src/librustc/infer/error_reporting/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ use syntax::ast::DUMMY_NODE_ID;
7373
use syntax_pos::{Pos, Span};
7474
use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
7575

76-
use rustc_data_structures::indexed_vec::Idx;
77-
7876
mod note;
7977

8078
mod need_type_info;

src/librustc/infer/region_constraints/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use self::CombineMapType::*;
1616
use super::{MiscVariable, RegionVariableOrigin, SubregionOrigin};
1717
use super::unify_key;
1818

19-
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
19+
use rustc_data_structures::indexed_vec::IndexVec;
2020
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
2121
use rustc_data_structures::unify as ut;
2222
use ty::{self, Ty, TyCtxt};

src/librustc/infer/unify_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ impl UnifyValue for RegionVidKey {
4949

5050
impl UnifyKey for ty::RegionVid {
5151
type Value = RegionVidKey;
52-
fn index(&self) -> u32 { self.0 }
53-
fn from_index(i: u32) -> ty::RegionVid { ty::RegionVid(i) }
52+
fn index(&self) -> u32 { u32::from(*self) }
53+
fn from_index(i: u32) -> ty::RegionVid { ty::RegionVid::from(i) }
5454
fn tag() -> &'static str { "RegionVid" }
5555
}
5656

src/librustc/middle/region.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,12 @@ pub struct BlockRemainder {
161161

162162
newtype_index! {
163163
pub struct FirstStatementIndex {
164-
pub idx
165164
MAX = SCOPE_DATA_REMAINDER_MAX
166165
}
167166
}
168167

168+
impl_stable_hash_for!(tuple_struct ::middle::region::FirstStatementIndex { idx });
169+
169170
impl From<ScopeData> for Scope {
170171
#[inline]
171172
fn from(scope_data: ScopeData) -> Self {

src/librustc/ty/sty.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,6 @@ pub struct FloatVid {
11791179

11801180
newtype_index! {
11811181
pub struct RegionVid {
1182-
pub idx
11831182
DEBUG_FORMAT = custom,
11841183
}
11851184
}
@@ -1190,18 +1189,6 @@ impl Atom for RegionVid {
11901189
}
11911190
}
11921191

1193-
impl From<usize> for RegionVid {
1194-
fn from(i: usize) -> RegionVid {
1195-
RegionVid::new(i)
1196-
}
1197-
}
1198-
1199-
impl From<RegionVid> for usize {
1200-
fn from(vid: RegionVid) -> usize {
1201-
Idx::index(vid)
1202-
}
1203-
}
1204-
12051192
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
12061193
pub enum InferTy {
12071194
TyVar(TyVid),

src/librustc/util/ppaux.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use std::cell::Cell;
2626
use std::fmt;
2727
use std::usize;
2828

29-
use rustc_data_structures::indexed_vec::Idx;
3029
use rustc_target::spec::abi::Abi;
3130
use syntax::ast::CRATE_NODE_ID;
3231
use syntax::symbol::{Symbol, InternedString};

src/librustc_codegen_llvm/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use syntax::symbol::keywords;
3232
use std::iter;
3333

3434
use rustc_data_structures::bitvec::BitArray;
35-
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
35+
use rustc_data_structures::indexed_vec::IndexVec;
3636

3737
pub use self::constant::codegen_static_initializer;
3838

0 commit comments

Comments
 (0)