Use span_err instead of err. Fixes issue #444.
This commit is contained in:
parent
d569a71b0b
commit
528c6516f0
@ -2009,9 +2009,8 @@ fn check_expr(&@stmt_ctxt scx, &@ast::expr expr) {
|
||||
case (none) {
|
||||
auto nil = ty::mk_nil(scx.fcx.ccx.tcx);
|
||||
if (!are_compatible(scx, scx.fcx.ret_ty, nil)) {
|
||||
// TODO: span_err
|
||||
scx.fcx.ccx.tcx.sess.err("ret; in function " +
|
||||
"returning non-nil");
|
||||
scx.fcx.ccx.tcx.sess.span_err(expr.span,
|
||||
"ret; in function returning non-nil");
|
||||
}
|
||||
|
||||
write::bot_ty(scx.fcx.ccx.tcx, a.id);
|
||||
|
14
src/test/compile-fail/ret-non-nil.rs
Normal file
14
src/test/compile-fail/ret-non-nil.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// error-pattern: ret; in function returning non-nil
|
||||
|
||||
fn f() {
|
||||
ret;
|
||||
}
|
||||
|
||||
fn g() -> int {
|
||||
ret;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
f();
|
||||
g();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user