diff options
| author | Jesse Ruderman <jruderman@gmail.com> | 2011-09-24 15:36:09 -0700 |
|---|---|---|
| committer | Jesse Ruderman <jruderman@gmail.com> | 2011-09-24 15:36:09 -0700 |
| commit | 064f52fa96a51e3871eeaa453fa87221245e6421 (patch) | |
| tree | 7c1dd55d1adb10c663d8d832832af81eed750b81 /src/comp | |
| parent | 48c2c9b3a7da174d58219f2c2e0cc43926280f35 (diff) | |
Mark some fns as pure so type_is_unique_box doesn't need to be unchecked
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/trans_uniq.rs | 4 | ||||
| -rw-r--r-- | src/comp/middle/ty.rs | 14 | ||||
| -rw-r--r-- | src/comp/syntax/util/interner.rs | 4 |
3 files changed, 10 insertions, 12 deletions
diff --git a/src/comp/middle/trans_uniq.rs b/src/comp/middle/trans_uniq.rs index faa7c812054..0986a0c1265 100644 --- a/src/comp/middle/trans_uniq.rs +++ b/src/comp/middle/trans_uniq.rs @@ -20,9 +20,7 @@ export trans_uniq, make_free_glue, type_is_unique_box, copy_val, 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, diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index a013359f3b0..a91f7946c7d 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -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; } diff --git a/src/comp/syntax/util/interner.rs b/src/comp/syntax/util/interner.rs index ce1124d68aa..164b38fe870 100644 --- a/src/comp/syntax/util/interner.rs +++ b/src/comp/syntax/util/interner.rs @@ -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); } |
