Skip to content

Commit 528c651

Browse files
committed
Use span_err instead of err. Fixes issue #444.
1 parent d569a71 commit 528c651

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/comp/middle/typeck.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,9 +2009,8 @@ fn check_expr(&@stmt_ctxt scx, &@ast::expr expr) {
20092009
case (none) {
20102010
auto nil = ty::mk_nil(scx.fcx.ccx.tcx);
20112011
if (!are_compatible(scx, scx.fcx.ret_ty, nil)) {
2012-
// TODO: span_err
2013-
scx.fcx.ccx.tcx.sess.err("ret; in function " +
2014-
"returning non-nil");
2012+
scx.fcx.ccx.tcx.sess.span_err(expr.span,
2013+
"ret; in function returning non-nil");
20152014
}
20162015

20172016
write::bot_ty(scx.fcx.ccx.tcx, a.id);

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// error-pattern: ret; in function returning non-nil
2+
3+
fn f() {
4+
ret;
5+
}
6+
7+
fn g() -> int {
8+
ret;
9+
}
10+
11+
fn main() {
12+
f();
13+
g();
14+
}

0 commit comments

Comments
 (0)