Skip to content

Commit a4444aa

Browse files
author
Nick Hamann
committed
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.
1 parent 5a341ec commit a4444aa

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,8 +3082,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
30823082
let mut checked = false;
30833083
opt_place.as_ref().map(|place| match place.node {
30843084
ast::ExprPath(None, ref path) => {
3085-
// FIXME(pcwalton): For now we hardcode the two permissible
3086-
// places: the exchange heap and the managed heap.
3085+
// FIXME(pcwalton): For now we hardcode the only permissible
3086+
// place: the exchange heap.
30873087
let definition = lookup_full_def(tcx, path.span, place.id);
30883088
let def_id = definition.def_id();
30893089
let referent_ty = fcx.expr_ty(&**subexpr);
@@ -3097,7 +3097,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
30973097

30983098
if !checked {
30993099
span_err!(tcx.sess, expr.span, E0066,
3100-
"only the managed heap and exchange heap are currently supported");
3100+
"only the exchange heap is currently supported");
31013101
fcx.write_ty(id, tcx.types.err);
31023102
}
31033103
}
@@ -3317,7 +3317,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
33173317
if let Err(_) = fcx.mk_eqty(false, infer::Misc(expr.span),
33183318
result_type, ty::mk_nil(fcx.tcx())) {
33193319
span_err!(tcx.sess, expr.span, E0069,
3320-
"`return;` in function returning non-nil");
3320+
"`return;` in a function whose return type is \
3321+
not `()`");
33213322
},
33223323
Some(ref e) => {
33233324
check_expr_coercable_to_type(fcx, &**e, result_type);

src/librustc_typeck/diagnostics.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ enum variant, one of the fields was not provided. Each field should be specified
9191
exactly once.
9292
"##,
9393

94+
E0066: r##"
95+
Box placement expressions (like C++'s "placement new") do not support any
96+
place expression except the exchange heap (i.e. `std::boxed::HEAP`).
97+
Furthermore, the syntax is changing to use `in` instead of `box`. See [RFC
98+
470][rfc470] and [RFC 809][rfc809] for more details.
99+
100+
[rfc470]: https://github.com/rust-lang/rfcs/pull/470
101+
[rfc809]: https://github.com/rust-lang/rfcs/pull/809
102+
"##,
103+
94104
E0067: r##"
95105
The left-hand side of an assignment operator must be an lvalue expression. An
96106
lvalue expression represents a memory location and includes item paths (ie,
@@ -108,6 +118,21 @@ LinkedList::new() += 1;
108118
```
109119
"##,
110120

121+
E0069: r##"
122+
The compiler found a function whose body contains a `return;` statement but
123+
whose return type is not `()`. An example of this is:
124+
125+
```
126+
// error
127+
fn foo() -> u8 {
128+
return;
129+
}
130+
```
131+
132+
Since `return;` is just like `return ();`, there is a mismatch between the
133+
function's return type and the value being returned.
134+
"##,
135+
111136
E0081: r##"
112137
Enum discriminants are used to differentiate enum variants stored in memory.
113138
This error indicates that the same value was used for two or more variants,
@@ -484,9 +509,7 @@ register_diagnostics! {
484509
E0059,
485510
E0060,
486511
E0061,
487-
E0066,
488512
E0068,
489-
E0069,
490513
E0070,
491514
E0071,
492515
E0072,

src/test/compile-fail/issue-14084.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
fn main() {
1414
box ( () ) 0;
15-
//~^ ERROR: only the managed heap and exchange heap are currently supported
15+
//~^ ERROR: only the exchange heap is currently supported
1616
}

src/test/compile-fail/ret-non-nil.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern: `return;` in function returning non-nil
11+
// error-pattern: `return;` in a function whose return type is not `()`
1212

1313
fn f() { return; }
1414

0 commit comments

Comments
 (0)