Skip to content

Commit dbd3e71

Browse files
committed
---
yaml --- r: 97662 b: refs/heads/snap-stage3 c: c74c854 h: refs/heads/master v: v3
1 parent 46aacd0 commit dbd3e71

File tree

7 files changed

+61
-28
lines changed

7 files changed

+61
-28
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: b97ace2f6b361f10541586e69371f4924ce967c6
4+
refs/heads/snap-stage3: c74c854adc83eb311aef722e64c0af81ea09f1a1
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/liveness.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ fn visit_fn(v: &mut LivenessVisitor,
439439

440440
// check for various error conditions
441441
lsets.visit_block(body, ());
442-
lsets.check_ret(id, sp, fk, entry_ln);
442+
lsets.check_ret(id, sp, fk, entry_ln, body);
443443
lsets.warn_about_unused_args(decl, entry_ln);
444444
}
445445

@@ -1575,7 +1575,8 @@ impl Liveness {
15751575
id: NodeId,
15761576
sp: Span,
15771577
_fk: &FnKind,
1578-
entry_ln: LiveNode) {
1578+
entry_ln: LiveNode,
1579+
body: &Block) {
15791580
if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() {
15801581
// if no_ret_var is live, then we fall off the end of the
15811582
// function without any kind of return expression:
@@ -1588,9 +1589,30 @@ impl Liveness {
15881589
self.tcx.sess.span_err(
15891590
sp, "some control paths may return");
15901591
} else {
1592+
let ends_with_stmt = match body.expr {
1593+
None if body.stmts.len() > 0 =>
1594+
match body.stmts.last().node {
1595+
StmtSemi(e, _) => {
1596+
let t_stmt = ty::expr_ty(self.tcx, e);
1597+
ty::get(t_stmt).sty == ty::get(t_ret).sty
1598+
},
1599+
_ => false
1600+
},
1601+
_ => false
1602+
};
1603+
if ends_with_stmt {
1604+
let last_stmt = body.stmts.last();
1605+
let span_semicolon = Span {
1606+
lo: last_stmt.span.hi,
1607+
hi: last_stmt.span.hi,
1608+
expn_info: last_stmt.span.expn_info
1609+
};
1610+
self.tcx.sess.span_note(
1611+
span_semicolon, "consider removing this semicolon:");
1612+
}
15911613
self.tcx.sess.span_err(
15921614
sp, "not all control paths return a value");
1593-
}
1615+
}
15941616
}
15951617
}
15961618

branches/snap-stage3/src/librustc/middle/ty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,23 +810,23 @@ impl Vid for TyVid {
810810
}
811811

812812
impl ToStr for TyVid {
813-
fn to_str(&self) -> ~str { format!("<generic \\#{}>", self.to_uint()) }
813+
fn to_str(&self) -> ~str { format!("<V{}>", self.to_uint()) }
814814
}
815815

816816
impl Vid for IntVid {
817817
fn to_uint(&self) -> uint { let IntVid(v) = *self; v }
818818
}
819819

820820
impl ToStr for IntVid {
821-
fn to_str(&self) -> ~str { format!("<generic integer \\#{}>", self.to_uint()) }
821+
fn to_str(&self) -> ~str { format!("<VI{}>", self.to_uint()) }
822822
}
823823

824824
impl Vid for FloatVid {
825825
fn to_uint(&self) -> uint { let FloatVid(v) = *self; v }
826826
}
827827

828828
impl ToStr for FloatVid {
829-
fn to_str(&self) -> ~str { format!("<generic float \\#{}>", self.to_uint()) }
829+
fn to_str(&self) -> ~str { format!("<VF{}>", self.to_uint()) }
830830
}
831831

832832
impl Vid for RegionVid {

branches/snap-stage3/src/test/compile-fail/issue-3680.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
fn main() {
1212
match None {
13-
Err(_) => () //~ ERROR mismatched types: expected `std::option::Option<<generic #1>>` but found `std::result::Result<<generic #2>,<generic #3>>`
13+
Err(_) => () //~ ERROR mismatched types: expected `std::option::Option<<V1>>` but found `std::result::Result<<V2>,<V3>>`
1414
}
1515
}

branches/snap-stage3/src/test/compile-fail/issue-4968.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
static A: (int,int) = (4,2);
1414
fn main() {
15-
match 42 { A => () } //~ ERROR mismatched types: expected `<generic integer #0>` but found `(int,int)` (expected integral variable but found tuple)
15+
match 42 { A => () } //~ ERROR mismatched types: expected `<VI0>` but found `(int,int)` (expected integral variable but found tuple)
1616
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
//
11+
// regression test for #8005
12+
13+
#[feature(macro_rules)];
14+
15+
macro_rules! test ( () => { fn foo() -> int { 1i; } } ) //~ ERROR not all control paths return a value
16+
//~^ NOTE consider removing this semicolon
17+
18+
fn no_return() -> int {} //~ ERROR not all control paths return a value
19+
20+
fn bar(x: u32) -> u32 { //~ ERROR not all control paths return a value
21+
x * 2; //~ NOTE consider removing this semicolon
22+
}
23+
24+
fn baz(x: u64) -> u32 { //~ ERROR not all control paths return a value
25+
x * 2;
26+
}
27+
28+
fn main() {
29+
test!();
30+
}

branches/snap-stage3/src/test/compile-fail/slightly-nice-generic-literal-messages.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)