Skip to content

Commit 064f52f

Browse files
committed
Mark some fns as pure so type_is_unique_box doesn't need to be unchecked
1 parent 48c2c9b commit 064f52f

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

src/comp/middle/trans_uniq.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ export trans_uniq, make_free_glue, type_is_unique_box, copy_val,
2020
autoderef, duplicate;
2121

2222
pure fn type_is_unique_box(bcx: @block_ctxt, ty: ty::t) -> bool {
23-
unchecked {
24-
ty::type_is_unique_box(bcx_tcx(bcx), ty)
25-
}
23+
ty::type_is_unique_box(bcx_tcx(bcx), ty)
2624
}
2725

2826
fn trans_uniq(cx: @block_ctxt, contents: @ast::expr,

src/comp/middle/ty.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ fn mk_iter_body_fn(cx: ctxt, output: t) -> t {
592592
}
593593

594594
// Returns the one-level-deep type structure of the given type.
595-
fn struct(cx: ctxt, typ: t) -> sty { ret interner::get(*cx.ts, typ).struct; }
595+
pure fn struct(cx: ctxt, typ: t) -> sty { interner::get(*cx.ts, typ).struct }
596596

597597

598598
// Returns the canonical name of the given type.
@@ -862,36 +862,36 @@ fn get_element_type(cx: ctxt, ty: t, i: uint) -> t {
862862
// tag.
863863
}
864864

865-
fn type_is_box(cx: ctxt, ty: t) -> bool {
865+
pure fn type_is_box(cx: ctxt, ty: t) -> bool {
866866
alt struct(cx, ty) {
867867
ty_box(_) { ret true; }
868868
_ { ret false; }
869869
}
870870
}
871871

872-
fn type_is_boxed(cx: ctxt, ty: t) -> bool {
872+
pure fn type_is_boxed(cx: ctxt, ty: t) -> bool {
873873
alt struct(cx, ty) {
874874
ty_box(_) { ret true; }
875875
_ { ret false; }
876876
}
877877
}
878878

879-
fn type_is_unique_box(cx: ctxt, ty: t) -> bool {
879+
pure fn type_is_unique_box(cx: ctxt, ty: t) -> bool {
880880
alt struct(cx, ty) {
881881
ty_uniq(_) { ret true; }
882882
_ { ret false; }
883883
}
884884
}
885885

886-
fn type_is_vec(cx: ctxt, ty: t) -> bool {
886+
pure fn type_is_vec(cx: ctxt, ty: t) -> bool {
887887
ret alt struct(cx, ty) {
888888
ty_vec(_) { true }
889889
ty_str. { true }
890890
_ { false }
891891
};
892892
}
893893

894-
fn type_is_unique(cx: ctxt, ty: t) -> bool {
894+
pure fn type_is_unique(cx: ctxt, ty: t) -> bool {
895895
alt struct(cx, ty) {
896896
ty_uniq(_) { ret true; }
897897
ty_vec(_) { true }
@@ -900,7 +900,7 @@ fn type_is_unique(cx: ctxt, ty: t) -> bool {
900900
}
901901
}
902902

903-
fn type_is_scalar(cx: ctxt, ty: t) -> bool {
903+
pure fn type_is_scalar(cx: ctxt, ty: t) -> bool {
904904
alt struct(cx, ty) {
905905
ty_nil. { ret true; }
906906
ty_bool. { ret true; }

src/comp/syntax/util/interner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn intern<@T>(itr: interner<T>, val: T) -> uint {
2828
}
2929
}
3030

31-
fn get<@T>(itr: interner<T>, idx: uint) -> T { ret itr.vect[idx]; }
31+
pure fn get<@T>(itr: interner<T>, idx: uint) -> T { ret itr.vect[idx]; }
3232

33-
fn len<T>(itr: interner<T>) -> uint { ret vec::len(itr.vect); }
33+
pure fn len<T>(itr: interner<T>) -> uint { ret vec::len(itr.vect); }
3434

0 commit comments

Comments
 (0)