Skip to content

Commit 4dc62df

Browse files
committed
do not run regionck if there have been type errors
1 parent 7b36e34 commit 4dc62df

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/librustc/middle/typeck/check/regionck.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,19 @@ pub impl Rcx {
138138

139139
pub fn regionck_expr(fcx: @mut FnCtxt, e: @ast::expr) {
140140
let rcx = @mut Rcx { fcx: fcx, errors_reported: 0 };
141-
let v = regionck_visitor();
142-
(v.visit_expr)(e, rcx, v);
141+
if !fcx.tcx().sess.has_errors() { // regionck assumes typeck succeeded
142+
let v = regionck_visitor();
143+
(v.visit_expr)(e, rcx, v);
144+
}
143145
fcx.infcx().resolve_regions();
144146
}
145147

146148
pub fn regionck_fn(fcx: @mut FnCtxt, blk: &ast::blk) {
147149
let rcx = @mut Rcx { fcx: fcx, errors_reported: 0 };
148-
let v = regionck_visitor();
149-
(v.visit_block)(blk, rcx, v);
150+
if !fcx.tcx().sess.has_errors() { // regionck assumes typeck succeeded
151+
let v = regionck_visitor();
152+
(v.visit_block)(blk, rcx, v);
153+
}
150154
fcx.infcx().resolve_regions();
151155
}
152156

0 commit comments

Comments
 (0)