@@ -362,6 +362,9 @@ top_level_options!(
362
362
363
363
debugging_opts: DebuggingOptions [ TRACKED ] ,
364
364
prints: Vec <PrintRequest > [ UNTRACKED ] ,
365
+ // Determines which borrow checker(s) to run. This is the parsed, sanitized
366
+ // version of `debugging_opts.borrowck`, which is just a plain string.
367
+ borrowck_mode: BorrowckMode [ UNTRACKED ] ,
365
368
cg: CodegenOptions [ TRACKED ] ,
366
369
// FIXME(mw): We track this for now but it actually doesn't make too
367
370
// much sense: The value of this option can stay the same
@@ -401,6 +404,32 @@ pub enum PrintRequest {
401
404
NativeStaticLibs ,
402
405
}
403
406
407
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
408
+ pub enum BorrowckMode {
409
+ Ast ,
410
+ Mir ,
411
+ Compare ,
412
+ }
413
+
414
+ impl BorrowckMode {
415
+ /// Should we emit the AST-based borrow checker errors?
416
+ pub fn use_ast ( self ) -> bool {
417
+ match self {
418
+ BorrowckMode :: Ast => true ,
419
+ BorrowckMode :: Compare => true ,
420
+ BorrowckMode :: Mir => false ,
421
+ }
422
+ }
423
+ /// Should we emit the MIR-based borrow checker errors?
424
+ pub fn use_mir ( self ) -> bool {
425
+ match self {
426
+ BorrowckMode :: Ast => false ,
427
+ BorrowckMode :: Compare => true ,
428
+ BorrowckMode :: Mir => true ,
429
+ }
430
+ }
431
+ }
432
+
404
433
pub enum Input {
405
434
/// Load source from file
406
435
File ( PathBuf ) ,
@@ -526,6 +555,7 @@ pub fn basic_options() -> Options {
526
555
incremental : None ,
527
556
debugging_opts : basic_debugging_options ( ) ,
528
557
prints : Vec :: new ( ) ,
558
+ borrowck_mode : BorrowckMode :: Ast ,
529
559
cg : basic_codegen_options ( ) ,
530
560
error_format : ErrorOutputType :: default ( ) ,
531
561
externs : Externs ( BTreeMap :: new ( ) ) ,
@@ -973,8 +1003,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
973
1003
"make unnamed regions display as '# (where # is some non-ident unique id)" ) ,
974
1004
emit_end_regions: bool = ( false , parse_bool, [ UNTRACKED ] ,
975
1005
"emit EndRegion as part of MIR; enable transforms that solely process EndRegion" ) ,
976
- borrowck_mir : bool = ( false , parse_bool , [ UNTRACKED ] ,
977
- "implicitly treat functions as if they have `#[rustc_mir_borrowck]` attribute " ) ,
1006
+ borrowck : Option < String > = ( None , parse_opt_string , [ UNTRACKED ] ,
1007
+ "select which borrowck is used (`ast`, `mir`, or `compare`) " ) ,
978
1008
time_passes: bool = ( false , parse_bool, [ UNTRACKED ] ,
979
1009
"measure time of each rustc pass" ) ,
980
1010
count_llvm_insns: bool = ( false , parse_bool,
@@ -1743,6 +1773,15 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1743
1773
}
1744
1774
} ) ) ;
1745
1775
1776
+ let borrowck_mode = match debugging_opts. borrowck . as_ref ( ) . map ( |s| & s[ ..] ) {
1777
+ None | Some ( "ast" ) => BorrowckMode :: Ast ,
1778
+ Some ( "mir" ) => BorrowckMode :: Mir ,
1779
+ Some ( "compare" ) => BorrowckMode :: Compare ,
1780
+ Some ( m) => {
1781
+ early_error ( error_format, & format ! ( "unknown borrowchk mode `{}`" , m) )
1782
+ } ,
1783
+ } ;
1784
+
1746
1785
if !cg. remark . is_empty ( ) && debuginfo == NoDebugInfo {
1747
1786
early_warn ( error_format, "-C remark will not show source locations without \
1748
1787
--debuginfo") ;
@@ -1784,6 +1823,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1784
1823
incremental,
1785
1824
debugging_opts,
1786
1825
prints,
1826
+ borrowck_mode,
1787
1827
cg,
1788
1828
error_format,
1789
1829
externs : Externs ( externs) ,
0 commit comments