about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEric Holk <eric.holk@gmail.com>2012-05-31 10:51:58 -0700
committerEric Holk <eric.holk@gmail.com>2012-05-31 13:55:54 -0700
commit0470abe1d290ef28fa72693b70f955328656e471 (patch)
treef1c9803901c49433c66e12f7de203d02a987fd43 /src
parent3acc3c4d85e017edde2149eaabd44a78be5f7e17 (diff)
downloadrust-0470abe1d290ef28fa72693b70f955328656e471.tar.gz
rust-0470abe1d290ef28fa72693b70f955328656e471.zip
Allow some resources to be considered const.
Diffstat (limited to 'src')
-rw-r--r--src/rustc/middle/ty.rs5
-rw-r--r--src/test/compile-fail/non-const.rs4
2 files changed, 7 insertions, 2 deletions
diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs
index 878c58f2402..5fced36e408 100644
--- a/src/rustc/middle/ty.rs
+++ b/src/rustc/middle/ty.rs
@@ -1526,7 +1526,10 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
         }
         lowest
       }
-      ty_res(did, inner, tps) { kind_send_only() }
+      ty_res(did, inner, tps) {
+        let inner = subst(cx, tps, inner);
+        (kind_const() & type_kind(cx, inner)) | kind_send_only()
+      }
       ty_param(_, did) {
         // FIXME: type params shouldn't be implicitly copyable (#2449)
         let k = param_bounds_to_kind(cx.ty_param_bounds.get(did.node));
diff --git a/src/test/compile-fail/non-const.rs b/src/test/compile-fail/non-const.rs
index 193fdb4a16b..320bc1d25f8 100644
--- a/src/test/compile-fail/non-const.rs
+++ b/src/test/compile-fail/non-const.rs
@@ -3,6 +3,7 @@
 fn foo<T: const>(_x: T) { }
 
 resource r(_x: int) {}
+resource r2(_x: @mut int) {}
 
 fn main() {
     foo({f: 3});
@@ -13,7 +14,8 @@ fn main() {
     foo(~mut 1); //! ERROR missing `const`
     foo(@1);
     foo(@mut 1); //! ERROR missing `const`
-    foo(r(1)); //! ERROR missing `const`
+    foo(r(1)); // this is okay now.
+    foo(r2(@mut 1)); //! ERROR missing `const`
     foo("123");
     foo({f: {mut f: 1}}); //! ERROR missing `const`
 }