Skip to content

Commit f37e202

Browse files
committed
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.
1 parent 935da07 commit f37e202

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/doc/guide.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -895,13 +895,14 @@ fn add_one(x: int) -> int {
895895
We would get an error:
896896

897897
```{ignore,notrust}
898-
note: consider removing this semicolon:
899-
x + 1;
900-
^
901898
error: not all control paths return a value
902899
fn add_one(x: int) -> int {
903900
x + 1;
904901
}
902+
903+
note: consider removing this semicolon:
904+
x + 1;
905+
^
905906
```
906907

907908
Remember our earlier discussions about semicolons and `()`? Our function claims

src/librustc/middle/liveness.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,8 @@ impl<'a> Liveness<'a> {
14581458
},
14591459
_ => false
14601460
};
1461+
self.ir.tcx.sess.span_err(
1462+
sp, "not all control paths return a value");
14611463
if ends_with_stmt {
14621464
let last_stmt = body.stmts.last().unwrap();
14631465
let original_span = original_sp(last_stmt.span, sp);
@@ -1469,8 +1471,6 @@ impl<'a> Liveness<'a> {
14691471
self.ir.tcx.sess.span_note(
14701472
span_semicolon, "consider removing this semicolon:");
14711473
}
1472-
self.ir.tcx.sess.span_err(
1473-
sp, "not all control paths return a value");
14741474
}
14751475
}
14761476
}

0 commit comments

Comments
 (0)