From 860573e3e00b5a807021b8c7a94a9672de4fa687 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 11 Oct 2012 10:31:57 -0700 Subject: [PATCH] Reword para on diverging functions. --- doc/rust.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/rust.md b/doc/rust.md index a3ef24ab8dd..8846ac9f945 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -936,11 +936,13 @@ fn f(i: int) -> int { } ~~~~ -The typechecker would complain that `f` doesn't return a value in the -`else` branch. Adding the `!` annotation on `my_err` would -express that `f` requires no explicit `return`, as if it returns -control to the caller, it returns a value (true because it never returns -control). +This will not compile without the `!` annotation on `my_err`, +since the `else` branch of the conditional in `f` does not return an `int`, +as required by the signature of `f`. +Adding the `!` annotation to `my_err` informs the typechecker that, +should control ever enter `my_err`, no further type judgments about `f` need to hold, +since control will never resume in any context that relies on those judgments. +Thus the return type on `f` only needs to reflect the `if` branch of the conditional. #### Pure functions