Update error message for E0166

This commit is contained in:
Roy Brunton 2016-08-05 15:06:36 +01:00
parent 40f3ee2a01
commit 5eebb92c2f
3 changed files with 10 additions and 4 deletions

View file

@ -3392,8 +3392,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if let Some(ref e) = *expr_opt {
self.check_expr(&e);
}
span_err!(tcx.sess, expr.span, E0166,
"`return` in a function declared as diverging");
struct_span_err!(tcx.sess, expr.span, E0166,
"`return` in a function declared as diverging")
.span_label(expr.span, &format!("diverging function cannot return"))
.emit();
}
}
self.write_ty(id, self.next_diverging_ty_var());

View file

@ -8,7 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo() -> ! { return; } //~ ERROR E0166
fn foo() -> ! { return; }
//~^ ERROR E0166
//~| NOTE diverging function cannot return
fn main() {
}

View file

@ -11,7 +11,9 @@
// Tests that a function with a ! annotation always actually fails
fn bad_bang(i: usize) -> ! {
return 7; //~ ERROR `return` in a function declared as diverging [E0166]
return 7;
//~^ ERROR `return` in a function declared as diverging [E0166]
//~| NOTE diverging function cannot return
}
fn main() { bad_bang(5); }