rustc: Make return value checking warnings a little prettier. Also introduce a new "note" diagnostic level.

This commit is contained in:
Patrick Walton 2011-05-17 14:12:49 -07:00
parent 5047ab0b0c
commit f300de2963
2 changed files with 10 additions and 3 deletions

View file

@ -102,6 +102,11 @@ state obj session(ast::crate_num cnum,
emit_diagnostic(sp, msg, "warning", 11u8, cm);
}
fn span_note(span sp, str msg) {
// FIXME: Use constants, but rustboot doesn't know how to export them.
emit_diagnostic(sp, msg, "note", 10u8, cm);
}
fn bug(str msg) {
log_err #fmt("error: internal compiler error %s", msg);
fail;

View file

@ -141,9 +141,11 @@ fn check_states_against_conditions(&fn_ctxt fcx, &_fn f, &ann a) -> () {
/* fcx.ccx.tcx.sess.span_err(f.body.span, "Function " +
fcx.name + " may not return. Its declared return type is "
+ util.common.ty_to_str(*f.decl.output)); */
log_err("WARNING: Function " +
fcx.name + " may not return. Its declared return type is "
+ ty_to_str(*f.decl.output));
fcx.ccx.tcx.sess.span_warn(f.body.span, "not all control paths " +
"return a value");
fcx.ccx.tcx.sess.span_note(f.decl.output.span,
"see declared return type of '" + ty_to_str(*f.decl.output) +
"'");
}
}