Skip to content

Commit 70d0123

Browse files
committed
Address nit: Remove ScopedDataVec newtype
1 parent b3d2059 commit 70d0123

File tree

5 files changed

+12
-24
lines changed

5 files changed

+12
-24
lines changed

src/librustc/mir/repr.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct Mir<'tcx> {
3434

3535
/// List of lexical scopes; these are referenced by statements and
3636
/// used (eventually) for debuginfo. Indexed by a `ScopeId`.
37-
pub scopes: ScopeDataVec,
37+
pub scopes: Vec<ScopeData>,
3838

3939
/// Return type of the function.
4040
pub return_ty: FnOutput<'tcx>,
@@ -651,30 +651,19 @@ impl<'tcx> Debug for Lvalue<'tcx> {
651651
///////////////////////////////////////////////////////////////////////////
652652
// Scopes
653653

654-
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
655-
pub struct ScopeDataVec {
656-
pub vec: Vec<ScopeData>
657-
}
658-
659-
impl ScopeDataVec {
660-
pub fn new() -> Self {
661-
ScopeDataVec { vec: Vec::new() }
662-
}
663-
}
664-
665-
impl Index<ScopeId> for ScopeDataVec {
654+
impl Index<ScopeId> for Vec<ScopeData> {
666655
type Output = ScopeData;
667656

668657
#[inline]
669658
fn index(&self, index: ScopeId) -> &ScopeData {
670-
&self.vec[index.index()]
659+
&self[index.index()]
671660
}
672661
}
673662

674-
impl IndexMut<ScopeId> for ScopeDataVec {
663+
impl IndexMut<ScopeId> for Vec<ScopeData> {
675664
#[inline]
676665
fn index_mut(&mut self, index: ScopeId) -> &mut ScopeData {
677-
&mut self.vec[index.index()]
666+
&mut self[index.index()]
678667
}
679668
}
680669

src/librustc_mir/build/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct Builder<'a, 'tcx: 'a> {
4141

4242
// the vector of all scopes that we have created thus far;
4343
// we track this for debuginfo later
44-
scope_data_vec: ScopeDataVec,
44+
scope_datas: Vec<ScopeData>,
4545

4646
var_decls: Vec<VarDecl<'tcx>>,
4747
var_indices: FnvHashMap<ast::NodeId, u32>,
@@ -151,7 +151,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
151151
cfg: cfg,
152152
fn_span: span,
153153
scopes: vec![],
154-
scope_data_vec: ScopeDataVec::new(),
154+
scope_datas: vec![],
155155
scope_auxiliary: vec![],
156156
loop_scopes: vec![],
157157
temp_decls: vec![],
@@ -191,7 +191,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
191191
MirAndScopeAuxiliary {
192192
mir: Mir {
193193
basic_blocks: builder.cfg.basic_blocks,
194-
scopes: builder.scope_data_vec,
194+
scopes: builder.scope_datas,
195195
var_decls: builder.var_decls,
196196
arg_decls: arg_decls,
197197
temp_decls: builder.temp_decls,

src/librustc_mir/build/scope.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ use rustc::middle::const_eval::ConstVal;
9898
use rustc_const_eval::ConstInt;
9999

100100
pub struct Scope<'tcx> {
101-
/// the scope-id within the scope_data_vec
101+
/// the scope-id within the scope_datas
102102
id: ScopeId,
103103
extent: CodeExtent,
104104
drops: Vec<DropData<'tcx>>,
@@ -246,8 +246,8 @@ impl<'a,'tcx> Builder<'a,'tcx> {
246246
pub fn push_scope(&mut self, extent: CodeExtent, entry: BasicBlock) -> ScopeId {
247247
debug!("push_scope({:?})", extent);
248248
let parent_id = self.scopes.last().map(|s| s.id);
249-
let id = ScopeId::new(self.scope_data_vec.vec.len());
250-
self.scope_data_vec.vec.push(ScopeData {
249+
let id = ScopeId::new(self.scope_datas.len());
250+
self.scope_datas.push(ScopeData {
251251
parent_scope: parent_id,
252252
});
253253
self.scopes.push(Scope {

src/librustc_mir/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub fn write_mir_fn<'tcx>(tcx: &TyCtxt<'tcx>,
118118

119119
// construct a scope tree and write it out
120120
let mut scope_tree: FnvHashMap<Option<ScopeId>, Vec<ScopeId>> = FnvHashMap();
121-
for (index, scope_data) in mir.scopes.vec.iter().enumerate() {
121+
for (index, scope_data) in mir.scopes.iter().enumerate() {
122122
scope_tree.entry(scope_data.parent_scope)
123123
.or_insert(vec![])
124124
.push(ScopeId::new(index));

src/librustc_trans/trans/mir/block.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,4 +569,3 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
569569
self.blocks[bb.index()].llbb
570570
}
571571
}
572-

0 commit comments

Comments
 (0)