From f37e202b53d208cd65f45fa96d2f2453b26bb9ee Mon Sep 17 00:00:00 2001 From: Mike Boutin Date: Fri, 4 Jul 2014 17:25:27 -0400 Subject: [PATCH] rustc: Reorder error and note message to reduce confusion. Moved note after error to reduce confusion when the pair appears in the middle of other errors. Closes #13279. --- src/doc/guide.md | 7 ++++--- src/librustc/middle/liveness.rs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index dc9608563e1..ab480745b68 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -895,13 +895,14 @@ fn add_one(x: int) -> int { We would get an error: ```{ignore,notrust} -note: consider removing this semicolon: - x + 1; - ^ error: not all control paths return a value fn add_one(x: int) -> int { x + 1; } + +note: consider removing this semicolon: + x + 1; + ^ ``` Remember our earlier discussions about semicolons and `()`? Our function claims diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index d48f7f541f0..a3306245762 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -1458,6 +1458,8 @@ impl<'a> Liveness<'a> { }, _ => false }; + self.ir.tcx.sess.span_err( + sp, "not all control paths return a value"); if ends_with_stmt { let last_stmt = body.stmts.last().unwrap(); let original_span = original_sp(last_stmt.span, sp); @@ -1469,8 +1471,6 @@ impl<'a> Liveness<'a> { self.ir.tcx.sess.span_note( span_semicolon, "consider removing this semicolon:"); } - self.ir.tcx.sess.span_err( - sp, "not all control paths return a value"); } } }