Skip to content

Commit

Permalink
Rollup merge of rust-lang#35288 - Roybie:35271-E0166-update-error-for…
Browse files Browse the repository at this point in the history
…mat, r=GuillaumeGomez

Update error message for E0166

Fixes rust-lang#35271 as part of rust-lang#35233.

r? @jonathandturner
  • Loading branch information
eddyb authored Aug 6, 2016
2 parents d9cc84b + 5eebb92 commit bb1ff9d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3415,8 +3415,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());
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0166.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/bad-bang-ann-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

0 comments on commit bb1ff9d

Please sign in to comment.