about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2011-07-21 15:59:41 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2011-07-21 16:09:55 -0700
commit2261ddc717485dc06e4dbd255947549816f37e4b (patch)
tree174ca719501398663e6b18362ec0421569e433df /src/comp
parent075a094c1fae81498443db137ba8e178e4e757e4 (diff)
downloadrust-2261ddc717485dc06e4dbd255947549816f37e4b.tar.gz
rust-2261ddc717485dc06e4dbd255947549816f37e4b.zip
Move ast_constr_to_constr from typeck to ty
so that it can be used in places that import ty.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/ty.rs17
-rw-r--r--src/comp/middle/typeck.rs29
2 files changed, 24 insertions, 22 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 197cd1bf9c3..1228892077f 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -30,6 +30,7 @@ export any_item_native;
 export any_item_rust;
 export arg;
 export args_eq;
+export ast_constr_to_constr;
 export bind_params_in_type;
 export block_ty;
 export constr;
@@ -3120,6 +3121,22 @@ fn is_binopable(&ctxt cx, t ty, ast::binop op) -> bool {
     ret tbl.(tycat(cx, ty)).(opcat(op));
 }
 
+fn ast_constr_to_constr[T](ty::ctxt tcx, &@ast::constr_general[T] c)
+    -> @ty::constr_general[T] {
+    alt (tcx.def_map.find(c.node.id)) {
+        case (some(ast::def_fn(?pred_id, ast::pure_fn))) {
+            ret @respan(c.span, rec(path=c.node.path, args=c.node.args,
+                                    id=pred_id));
+        }
+        case (_) {
+            tcx.sess.span_fatal(c.span, "Predicate "
+                      + path_to_str(c.node.path)
+                      + " is unbound or bound to a non-function or an \
+                        impure function");
+        }
+    }
+}
+
 // Local Variables:
 // mode: rust
 // fill-column: 78;
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 677262311de..4a0bcf5e61e 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -347,7 +347,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
 
             auto out_constrs = ~[];
             for (@ast::constr constr in constrs) {
-                out_constrs += ~[ast_constr_to_constr(tcx, constr)];
+                out_constrs += ~[ty::ast_constr_to_constr(tcx, constr)];
             }
             typ = ty::mk_fn(tcx, proto, i, out_ty, cf, out_constrs);
         }
@@ -383,7 +383,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
 
                 auto out_constrs = ~[];
                 for (@ast::constr constr in m.node.constrs) {
-                    out_constrs += ~[ast_constr_to_constr(tcx, constr)];
+                    out_constrs += ~[ty::ast_constr_to_constr(tcx, constr)];
                 }
                 let ty::method new_m =
                     rec(proto=m.node.proto,
@@ -399,7 +399,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
         case (ast::ty_constr(?t, ?cs)) {
             auto out_cs = ~[];
             for (@ast::ty_constr constr in cs) {
-                out_cs += ~[ast_constr_to_constr(tcx, constr)];
+                out_cs += ~[ty::ast_constr_to_constr(tcx, constr)];
             }
             typ = ty::mk_constr(tcx, ast_ty_to_ty(tcx, getter, t), out_cs);
         }
@@ -509,7 +509,7 @@ mod collect {
 
         auto out_constrs = ~[];
         for (@ast::constr constr in decl.constraints) {
-            out_constrs += ~[ast_constr_to_constr(cx.tcx, constr)];
+            out_constrs += ~[ty::ast_constr_to_constr(cx.tcx, constr)];
         }
         auto t_fn =
             ty::mk_fn(cx.tcx, proto, input_tys, output_ty, decl.cf,
@@ -589,7 +589,7 @@ mod collect {
 
         auto out_constrs = ~[];
         for (@ast::constr constr in m.node.meth.decl.constraints) {
-            out_constrs += ~[ast_constr_to_constr(cx.tcx, constr)];
+            out_constrs += ~[ty::ast_constr_to_constr(cx.tcx, constr)];
         }
         ret rec(proto=m.node.meth.proto, ident=m.node.ident,
                 inputs=inputs, output=output, cf=m.node.meth.decl.cf,
@@ -2422,7 +2422,8 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
 
                 auto out_constrs = ~[];
                 for (@ast::constr constr in m.node.meth.decl.constraints) {
-                    out_constrs += ~[ast_constr_to_constr(ccx.tcx, constr)];
+                    out_constrs +=
+                      ~[ty::ast_constr_to_constr(ccx.tcx, constr)];
                 }
 
                 ret rec(proto=m.node.meth.proto, ident=m.node.ident,
@@ -2535,22 +2536,6 @@ fn get_obj_info(&@crate_ctxt ccx) -> option::t[obj_info] {
     ret ivec::last[obj_info](ccx.obj_infos);
 }
 
-fn ast_constr_to_constr[T](ty::ctxt tcx, &@ast::constr_general[T] c)
-    -> @ty::constr_general[T] {
-    alt (tcx.def_map.find(c.node.id)) {
-        case (some(ast::def_fn(?pred_id, ast::pure_fn))) {
-            ret @respan(c.span, rec(path=c.node.path, args=c.node.args,
-                                    id=pred_id));
-        }
-        case (_) {
-            tcx.sess.span_fatal(c.span, "Predicate "
-                      + path_to_str(c.node.path)
-                      + " is unbound or bound to a non-function or an \
-                        impure function");
-        }
-    }
-}
-
 fn check_decl_initializer(&@fn_ctxt fcx, ast::node_id nid,
                           &ast::initializer init) {
     check_expr(fcx, init.expr);