@@ -13,7 +13,8 @@ use rustc::hir::lowering::lower_crate;
13
13
use rustc:: ich:: Fingerprint ;
14
14
use rustc_data_structures:: stable_hasher:: StableHasher ;
15
15
use rustc_mir as mir;
16
- use rustc:: session:: { Session , CompileResult , compile_result_from_err_count} ;
16
+ use rustc:: session:: { Session , CompileResult } ;
17
+ use rustc:: session:: CompileIncomplete ;
17
18
use rustc:: session:: config:: { self , Input , OutputFilenames , OutputType ,
18
19
OutputTypes } ;
19
20
use rustc:: session:: search_paths:: PathKind ;
@@ -23,7 +24,7 @@ use rustc::middle::privacy::AccessLevels;
23
24
use rustc:: mir:: transform:: { MIR_CONST , MIR_VALIDATED , MIR_OPTIMIZED , Passes } ;
24
25
use rustc:: ty:: { self , TyCtxt , Resolutions , GlobalArenas } ;
25
26
use rustc:: traits;
26
- use rustc:: util:: common:: time;
27
+ use rustc:: util:: common:: { ErrorReported , time} ;
27
28
use rustc:: util:: nodemap:: NodeSet ;
28
29
use rustc:: util:: fs:: rename_or_copy_remove;
29
30
use rustc_borrowck as borrowck;
@@ -78,7 +79,9 @@ pub fn compile_input(sess: &Session,
78
79
}
79
80
80
81
if control. $point. stop == Compilation :: Stop {
81
- return compile_result_from_err_count( $tsess. err_count( ) ) ;
82
+ // FIXME: shouldn't this return Err(CompileIncomplete::Stopped)
83
+ // if there are no errors?
84
+ return $tsess. compile_status( ) ;
82
85
}
83
86
} }
84
87
}
@@ -91,7 +94,7 @@ pub fn compile_input(sess: &Session,
91
94
Ok ( krate) => krate,
92
95
Err ( mut parse_error) => {
93
96
parse_error. emit ( ) ;
94
- return Err ( 1 ) ;
97
+ return Err ( CompileIncomplete :: Errored ( ErrorReported ) ) ;
95
98
}
96
99
} ;
97
100
@@ -194,7 +197,7 @@ pub fn compile_input(sess: &Session,
194
197
( control. after_analysis . callback ) ( & mut state) ;
195
198
196
199
if control. after_analysis . stop == Compilation :: Stop {
197
- return result. and_then ( |_| Err ( 0usize ) ) ;
200
+ return result. and_then ( |_| Err ( CompileIncomplete :: Stopped ) ) ;
198
201
}
199
202
}
200
203
@@ -564,7 +567,7 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
564
567
addl_plugins : Option < Vec < String > > ,
565
568
make_glob_map : MakeGlobMap ,
566
569
after_expand : F )
567
- -> Result < ExpansionResult , usize >
570
+ -> Result < ExpansionResult , CompileIncomplete >
568
571
where F : FnOnce ( & ast:: Crate ) -> CompileResult ,
569
572
{
570
573
let time_passes = sess. time_passes ( ) ;
@@ -636,7 +639,7 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
636
639
// Lint plugins are registered; now we can process command line flags.
637
640
if sess. opts . describe_lints {
638
641
super :: describe_lints ( & sess. lint_store . borrow ( ) , true ) ;
639
- return Err ( 0 ) ;
642
+ return Err ( CompileIncomplete :: Stopped ) ;
640
643
}
641
644
sess. track_errors ( || sess. lint_store . borrow_mut ( ) . process_command_line ( sess) ) ?;
642
645
@@ -839,7 +842,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
839
842
arenas : & ' tcx GlobalArenas < ' tcx > ,
840
843
name : & str ,
841
844
f : F )
842
- -> Result < R , usize >
845
+ -> Result < R , CompileIncomplete >
843
846
where F : for < ' a > FnOnce ( TyCtxt < ' a , ' tcx , ' tcx > ,
844
847
ty:: CrateAnalysis ,
845
848
IncrementalHashesMap ,
@@ -1019,7 +1022,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
1019
1022
// lint warnings and so on -- kindck used to do this abort, but
1020
1023
// kindck is gone now). -nmatsakis
1021
1024
if sess. err_count ( ) > 0 {
1022
- return Ok ( f ( tcx, analysis, incremental_hashes_map, Err ( sess. err_count ( ) ) ) ) ;
1025
+ return Ok ( f ( tcx, analysis, incremental_hashes_map, sess. compile_status ( ) ) ) ;
1023
1026
}
1024
1027
1025
1028
analysis. reachable =
@@ -1035,12 +1038,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
1035
1038
1036
1039
time ( time_passes, "lint checking" , || lint:: check_crate ( tcx) ) ;
1037
1040
1038
- // The above three passes generate errors w/o aborting
1039
- if sess. err_count ( ) > 0 {
1040
- return Ok ( f ( tcx, analysis, incremental_hashes_map, Err ( sess. err_count ( ) ) ) ) ;
1041
- }
1042
-
1043
- Ok ( f ( tcx, analysis, incremental_hashes_map, Ok ( ( ) ) ) )
1041
+ return Ok ( f ( tcx, analysis, incremental_hashes_map, tcx. sess . compile_status ( ) ) ) ;
1044
1042
} )
1045
1043
}
1046
1044
@@ -1116,11 +1114,7 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
1116
1114
"serialize work products" ,
1117
1115
move || rustc_incremental:: save_work_products ( sess) ) ;
1118
1116
1119
- if sess. err_count ( ) > 0 {
1120
- Err ( sess. err_count ( ) )
1121
- } else {
1122
- Ok ( ( ) )
1123
- }
1117
+ sess. compile_status ( )
1124
1118
}
1125
1119
1126
1120
/// Run the linker on any artifacts that resulted from the LLVM run.
0 commit comments