Skip to content

Commit 714dfb0

Browse files
committed
---
yaml --- r: 96079 b: refs/heads/dist-snap c: 49c6ae1 h: refs/heads/master i: 96077: 28560f9 96075: 37223ab 96071: 98bf525 96063: f06627b v: v3
1 parent 4388991 commit 714dfb0

24 files changed

+543
-368
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 3d57b240ab1fd038b3a41fe2042dc9a0544ea53e
9+
refs/heads/dist-snap: 49c6ae10cb2a67a3e673507213ffed3201e43c9c
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libextra/time.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,18 +1005,17 @@ mod tests {
10051005

10061006
fn test_precise_time() {
10071007
let s0 = precise_time_s();
1008-
let ns1 = precise_time_ns();
1009-
10101008
debug!("s0={} sec", f64::to_str_digits(s0, 9u));
10111009
assert!(s0 > 0.);
1012-
let ns0 = (s0 * 1000000000.) as u64;
1013-
debug!("ns0={:?} ns", ns0);
10141010

1015-
debug!("ns1={:?} ns", ns0);
1011+
let ns0 = precise_time_ns();
1012+
let ns1 = precise_time_ns();
1013+
debug!("ns0={:?} ns", ns0);
1014+
debug!("ns1={:?} ns", ns1);
10161015
assert!(ns1 >= ns0);
10171016

10181017
let ns2 = precise_time_ns();
1019-
debug!("ns2={:?} ns", ns0);
1018+
debug!("ns2={:?} ns", ns2);
10201019
assert!(ns2 >= ns1);
10211020
}
10221021

branches/dist-snap/src/librustc/driver/driver.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,10 @@ pub fn phase_3_run_analysis_passes(sess: Session,
302302

303303
let reachable_map =
304304
time(time_passes, "reachability checking", (), |_|
305-
reachable::find_reachable(ty_cx, method_map, exp_map2,
306-
&exported_items));
305+
reachable::find_reachable(ty_cx, method_map, &exported_items));
307306

308307
time(time_passes, "lint checking", (), |_|
309-
lint::check_crate(ty_cx, crate));
308+
lint::check_crate(ty_cx, &exported_items, crate));
310309

311310
CrateAnalysis {
312311
exp_map2: exp_map2,

branches/dist-snap/src/librustc/middle/check_loop.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,68 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
1211
use middle::ty;
1312

14-
use syntax::ast::*;
15-
use syntax::visit;
13+
use syntax::ast;
14+
use syntax::codemap::Span;
1615
use syntax::visit::Visitor;
16+
use syntax::visit;
1717

18-
#[deriving(Clone)]
19-
pub struct Context {
20-
in_loop: bool,
21-
can_ret: bool
18+
#[deriving(Clone, Eq)]
19+
enum Context {
20+
Normal, Loop, Closure
2221
}
2322

2423
struct CheckLoopVisitor {
2524
tcx: ty::ctxt,
2625
}
2726

28-
pub fn check_crate(tcx: ty::ctxt, crate: &Crate) {
29-
visit::walk_crate(&mut CheckLoopVisitor { tcx: tcx },
30-
crate,
31-
Context { in_loop: false, can_ret: true });
27+
pub fn check_crate(tcx: ty::ctxt, crate: &ast::Crate) {
28+
visit::walk_crate(&mut CheckLoopVisitor { tcx: tcx }, crate, Normal)
3229
}
3330

3431
impl Visitor<Context> for CheckLoopVisitor {
35-
fn visit_item(&mut self, i:@item, _cx:Context) {
36-
visit::walk_item(self, i, Context {
37-
in_loop: false,
38-
can_ret: true
39-
});
32+
fn visit_item(&mut self, i: @ast::item, _cx: Context) {
33+
visit::walk_item(self, i, Normal);
4034
}
4135

42-
fn visit_expr(&mut self, e:@Expr, cx:Context) {
43-
44-
match e.node {
45-
ExprWhile(e, ref b) => {
36+
fn visit_expr(&mut self, e: @ast::Expr, cx:Context) {
37+
match e.node {
38+
ast::ExprWhile(e, ref b) => {
4639
self.visit_expr(e, cx);
47-
self.visit_block(b, Context { in_loop: true,.. cx });
48-
}
49-
ExprLoop(ref b, _) => {
50-
self.visit_block(b, Context { in_loop: true,.. cx });
51-
}
52-
ExprFnBlock(_, ref b) | ExprProc(_, ref b) => {
53-
self.visit_block(b, Context { in_loop: false, can_ret: false });
54-
}
55-
ExprBreak(_) => {
56-
if !cx.in_loop {
57-
self.tcx.sess.span_err(e.span, "`break` outside of loop");
58-
}
59-
}
60-
ExprAgain(_) => {
61-
if !cx.in_loop {
62-
self.tcx.sess.span_err(e.span, "`loop` outside of loop");
63-
}
64-
}
65-
ExprRet(oe) => {
66-
if !cx.can_ret {
67-
self.tcx.sess.span_err(e.span, "`return` in block function");
40+
self.visit_block(b, Loop);
41+
}
42+
ast::ExprLoop(ref b, _) => {
43+
self.visit_block(b, Loop);
44+
}
45+
ast::ExprFnBlock(_, ref b) | ast::ExprProc(_, ref b) => {
46+
self.visit_block(b, Closure);
47+
}
48+
ast::ExprBreak(_) => self.require_loop("break", cx, e.span),
49+
ast::ExprAgain(_) => self.require_loop("continue", cx, e.span),
50+
ast::ExprRet(oe) => {
51+
if cx == Closure {
52+
self.tcx.sess.span_err(e.span, "`return` in a closure");
6853
}
6954
visit::walk_expr_opt(self, oe, cx);
70-
}
71-
_ => visit::walk_expr(self, e, cx)
7255
}
56+
_ => visit::walk_expr(self, e, cx)
57+
}
58+
}
59+
}
7360

61+
impl CheckLoopVisitor {
62+
fn require_loop(&self, name: &str, cx: Context, span: Span) {
63+
match cx {
64+
Loop => {}
65+
Closure => {
66+
self.tcx.sess.span_err(span, format!("`{}` inside of a closure",
67+
name));
68+
}
69+
Normal => {
70+
self.tcx.sess.span_err(span, format!("`{}` outside of loop",
71+
name));
72+
}
73+
}
7474
}
7575
}

0 commit comments

Comments
 (0)