/// 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>,
///////////////////////////////////////////////////////////////////////////
// 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()]
}
}
// 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>,
cfg: cfg,
fn_span: span,
scopes: vec![],
- scope_data_vec: ScopeDataVec::new(),
+ scope_datas: vec![],
scope_auxiliary: vec![],
loop_scopes: vec![],
temp_decls: vec![],
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,
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>>,
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 {
// 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));
self.blocks[bb.index()].llbb
}
}
-