]> git.lizzy.rs Git - rust.git/commitdiff
Address nit: Remove `ScopedDataVec` newtype
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 23 Mar 2016 08:59:44 +0000 (04:59 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 23 Mar 2016 20:42:54 +0000 (16:42 -0400)
src/librustc/mir/repr.rs
src/librustc_mir/build/mod.rs
src/librustc_mir/build/scope.rs
src/librustc_mir/pretty.rs
src/librustc_trans/trans/mir/block.rs

index 2931af2936f5187989704e07da3b275bf5ba08c3..4022d762aec34de3fc70e5d25ce3ada24d053c38 100644 (file)
@@ -34,7 +34,7 @@ pub struct Mir<'tcx> {
 
     /// List of lexical scopes; these are referenced by statements and
     /// used (eventually) for debuginfo. Indexed by a `ScopeId`.
-    pub scopes: ScopeDataVec,
+    pub scopes: Vec<ScopeData>,
 
     /// Return type of the function.
     pub return_ty: FnOutput<'tcx>,
@@ -651,30 +651,19 @@ fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
 ///////////////////////////////////////////////////////////////////////////
 // Scopes
 
-#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
-pub struct ScopeDataVec {
-    pub vec: Vec<ScopeData>
-}
-
-impl ScopeDataVec {
-    pub fn new() -> Self {
-        ScopeDataVec { vec: Vec::new() }
-    }
-}
-
-impl Index<ScopeId> for ScopeDataVec {
+impl Index<ScopeId> for Vec<ScopeData> {
     type Output = ScopeData;
 
     #[inline]
     fn index(&self, index: ScopeId) -> &ScopeData {
-        &self.vec[index.index()]
+        &self[index.index()]
     }
 }
 
-impl IndexMut<ScopeId> for ScopeDataVec {
+impl IndexMut<ScopeId> for Vec<ScopeData> {
     #[inline]
     fn index_mut(&mut self, index: ScopeId) -> &mut ScopeData {
-        &mut self.vec[index.index()]
+        &mut self[index.index()]
     }
 }
 
index 58b2b92b7960a839fd36903c5056e77b932bd3bd..056d74ffe1f136fec5c8156ecffaf1488e536324 100644 (file)
@@ -41,7 +41,7 @@ pub struct Builder<'a, 'tcx: 'a> {
 
     // the vector of all scopes that we have created thus far;
     // we track this for debuginfo later
-    scope_data_vec: ScopeDataVec,
+    scope_datas: Vec<ScopeData>,
 
     var_decls: Vec<VarDecl<'tcx>>,
     var_indices: FnvHashMap<ast::NodeId, u32>,
@@ -151,7 +151,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
         cfg: cfg,
         fn_span: span,
         scopes: vec![],
-        scope_data_vec: ScopeDataVec::new(),
+        scope_datas: vec![],
         scope_auxiliary: vec![],
         loop_scopes: vec![],
         temp_decls: vec![],
@@ -191,7 +191,7 @@ pub fn construct<'a,'tcx>(hir: Cx<'a,'tcx>,
     MirAndScopeAuxiliary {
         mir: Mir {
             basic_blocks: builder.cfg.basic_blocks,
-            scopes: builder.scope_data_vec,
+            scopes: builder.scope_datas,
             var_decls: builder.var_decls,
             arg_decls: arg_decls,
             temp_decls: builder.temp_decls,
index baacc8ca9a9a07e6ff32ccac9287d4106e9276ca..54830e6c2257d3cb573f624993f08191546b94e0 100644 (file)
@@ -98,7 +98,7 @@
 use rustc_const_eval::ConstInt;
 
 pub struct Scope<'tcx> {
-    /// the scope-id within the scope_data_vec
+    /// the scope-id within the scope_datas
     id: ScopeId,
     extent: CodeExtent,
     drops: Vec<DropData<'tcx>>,
@@ -246,8 +246,8 @@ pub fn in_scope<F, R>(&mut self, extent: CodeExtent, mut block: BasicBlock, f: F
     pub fn push_scope(&mut self, extent: CodeExtent, entry: BasicBlock) -> ScopeId {
         debug!("push_scope({:?})", extent);
         let parent_id = self.scopes.last().map(|s| s.id);
-        let id = ScopeId::new(self.scope_data_vec.vec.len());
-        self.scope_data_vec.vec.push(ScopeData {
+        let id = ScopeId::new(self.scope_datas.len());
+        self.scope_datas.push(ScopeData {
             parent_scope: parent_id,
         });
         self.scopes.push(Scope {
index d8cfd8a88cf9b43bb8feb4f97945e5baf62e9d48..05fe255c64144b372fbe8f84058f3e15ccf7bd67 100644 (file)
@@ -118,7 +118,7 @@ pub fn write_mir_fn<'tcx>(tcx: &TyCtxt<'tcx>,
 
     // construct a scope tree and write it out
     let mut scope_tree: FnvHashMap<Option<ScopeId>, Vec<ScopeId>> = FnvHashMap();
-    for (index, scope_data) in mir.scopes.vec.iter().enumerate() {
+    for (index, scope_data) in mir.scopes.iter().enumerate() {
         scope_tree.entry(scope_data.parent_scope)
                   .or_insert(vec![])
                   .push(ScopeId::new(index));
index 0fb4975453a230b43790cda37be3b7d7e6a5f800..7abaeb44c1c29bfa4e814667069b3a65be952c86 100644 (file)
@@ -569,4 +569,3 @@ pub fn llblock(&self, bb: mir::BasicBlock) -> BasicBlockRef {
         self.blocks[bb.index()].llbb
     }
 }
-