diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-02-02 13:26:54 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-02-06 00:04:32 +0100 |
| commit | e4a678ddab7727a8336fc51a6cf8ea2a2952f27c (patch) | |
| tree | 6f2a4a717bb1b35f585cd6abfed88bd4c3597786 /src | |
| parent | 189930fcae287565dcef856ae8d60a83190a4b92 (diff) | |
| download | rust-e4a678ddab7727a8336fc51a6cf8ea2a2952f27c.tar.gz rust-e4a678ddab7727a8336fc51a6cf8ea2a2952f27c.zip | |
Ported regions-mock-tcx to use TypedArena rather than Arena since it holds
cyclic structure (which the Arena API updated for dropck cannot handle).
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/run-pass/regions-mock-tcx.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/test/run-pass/regions-mock-tcx.rs b/src/test/run-pass/regions-mock-tcx.rs index be7db25201a..bf789d53645 100644 --- a/src/test/run-pass/regions-mock-tcx.rs +++ b/src/test/run-pass/regions-mock-tcx.rs @@ -21,7 +21,7 @@ extern crate libc; use TypeStructure::{TypeInt, TypeFunction}; use AstKind::{ExprInt, ExprVar, ExprLambda}; -use arena::Arena; +use arena::TypedArena; use std::collections::HashMap; use std::mem; @@ -45,17 +45,20 @@ impl<'tcx> PartialEq for TypeStructure<'tcx> { impl<'tcx> Eq for TypeStructure<'tcx> {} +type TyArena<'tcx> = TypedArena<TypeStructure<'tcx>>; +type AstArena<'ast> = TypedArena<AstStructure<'ast>>; + struct TypeContext<'tcx, 'ast> { - ty_arena: &'tcx Arena, + ty_arena: &'tcx TyArena<'tcx>, types: Vec<Type<'tcx>> , type_table: HashMap<NodeId, Type<'tcx>>, - ast_arena: &'ast Arena, + ast_arena: &'ast AstArena<'ast>, ast_counter: uint, } impl<'tcx,'ast> TypeContext<'tcx, 'ast> { - fn new(ty_arena: &'tcx Arena, ast_arena: &'ast Arena) + fn new(ty_arena: &'tcx TyArena<'tcx>, ast_arena: &'ast AstArena<'ast>) -> TypeContext<'tcx, 'ast> { TypeContext { ty_arena: ty_arena, types: Vec::new(), @@ -72,7 +75,7 @@ impl<'tcx,'ast> TypeContext<'tcx, 'ast> { } } - let ty = self.ty_arena.alloc(|| s); + let ty = self.ty_arena.alloc(s); self.types.push(ty); ty } @@ -85,7 +88,7 @@ impl<'tcx,'ast> TypeContext<'tcx, 'ast> { fn ast(&mut self, a: AstKind<'ast>) -> Ast<'ast> { let id = self.ast_counter; self.ast_counter += 1; - self.ast_arena.alloc(|| AstStructure { id: NodeId {id:id}, kind: a }) + self.ast_arena.alloc(AstStructure { id: NodeId {id:id}, kind: a }) } } @@ -127,8 +130,8 @@ fn compute_types<'tcx,'ast>(tcx: &mut TypeContext<'tcx,'ast>, } pub fn main() { - let ty_arena = arena::Arena::new(); - let ast_arena = arena::Arena::new(); + let ty_arena = TypedArena::new(); + let ast_arena = TypedArena::new(); let mut tcx = TypeContext::new(&ty_arena, &ast_arena); let ast = tcx.ast(ExprInt); let ty = compute_types(&mut tcx, ast); |
