@@ -70,7 +70,6 @@ use rustc_macros::HashStable;
7070use syntax:: ast;
7171use syntax:: attr;
7272use syntax:: source_map:: MultiSpan ;
73- use syntax:: edition:: Edition ;
7473use syntax:: feature_gate;
7574use syntax:: symbol:: { Symbol , keywords, InternedString } ;
7675use syntax_pos:: Span ;
@@ -1496,21 +1495,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
14961495 /// because that method has a narrower effect that can be toggled
14971496 /// off via a separate `-Z` flag, at least for the short term.
14981497 pub fn allow_bind_by_move_patterns_with_guards ( self ) -> bool {
1499- self . features ( ) . bind_by_move_pattern_guards && self . use_mir_borrowck ( )
1498+ self . features ( ) . bind_by_move_pattern_guards
15001499 }
15011500
15021501 /// If true, we should use a naive AST walk to determine if match
15031502 /// guard could perform bad mutations (or mutable-borrows).
15041503 pub fn check_for_mutation_in_guard_via_ast_walk ( self ) -> bool {
1505- // If someone requests the feature, then be a little more
1506- // careful and ensure that MIR-borrowck is enabled (which can
1507- // happen via edition selection, via `feature(nll)`, or via an
1508- // appropriate `-Z` flag) before disabling the mutation check.
1509- if self . allow_bind_by_move_patterns_with_guards ( ) {
1510- return false ;
1511- }
1512-
1513- return true ;
1504+ !self . allow_bind_by_move_patterns_with_guards ( )
15141505 }
15151506
15161507 /// If true, we should use the AST-based borrowck (we may *also* use
@@ -1519,12 +1510,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
15191510 self . borrowck_mode ( ) . use_ast ( )
15201511 }
15211512
1522- /// If true, we should use the MIR-based borrowck (we may *also* use
1523- /// the AST-based borrowck).
1524- pub fn use_mir_borrowck ( self ) -> bool {
1525- self . borrowck_mode ( ) . use_mir ( )
1526- }
1527-
15281513 /// If true, we should use the MIR-based borrow check, but also
15291514 /// fall back on the AST borrow check if the MIR-based one errors.
15301515 pub fn migrate_borrowck ( self ) -> bool {
@@ -1541,38 +1526,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
15411526 /// statements (which simulate the maximal effect of executing the
15421527 /// patterns in a match arm).
15431528 pub fn emit_read_for_match ( & self ) -> bool {
1544- self . use_mir_borrowck ( ) && !self . sess . opts . debugging_opts . nll_dont_emit_read_for_match
1545- }
1546-
1547- /// If true, pattern variables for use in guards on match arms
1548- /// will be bound as references to the data, and occurrences of
1549- /// those variables in the guard expression will implicitly
1550- /// dereference those bindings. (See rust-lang/rust#27282.)
1551- pub fn all_pat_vars_are_implicit_refs_within_guards ( self ) -> bool {
1552- self . borrowck_mode ( ) . use_mir ( )
1553- }
1554-
1555- /// If true, we should enable two-phase borrows checks. This is
1556- /// done with either: `-Ztwo-phase-borrows`, `#![feature(nll)]`,
1557- /// or by opting into an edition after 2015.
1558- pub fn two_phase_borrows ( self ) -> bool {
1559- self . sess . rust_2018 ( ) || self . features ( ) . nll ||
1560- self . sess . opts . debugging_opts . two_phase_borrows
1529+ !self . sess . opts . debugging_opts . nll_dont_emit_read_for_match
15611530 }
15621531
15631532 /// What mode(s) of borrowck should we run? AST? MIR? both?
15641533 /// (Also considers the `#![feature(nll)]` setting.)
15651534 pub fn borrowck_mode ( & self ) -> BorrowckMode {
15661535 // Here are the main constraints we need to deal with:
15671536 //
1568- // 1. An opts.borrowck_mode of `BorrowckMode::Ast ` is
1537+ // 1. An opts.borrowck_mode of `BorrowckMode::Migrate ` is
15691538 // synonymous with no `-Z borrowck=...` flag at all.
1570- // (This is arguably a historical accident.)
1571- //
1572- // 2. `BorrowckMode::Migrate` is the limited migration to
1573- // NLL that we are deploying with the 2018 edition.
15741539 //
1575- // 3 . We want to allow developers on the Nightly channel
1540+ // 2 . We want to allow developers on the Nightly channel
15761541 // to opt back into the "hard error" mode for NLL,
15771542 // (which they can do via specifying `#![feature(nll)]`
15781543 // explicitly in their crate).
@@ -1585,24 +1550,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
15851550 // a user's attempt to specify `-Z borrowck=compare`, which
15861551 // we arguably do not need anymore and should remove.)
15871552 //
1588- // * Otherwise, if no `-Z borrowck=...` flag was given (or
1589- // if `borrowck=ast` was specified), then use the default
1590- // as required by the edition.
1553+ // * Otherwise, if no `-Z borrowck=...` then use migrate mode
15911554 //
15921555 // * Otherwise, use the behavior requested via `-Z borrowck=...`
15931556
15941557 if self . features ( ) . nll { return BorrowckMode :: Mir ; }
15951558
1596- match self . sess . opts . borrowck_mode {
1597- mode @ BorrowckMode :: Mir |
1598- mode @ BorrowckMode :: Compare |
1599- mode @ BorrowckMode :: Migrate => mode,
1600-
1601- BorrowckMode :: Ast => match self . sess . edition ( ) {
1602- Edition :: Edition2015 => BorrowckMode :: Ast ,
1603- Edition :: Edition2018 => BorrowckMode :: Migrate ,
1604- } ,
1605- }
1559+ self . sess . opts . borrowck_mode
16061560 }
16071561
16081562 #[ inline]
0 commit comments