Skip to content

Commit f36f9fc

Browse files
committed
rustc: Comments only - explain the invariant about ty_err and ty_bot a little
1 parent db00362 commit f36f9fc

File tree

1 file changed

+10
-0
lines changed
  • src/librustc/middle/typeck/check

1 file changed

+10
-0
lines changed

src/librustc/middle/typeck/check/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,16 @@ pub fn break_here() {
11271127
debug!("break here!");
11281128
}
11291129

1130+
/// Invariant:
1131+
/// If an expression has any sub-expressions that result in a type error,
1132+
/// inspecting that expression's type with `ty::type_is_error` will return
1133+
/// true. Likewise, if an expression is known to diverge, inspecting its
1134+
/// type with `ty::type_is_bot` will return true (n.b.: since Rust is
1135+
/// strict, _|_ can appear in the type of an expression that does not,
1136+
/// itself, diverge: for example, fn() -> _|_.)
1137+
/// Note that inspecting a type's structure *directly* may expose the fact
1138+
/// that there are actually multiple representations for both `ty_err` and
1139+
/// `ty_bot`, so avoid that when err and bot need to be handled differently.
11301140
pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
11311141
expr: @ast::expr,
11321142
expected: Option<ty::t>,

0 commit comments

Comments
 (0)