From 67aa39e1ef4358c309f4b07f1d587a0dad6dddf8 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Sun, 12 Sep 2010 01:05:56 -0700 Subject: Fix a leak when box types are used via type descriptors. --- src/Makefile | 1 + src/boot/me/trans.ml | 4 ++-- src/test/run-pass/leak-box-as-tydesc.rs | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/leak-box-as-tydesc.rs (limited to 'src') diff --git a/src/Makefile b/src/Makefile index a524739a..56fe9b98 100644 --- a/src/Makefile +++ b/src/Makefile @@ -488,6 +488,7 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \ lazy-and-or.rs \ lazy-init.rs \ lazychan.rs \ + leak-box-as-tydesc.rs \ lib-deque.rs \ lib-int.rs \ lib-io.rs \ diff --git a/src/boot/me/trans.ml b/src/boot/me/trans.ml index 693404ed..ad0d6445 100644 --- a/src/boot/me/trans.ml +++ b/src/boot/me/trans.ml @@ -2562,8 +2562,8 @@ let trans_visitor and get_tydesc (idopt:node_id option) (ty:Ast.ty) : Il.cell = log cx "getting tydesc for %a" Ast.sprintf_ty ty; - let (ty, mut) = simplified_ty_innermost_was_mutable ty in - match ty with + let (ty', mut) = simplified_ty_innermost_was_mutable ty in + match ty' with Ast.TY_param (idx, _) -> (get_ty_param_in_current_frame idx) | t when has_parametric_types t -> diff --git a/src/test/run-pass/leak-box-as-tydesc.rs b/src/test/run-pass/leak-box-as-tydesc.rs new file mode 100644 index 00000000..7da40cfe --- /dev/null +++ b/src/test/run-pass/leak-box-as-tydesc.rs @@ -0,0 +1,7 @@ +fn leaky[T](T t) { +} + +fn main() { + auto x = @10; + leaky[@int](x); +} \ No newline at end of file -- cgit v1.2.3