@@ -28,7 +28,7 @@ use rustc::middle::dataflow::DataFlowContext;
28
28
use rustc:: middle:: dataflow:: BitwiseOperator ;
29
29
use rustc:: middle:: dataflow:: DataFlowOperator ;
30
30
use rustc:: middle:: dataflow:: KillFrom ;
31
- use rustc:: middle:: borrowck:: BorrowCheckResult ;
31
+ use rustc:: middle:: borrowck:: { BorrowCheckResult , SignalledError } ;
32
32
use rustc:: hir:: def_id:: { DefId , LocalDefId } ;
33
33
use rustc:: middle:: expr_use_visitor as euv;
34
34
use rustc:: middle:: mem_categorization as mc;
@@ -42,7 +42,7 @@ use rustc_mir::util::borrowck_errors::{BorrowckErrors, Origin};
42
42
use rustc_mir:: util:: suggest_ref_mut;
43
43
use rustc:: util:: nodemap:: FxHashSet ;
44
44
45
- use std:: cell:: RefCell ;
45
+ use std:: cell:: { Cell , RefCell } ;
46
46
use std:: fmt;
47
47
use std:: rc:: Rc ;
48
48
use rustc_data_structures:: sync:: Lrc ;
@@ -90,7 +90,7 @@ pub struct AnalysisData<'a, 'tcx: 'a> {
90
90
fn borrowck < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , owner_def_id : DefId )
91
91
-> Lrc < BorrowCheckResult >
92
92
{
93
- assert ! ( tcx. use_ast_borrowck( ) ) ;
93
+ assert ! ( tcx. use_ast_borrowck( ) || tcx . migrate_borrowck ( ) ) ;
94
94
95
95
debug ! ( "borrowck(body_owner_def_id={:?})" , owner_def_id) ;
96
96
@@ -105,6 +105,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
105
105
// and do not need borrowchecking.
106
106
return Lrc :: new ( BorrowCheckResult {
107
107
used_mut_nodes : FxHashSet ( ) ,
108
+ signalled_any_error : SignalledError :: NoErrorsSeen ,
108
109
} )
109
110
}
110
111
_ => { }
@@ -121,6 +122,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
121
122
owner_def_id,
122
123
body,
123
124
used_mut_nodes : RefCell :: new ( FxHashSet ( ) ) ,
125
+ signalled_any_error : Cell :: new ( SignalledError :: NoErrorsSeen ) ,
124
126
} ;
125
127
126
128
// 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)
154
156
155
157
Lrc :: new ( BorrowCheckResult {
156
158
used_mut_nodes : bccx. used_mut_nodes . into_inner ( ) ,
159
+ signalled_any_error : bccx. signalled_any_error . into_inner ( ) ,
157
160
} )
158
161
}
159
162
@@ -234,6 +237,7 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
234
237
owner_def_id,
235
238
body,
236
239
used_mut_nodes : RefCell :: new ( FxHashSet ( ) ) ,
240
+ signalled_any_error : Cell :: new ( SignalledError :: NoErrorsSeen ) ,
237
241
} ;
238
242
239
243
let dataflow_data = build_borrowck_dataflow_data ( & mut bccx, true , body_id, |_| cfg) ;
@@ -257,6 +261,15 @@ pub struct BorrowckCtxt<'a, 'tcx: 'a> {
257
261
body : & ' tcx hir:: Body ,
258
262
259
263
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
+ }
260
273
}
261
274
262
275
impl < ' a , ' b , ' tcx : ' b > BorrowckErrors < ' a > for & ' a BorrowckCtxt < ' b , ' tcx > {
@@ -645,6 +658,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
645
658
. span_label ( use_span, format ! ( "use of possibly uninitialized `{}`" ,
646
659
self . loan_path_to_string( lp) ) )
647
660
. emit ( ) ;
661
+ self . signal_error ( ) ;
648
662
return ;
649
663
}
650
664
_ => {
@@ -760,6 +774,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
760
774
// not considered particularly helpful.
761
775
762
776
err. emit ( ) ;
777
+ self . signal_error ( ) ;
763
778
}
764
779
765
780
pub fn report_partial_reinitialization_of_uninitialized_structure (
@@ -770,6 +785,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
770
785
& self . loan_path_to_string ( lp) ,
771
786
Origin :: Ast )
772
787
. emit ( ) ;
788
+ self . signal_error ( ) ;
773
789
}
774
790
775
791
pub fn report_reassigned_immutable_variable ( & self ,
@@ -787,6 +803,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
787
803
self . loan_path_to_string( lp) ) ) ;
788
804
}
789
805
err. emit ( ) ;
806
+ self . signal_error ( ) ;
790
807
}
791
808
792
809
pub fn struct_span_err_with_code < S : Into < MultiSpan > > ( & self ,
@@ -908,6 +925,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
908
925
self . tcx . hir . hir_to_node_id ( err. cmt . hir_id )
909
926
) ;
910
927
db. emit ( ) ;
928
+ self . signal_error ( ) ;
911
929
}
912
930
err_out_of_scope( super_scope, sub_scope, cause) => {
913
931
let msg = match opt_loan_path ( & err. cmt ) {
@@ -1022,6 +1040,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
1022
1040
}
1023
1041
1024
1042
db. emit ( ) ;
1043
+ self . signal_error ( ) ;
1025
1044
}
1026
1045
err_borrowed_pointer_too_short( loan_scope, ptr_scope) => {
1027
1046
let descr = self . cmt_to_path_or_string ( err. cmt ) ;
@@ -1047,6 +1066,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
1047
1066
"" ) ;
1048
1067
1049
1068
db. emit ( ) ;
1069
+ self . signal_error ( ) ;
1050
1070
}
1051
1071
}
1052
1072
}
@@ -1125,6 +1145,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
1125
1145
err. help ( "closures behind references must be called via `&mut`" ) ;
1126
1146
}
1127
1147
err. emit ( ) ;
1148
+ self . signal_error ( ) ;
1128
1149
}
1129
1150
1130
1151
/// 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> {
1307
1328
cmt_path_or_string) ,
1308
1329
suggestion)
1309
1330
. emit ( ) ;
1331
+ self . signal_error ( ) ;
1310
1332
}
1311
1333
1312
1334
fn region_end_span ( & self , region : ty:: Region < ' tcx > ) -> Option < Span > {
0 commit comments