From e4a678ddab7727a8336fc51a6cf8ea2a2952f27c Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 2 Feb 2015 13:26:54 +0100 Subject: [PATCH] Ported regions-mock-tcx to use TypedArena rather than Arena since it holds cyclic structure (which the Arena API updated for dropck cannot handle). --- src/test/run-pass/regions-mock-tcx.rs | 19 +++++++++++-------- 1 file 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>; +type AstArena<'ast> = TypedArena>; + struct TypeContext<'tcx, 'ast> { - ty_arena: &'tcx Arena, + ty_arena: &'tcx TyArena<'tcx>, types: Vec> , type_table: HashMap>, - 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);