about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2013-03-21 11:32:57 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2013-03-21 11:32:57 -0700
commitf36f9fc91ccc86c7004979689da981184559e57a (patch)
treec1bae8cfb2feb8dc4545cd55158e233ba87706f9
parentdb003623134dbabae9a8065398644dc141b19d46 (diff)
downloadrust-f36f9fc91ccc86c7004979689da981184559e57a.tar.gz
rust-f36f9fc91ccc86c7004979689da981184559e57a.zip
rustc: Comments only - explain the invariant about ty_err and ty_bot a little
-rw-r--r--src/librustc/middle/typeck/check/mod.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs
index e74c417b05f..12c88ae7198 100644
--- a/src/librustc/middle/typeck/check/mod.rs
+++ b/src/librustc/middle/typeck/check/mod.rs
@@ -1127,6 +1127,16 @@ pub fn break_here() {
     debug!("break here!");
 }
 
+/// Invariant:
+/// If an expression has any sub-expressions that result in a type error,
+/// inspecting that expression's type with `ty::type_is_error` will return
+/// true. Likewise, if an expression is known to diverge, inspecting its
+/// type with `ty::type_is_bot` will return true (n.b.: since Rust is
+/// strict, _|_ can appear in the type of an expression that does not,
+/// itself, diverge: for example, fn() -> _|_.)
+/// Note that inspecting a type's structure *directly* may expose the fact
+/// that there are actually multiple representations for both `ty_err` and
+/// `ty_bot`, so avoid that when err and bot need to be handled differently.
 pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
                                expr: @ast::expr,
                                expected: Option<ty::t>,