Address nit: Remove `ScopedDataVec` newtype

This commit is contained in:
Niko Matsakis 2016-03-23 04:59:44 -04:00
parent b3d2059b08
commit 70d0123082
5 changed files with 12 additions and 24 deletions

View 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 @@ impl<'tcx> Debug for Lvalue<'tcx> {
///////////////////////////////////////////////////////////////////////////
// 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()]
}
}

View 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,

View File

@ -98,7 +98,7 @@ use rustc::middle::const_eval::ConstVal;
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 @@ impl<'a,'tcx> Builder<'a,'tcx> {
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 {

View 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));

View File

@ -569,4 +569,3 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
self.blocks[bb.index()].llbb
}
}