]> git.lizzy.rs Git - rust.git/commitdiff
Mark some fns as pure so type_is_unique_box doesn't need to be unchecked
authorJesse Ruderman <jruderman@gmail.com>
Sat, 24 Sep 2011 22:36:09 +0000 (15:36 -0700)
committerJesse Ruderman <jruderman@gmail.com>
Sat, 24 Sep 2011 22:36:09 +0000 (15:36 -0700)
src/comp/middle/trans_uniq.rs
src/comp/middle/ty.rs
src/comp/syntax/util/interner.rs

index faa7c812054b3571bef7242cadbc535c862b33ee..0986a0c12658564d55ccd2eec730a527ee4ad1c1 100644 (file)
@@ -20,9 +20,7 @@
 autoderef, duplicate;
 
 pure fn type_is_unique_box(bcx: @block_ctxt, ty: ty::t) -> bool {
-    unchecked {
-        ty::type_is_unique_box(bcx_tcx(bcx), ty)
-    }
+    ty::type_is_unique_box(bcx_tcx(bcx), ty)
 }
 
 fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,
index a013359f3b0d0529cabd24ce36f53ac815a55b76..a91f7946c7d33b41028c226ba8a63647e4aa7c31 100644 (file)
@@ -592,7 +592,7 @@ fn mk_iter_body_fn(cx: ctxt, output: t) -> t {
 }
 
 // Returns the one-level-deep type structure of the given type.
-fn struct(cx: ctxt, typ: t) -> sty { ret interner::get(*cx.ts, typ).struct; }
+pure fn struct(cx: ctxt, typ: t) -> sty { interner::get(*cx.ts, typ).struct }
 
 
 // Returns the canonical name of the given type.
@@ -862,28 +862,28 @@ fn get_element_type(cx: ctxt, ty: t, i: uint) -> t {
     // tag.
 }
 
-fn type_is_box(cx: ctxt, ty: t) -> bool {
+pure fn type_is_box(cx: ctxt, ty: t) -> bool {
     alt struct(cx, ty) {
       ty_box(_) { ret true; }
       _ { ret false; }
     }
 }
 
-fn type_is_boxed(cx: ctxt, ty: t) -> bool {
+pure fn type_is_boxed(cx: ctxt, ty: t) -> bool {
     alt struct(cx, ty) {
       ty_box(_) { ret true; }
       _ { ret false; }
     }
 }
 
-fn type_is_unique_box(cx: ctxt, ty: t) -> bool {
+pure fn type_is_unique_box(cx: ctxt, ty: t) -> bool {
     alt struct(cx, ty) {
       ty_uniq(_) { ret true; }
       _ { ret false; }
     }
 }
 
-fn type_is_vec(cx: ctxt, ty: t) -> bool {
+pure fn type_is_vec(cx: ctxt, ty: t) -> bool {
     ret alt struct(cx, ty) {
           ty_vec(_) { true }
           ty_str. { true }
@@ -891,7 +891,7 @@ fn type_is_vec(cx: ctxt, ty: t) -> bool {
         };
 }
 
-fn type_is_unique(cx: ctxt, ty: t) -> bool {
+pure fn type_is_unique(cx: ctxt, ty: t) -> bool {
     alt struct(cx, ty) {
       ty_uniq(_) { ret true; }
       ty_vec(_) { true }
@@ -900,7 +900,7 @@ fn type_is_unique(cx: ctxt, ty: t) -> bool {
     }
 }
 
-fn type_is_scalar(cx: ctxt, ty: t) -> bool {
+pure fn type_is_scalar(cx: ctxt, ty: t) -> bool {
     alt struct(cx, ty) {
       ty_nil. { ret true; }
       ty_bool. { ret true; }
index ce1124d68aa95e47220d68248316e7ded40a994c..164b38fe87052a8ec6d9a2d146ead7b06a9d0426 100644 (file)
@@ -28,7 +28,7 @@ fn intern<@T>(itr: interner<T>, val: T) -> uint {
     }
 }
 
-fn get<@T>(itr: interner<T>, idx: uint) -> T { ret itr.vect[idx]; }
+pure fn get<@T>(itr: interner<T>, idx: uint) -> T { ret itr.vect[idx]; }
 
-fn len<T>(itr: interner<T>) -> uint { ret vec::len(itr.vect); }
+pure fn len<T>(itr: interner<T>) -> uint { ret vec::len(itr.vect); }