@@ -28,7 +28,7 @@ use rustc::middle::dataflow::DataFlowContext;
2828use rustc:: middle:: dataflow:: BitwiseOperator ;
2929use rustc:: middle:: dataflow:: DataFlowOperator ;
3030use rustc:: middle:: dataflow:: KillFrom ;
31- use rustc:: middle:: borrowck:: BorrowCheckResult ;
31+ use rustc:: middle:: borrowck:: { BorrowCheckResult , SignalledError } ;
3232use rustc:: hir:: def_id:: { DefId , LocalDefId } ;
3333use rustc:: middle:: expr_use_visitor as euv;
3434use rustc:: middle:: mem_categorization as mc;
@@ -42,7 +42,7 @@ use rustc_mir::util::borrowck_errors::{BorrowckErrors, Origin};
4242use rustc_mir:: util:: suggest_ref_mut;
4343use rustc:: util:: nodemap:: FxHashSet ;
4444
45- use std:: cell:: RefCell ;
45+ use std:: cell:: { Cell , RefCell } ;
4646use std:: fmt;
4747use std:: rc:: Rc ;
4848use rustc_data_structures:: sync:: Lrc ;
@@ -90,7 +90,7 @@ pub struct AnalysisData<'a, 'tcx: 'a> {
9090fn borrowck < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , owner_def_id : DefId )
9191 -> Lrc < BorrowCheckResult >
9292{
93- assert ! ( tcx. use_ast_borrowck( ) ) ;
93+ assert ! ( tcx. use_ast_borrowck( ) || tcx . migrate_borrowck ( ) ) ;
9494
9595 debug ! ( "borrowck(body_owner_def_id={:?})" , owner_def_id) ;
9696
@@ -105,6 +105,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
105105 // and do not need borrowchecking.
106106 return Lrc :: new ( BorrowCheckResult {
107107 used_mut_nodes : FxHashSet ( ) ,
108+ signalled_any_error : SignalledError :: NoErrorsSeen ,
108109 } )
109110 }
110111 _ => { }
@@ -121,6 +122,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
121122 owner_def_id,
122123 body,
123124 used_mut_nodes : RefCell :: new ( FxHashSet ( ) ) ,
125+ signalled_any_error : Cell :: new ( SignalledError :: NoErrorsSeen ) ,
124126 } ;
125127
126128 // Eventually, borrowck will always read the MIR, but at the
@@ -154,6 +156,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
154156
155157 Lrc :: new ( BorrowCheckResult {
156158 used_mut_nodes : bccx. used_mut_nodes . into_inner ( ) ,
159+ signalled_any_error : bccx. signalled_any_error . into_inner ( ) ,
157160 } )
158161}
159162
@@ -234,6 +237,7 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
234237 owner_def_id,
235238 body,
236239 used_mut_nodes : RefCell :: new ( FxHashSet ( ) ) ,
240+ signalled_any_error : Cell :: new ( SignalledError :: NoErrorsSeen ) ,
237241 } ;
238242
239243 let dataflow_data = build_borrowck_dataflow_data ( & mut bccx, true , body_id, |_| cfg) ;
@@ -257,6 +261,15 @@ pub struct BorrowckCtxt<'a, 'tcx: 'a> {
257261 body : & ' tcx hir:: Body ,
258262
259263 used_mut_nodes : RefCell < FxHashSet < HirId > > ,
264+
265+ signalled_any_error : Cell < SignalledError > ,
266+ }
267+
268+
269+ impl < ' a , ' tcx : ' a > BorrowckCtxt < ' a , ' tcx > {
270+ fn signal_error ( & self ) {
271+ self . signalled_any_error . set ( SignalledError :: SawSomeError ) ;
272+ }
260273}
261274
262275impl < ' a , ' b , ' tcx : ' b > BorrowckErrors < ' a > for & ' a BorrowckCtxt < ' b , ' tcx > {
@@ -645,6 +658,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
645658 . span_label ( use_span, format ! ( "use of possibly uninitialized `{}`" ,
646659 self . loan_path_to_string( lp) ) )
647660 . emit ( ) ;
661+ self . signal_error ( ) ;
648662 return ;
649663 }
650664 _ => {
@@ -760,6 +774,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
760774 // not considered particularly helpful.
761775
762776 err. emit ( ) ;
777+ self . signal_error ( ) ;
763778 }
764779
765780 pub fn report_partial_reinitialization_of_uninitialized_structure (
@@ -770,6 +785,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
770785 & self . loan_path_to_string ( lp) ,
771786 Origin :: Ast )
772787 . emit ( ) ;
788+ self . signal_error ( ) ;
773789 }
774790
775791 pub fn report_reassigned_immutable_variable ( & self ,
@@ -787,6 +803,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
787803 self . loan_path_to_string( lp) ) ) ;
788804 }
789805 err. emit ( ) ;
806+ self . signal_error ( ) ;
790807 }
791808
792809 pub fn struct_span_err_with_code < S : Into < MultiSpan > > ( & self ,
@@ -908,6 +925,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
908925 self . tcx . hir . hir_to_node_id ( err. cmt . hir_id )
909926 ) ;
910927 db. emit ( ) ;
928+ self . signal_error ( ) ;
911929 }
912930 err_out_of_scope( super_scope, sub_scope, cause) => {
913931 let msg = match opt_loan_path ( & err. cmt ) {
@@ -1022,6 +1040,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
10221040 }
10231041
10241042 db. emit ( ) ;
1043+ self . signal_error ( ) ;
10251044 }
10261045 err_borrowed_pointer_too_short( loan_scope, ptr_scope) => {
10271046 let descr = self . cmt_to_path_or_string ( err. cmt ) ;
@@ -1047,6 +1066,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
10471066 "" ) ;
10481067
10491068 db. emit ( ) ;
1069+ self . signal_error ( ) ;
10501070 }
10511071 }
10521072 }
@@ -1125,6 +1145,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
11251145 err. help ( "closures behind references must be called via `&mut`" ) ;
11261146 }
11271147 err. emit ( ) ;
1148+ self . signal_error ( ) ;
11281149 }
11291150
11301151 /// Given a type, if it is an immutable reference, return a suggestion to make it mutable
@@ -1307,6 +1328,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
13071328 cmt_path_or_string) ,
13081329 suggestion)
13091330 . emit ( ) ;
1331+ self . signal_error ( ) ;
13101332 }
13111333
13121334 fn region_end_span ( & self , region : ty:: Region < ' tcx > ) -> Option < Span > {
0 commit comments