diff options
| author | Roy Brunton <roy@flashtalking.com> | 2016-08-05 15:06:36 +0100 |
|---|---|---|
| committer | Roy Brunton <roy@flashtalking.com> | 2016-08-05 15:06:36 +0100 |
| commit | 5eebb92c2fd62c2f20aa6c67d7f58f37ec521586 (patch) | |
| tree | 16e95115336f9f5cf88bd58281f55ecfaa00bd8f /src | |
| parent | 40f3ee2a01ef24d57430726c098de905c7c6e04a (diff) | |
| download | rust-5eebb92c2fd62c2f20aa6c67d7f58f37ec521586.tar.gz rust-5eebb92c2fd62c2f20aa6c67d7f58f37ec521586.zip | |
Update error message for E0166
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/E0166.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/bad-bang-ann-3.rs | 4 |
3 files changed, 10 insertions, 4 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 6062bd048b3..8817c6f8d1e 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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()); diff --git a/src/test/compile-fail/E0166.rs b/src/test/compile-fail/E0166.rs index 9fa41249aa5..f8585d71b40 100644 --- a/src/test/compile-fail/E0166.rs +++ b/src/test/compile-fail/E0166.rs @@ -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() { } diff --git a/src/test/compile-fail/bad-bang-ann-3.rs b/src/test/compile-fail/bad-bang-ann-3.rs index de315a41361..1a5496f0551 100644 --- a/src/test/compile-fail/bad-bang-ann-3.rs +++ b/src/test/compile-fail/bad-bang-ann-3.rs @@ -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); } |
