@@ -68,7 +68,6 @@ use rustc_target::spec::abi;
6868use syntax:: ast;
6969use syntax:: attr;
7070use syntax:: source_map:: MultiSpan ;
71- use syntax:: edition:: Edition ;
7271use syntax:: feature_gate;
7372use syntax:: symbol:: { Symbol , keywords, InternedString } ;
7473use syntax_pos:: Span ;
@@ -1472,21 +1471,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
14721471 /// because that method has a narrower effect that can be toggled
14731472 /// off via a separate `-Z` flag, at least for the short term.
14741473 pub fn allow_bind_by_move_patterns_with_guards ( self ) -> bool {
1475- self . features ( ) . bind_by_move_pattern_guards && self . use_mir_borrowck ( )
1474+ self . features ( ) . bind_by_move_pattern_guards
14761475 }
14771476
14781477 /// If true, we should use a naive AST walk to determine if match
14791478 /// guard could perform bad mutations (or mutable-borrows).
14801479 pub fn check_for_mutation_in_guard_via_ast_walk ( self ) -> bool {
1481- // If someone requests the feature, then be a little more
1482- // careful and ensure that MIR-borrowck is enabled (which can
1483- // happen via edition selection, via `feature(nll)`, or via an
1484- // appropriate `-Z` flag) before disabling the mutation check.
1485- if self . allow_bind_by_move_patterns_with_guards ( ) {
1486- return false ;
1487- }
1488-
1489- return true ;
1480+ !self . allow_bind_by_move_patterns_with_guards ( )
14901481 }
14911482
14921483 /// If true, we should use the AST-based borrowck (we may *also* use
@@ -1495,12 +1486,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
14951486 self . borrowck_mode ( ) . use_ast ( )
14961487 }
14971488
1498- /// If true, we should use the MIR-based borrowck (we may *also* use
1499- /// the AST-based borrowck).
1500- pub fn use_mir_borrowck ( self ) -> bool {
1501- self . borrowck_mode ( ) . use_mir ( )
1502- }
1503-
15041489 /// If true, we should use the MIR-based borrow check, but also
15051490 /// fall back on the AST borrow check if the MIR-based one errors.
15061491 pub fn migrate_borrowck ( self ) -> bool {
@@ -1517,38 +1502,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
15171502 /// statements (which simulate the maximal effect of executing the
15181503 /// patterns in a match arm).
15191504 pub fn emit_read_for_match ( & self ) -> bool {
1520- self . use_mir_borrowck ( ) && !self . sess . opts . debugging_opts . nll_dont_emit_read_for_match
1521- }
1522-
1523- /// If true, pattern variables for use in guards on match arms
1524- /// will be bound as references to the data, and occurrences of
1525- /// those variables in the guard expression will implicitly
1526- /// dereference those bindings. (See rust-lang/rust#27282.)
1527- pub fn all_pat_vars_are_implicit_refs_within_guards ( self ) -> bool {
1528- self . borrowck_mode ( ) . use_mir ( )
1529- }
1530-
1531- /// If true, we should enable two-phase borrows checks. This is
1532- /// done with either: `-Ztwo-phase-borrows`, `#![feature(nll)]`,
1533- /// or by opting into an edition after 2015.
1534- pub fn two_phase_borrows ( self ) -> bool {
1535- self . sess . rust_2018 ( ) || self . features ( ) . nll ||
1536- self . sess . opts . debugging_opts . two_phase_borrows
1505+ !self . sess . opts . debugging_opts . nll_dont_emit_read_for_match
15371506 }
15381507
15391508 /// What mode(s) of borrowck should we run? AST? MIR? both?
15401509 /// (Also considers the `#![feature(nll)]` setting.)
15411510 pub fn borrowck_mode ( & self ) -> BorrowckMode {
15421511 // Here are the main constraints we need to deal with:
15431512 //
1544- // 1. An opts.borrowck_mode of `BorrowckMode::Ast ` is
1513+ // 1. An opts.borrowck_mode of `BorrowckMode::Migrate ` is
15451514 // synonymous with no `-Z borrowck=...` flag at all.
1546- // (This is arguably a historical accident.)
1547- //
1548- // 2. `BorrowckMode::Migrate` is the limited migration to
1549- // NLL that we are deploying with the 2018 edition.
15501515 //
1551- // 3 . We want to allow developers on the Nightly channel
1516+ // 2 . We want to allow developers on the Nightly channel
15521517 // to opt back into the "hard error" mode for NLL,
15531518 // (which they can do via specifying `#![feature(nll)]`
15541519 // explicitly in their crate).
@@ -1561,24 +1526,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
15611526 // a user's attempt to specify `-Z borrowck=compare`, which
15621527 // we arguably do not need anymore and should remove.)
15631528 //
1564- // * Otherwise, if no `-Z borrowck=...` flag was given (or
1565- // if `borrowck=ast` was specified), then use the default
1566- // as required by the edition.
1529+ // * Otherwise, if no `-Z borrowck=...` then use migrate mode
15671530 //
15681531 // * Otherwise, use the behavior requested via `-Z borrowck=...`
15691532
15701533 if self . features ( ) . nll { return BorrowckMode :: Mir ; }
15711534
1572- match self . sess . opts . borrowck_mode {
1573- mode @ BorrowckMode :: Mir |
1574- mode @ BorrowckMode :: Compare |
1575- mode @ BorrowckMode :: Migrate => mode,
1576-
1577- BorrowckMode :: Ast => match self . sess . edition ( ) {
1578- Edition :: Edition2015 => BorrowckMode :: Ast ,
1579- Edition :: Edition2018 => BorrowckMode :: Migrate ,
1580- } ,
1581- }
1535+ self . sess . opts . borrowck_mode
15821536 }
15831537
15841538 #[ inline]
0 commit comments