about summary refs log tree commit diff
path: root/src/rustc
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-03-23 22:36:21 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-03-23 22:36:37 -0700
commit6b84cee5d30b0f99a2f932d3905e6b11598f95e3 (patch)
treecbd3d133b63caa5b613a26d227e5b2e8f972b8e9 /src/rustc
parentf5edb5ee1819585416c0c57645b9e3e4c157d407 (diff)
downloadrust-6b84cee5d30b0f99a2f932d3905e6b11598f95e3.tar.gz
rust-6b84cee5d30b0f99a2f932d3905e6b11598f95e3.zip
add a few measly comments, remove some dead code
Diffstat (limited to 'src/rustc')
-rw-r--r--src/rustc/middle/infer.rs33
-rw-r--r--src/rustc/middle/typeck.rs2
2 files changed, 19 insertions, 16 deletions
diff --git a/src/rustc/middle/infer.rs b/src/rustc/middle/infer.rs
index 7524ce0fc61..4af630e7bfd 100644
--- a/src/rustc/middle/infer.rs
+++ b/src/rustc/middle/infer.rs
@@ -85,6 +85,15 @@ impl methods for ures {
     }
 }
 
+// Most of these methods, like tys() and so forth, take two parameters
+// a and b and they are tasked with "ensuring that a is a subtype of
+// b".  They return success or failure.  They make changes in-place to
+// the variable bindings: these changes are recorded in the `bindings`
+// array, which then allows the changes to be rolled back if needed.
+//
+// The merge() and merge_bnds() methods are somewhat different in that
+// they compute a new type range for a variable (generally a subset of
+// the old range).  They therefore return a result.
 impl unify_methods for infer_ctxt {
     fn uok() -> ures {
         #debug["Unification OK"];
@@ -177,18 +186,8 @@ impl unify_methods for infer_ctxt {
         }
     }
 
-    // Take bound a if it is set, else take bound b.
-    fn aelseb(a: bound, b: bound) -> bound {
-        alt (a, b) {
-          (none, none) { none }
-          (some(_), none) { a }
-          (none, some(_)) { b }
-          (some(_), some(_)) { a }
-        }
-    }
-
     // Combines the two bounds.  Returns a bounds r where (r.lb <:
-    // a,b) and (a,b <: r.ub).
+    // a,b) and (a,b <: r.ub) (if such a bounds exists).
     fn merge_bnds(a: bound, b: bound) -> result<bounds, ty::type_err> {
         alt (a, b) {
           (none, none) {
@@ -215,10 +214,14 @@ impl unify_methods for infer_ctxt {
         }
     }
 
-    // Given a variable with bounds `a`, returns a new set of bounds
-    // such that `a` <: `b`.  The new bounds will always be a subset
-    // of the old bounds.  If this cannot be achieved, the result is
-    // failure.
+    // Updates the bounds for the variable `v_id` to be the intersection
+    // of `a` and `b`.  That is, the new bounds for `v_id` will be
+    // a bounds c such that:
+    //    c.ub <: a.ub
+    //    c.ub <: b.ub
+    //    a.lb <: c.lb
+    //    b.lb <: c.lb
+    // If this cannot be achieved, the result is failure.
     fn merge(v_id: uint, a: bounds, b: bounds) -> ures {
         // Think of the two diamonds, we want to find the
         // intersection.  There are basically four possibilities (you
diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs
index 8d56e3101b5..ec9868c688c 100644
--- a/src/rustc/middle/typeck.rs
+++ b/src/rustc/middle/typeck.rs
@@ -1129,7 +1129,7 @@ mod collect {
 // Type unification
 mod unify {
     fn unify_with_region_bindings(fcx: @fn_ctxt,
-                                  rb: @ty::unify::region_bindings,
+                                  _rb: @ty::unify::region_bindings,
                                   expected: ty::t,
                                   actual: ty::t)
             -> result<(), ty::type_err> {