about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNick Hamann <nick@wabbo.org>2015-05-11 23:36:54 -0500
committerNick Hamann <nick@wabbo.org>2015-05-13 19:55:34 -0500
commita4444aa78079665658b0d656c6d243d88a9ac5cc (patch)
tree98886f8ed6501d5fb3b561674d1b85d17cde95aa
parent5a341ecfc985c190d8c359a8c995a094ef22ab9e (diff)
downloadrust-a4444aa78079665658b0d656c6d243d88a9ac5cc.tar.gz
rust-a4444aa78079665658b0d656c6d243d88a9ac5cc.zip
Add error explanations for E0066 and E0069.
This also updates the error messages for both. For E0066, it removes mention
of "managed heap", which was removed in 8a91d33. For E0069, I just tweaked
the wording to make it a bit more explicit.
-rw-r--r--src/librustc_typeck/check/mod.rs9
-rw-r--r--src/librustc_typeck/diagnostics.rs27
-rw-r--r--src/test/compile-fail/issue-14084.rs2
-rw-r--r--src/test/compile-fail/ret-non-nil.rs2
4 files changed, 32 insertions, 8 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 554f3d4b5a0..3cdbaec1528 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -3082,8 +3082,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
           let mut checked = false;
           opt_place.as_ref().map(|place| match place.node {
               ast::ExprPath(None, ref path) => {
-                  // FIXME(pcwalton): For now we hardcode the two permissible
-                  // places: the exchange heap and the managed heap.
+                  // FIXME(pcwalton): For now we hardcode the only permissible
+                  // place: the exchange heap.
                   let definition = lookup_full_def(tcx, path.span, place.id);
                   let def_id = definition.def_id();
                   let referent_ty = fcx.expr_ty(&**subexpr);
@@ -3097,7 +3097,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
 
           if !checked {
               span_err!(tcx.sess, expr.span, E0066,
-                  "only the managed heap and exchange heap are currently supported");
+                  "only the exchange heap is currently supported");
               fcx.write_ty(id, tcx.types.err);
           }
       }
@@ -3317,7 +3317,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
                         if let Err(_) = fcx.mk_eqty(false, infer::Misc(expr.span),
                                                     result_type, ty::mk_nil(fcx.tcx())) {
                             span_err!(tcx.sess, expr.span, E0069,
-                                "`return;` in function returning non-nil");
+                                "`return;` in a function whose return type is \
+                                 not `()`");
                         },
                     Some(ref e) => {
                         check_expr_coercable_to_type(fcx, &**e, result_type);
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index a11a4edbd31..1613122ecce 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -91,6 +91,16 @@ enum variant, one of the fields was not provided. Each field should be specified
 exactly once.
 "##,
 
+E0066: r##"
+Box placement expressions (like C++'s "placement new") do not support any
+place expression except the exchange heap (i.e. `std::boxed::HEAP`).
+Furthermore, the syntax is changing to use `in` instead of `box`. See [RFC
+470][rfc470] and [RFC 809][rfc809] for more details.
+
+[rfc470]: https://github.com/rust-lang/rfcs/pull/470
+[rfc809]: https://github.com/rust-lang/rfcs/pull/809
+"##,
+
 E0067: r##"
 The left-hand side of an assignment operator must be an lvalue expression. An
 lvalue expression represents a memory location and includes item paths (ie,
@@ -108,6 +118,21 @@ LinkedList::new() += 1;
 ```
 "##,
 
+E0069: r##"
+The compiler found a function whose body contains a `return;` statement but
+whose return type is not `()`. An example of this is:
+
+```
+// error
+fn foo() -> u8 {
+    return;
+}
+```
+
+Since `return;` is just like `return ();`, there is a mismatch between the
+function's return type and the value being returned.
+"##,
+
 E0081: r##"
 Enum discriminants are used to differentiate enum variants stored in memory.
 This error indicates that the same value was used for two or more variants,
@@ -484,9 +509,7 @@ register_diagnostics! {
     E0059,
     E0060,
     E0061,
-    E0066,
     E0068,
-    E0069,
     E0070,
     E0071,
     E0072,
diff --git a/src/test/compile-fail/issue-14084.rs b/src/test/compile-fail/issue-14084.rs
index 92e0dd3ad0e..003c6644f7f 100644
--- a/src/test/compile-fail/issue-14084.rs
+++ b/src/test/compile-fail/issue-14084.rs
@@ -12,5 +12,5 @@
 
 fn main() {
     box ( () ) 0;
-    //~^ ERROR: only the managed heap and exchange heap are currently supported
+    //~^ ERROR: only the exchange heap is currently supported
 }
diff --git a/src/test/compile-fail/ret-non-nil.rs b/src/test/compile-fail/ret-non-nil.rs
index 4ee3cf4abac..6be98fbd827 100644
--- a/src/test/compile-fail/ret-non-nil.rs
+++ b/src/test/compile-fail/ret-non-nil.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern: `return;` in function returning non-nil
+// error-pattern: `return;` in a function whose return type is not `()`
 
 fn f() { return; }