@@ -70,7 +70,6 @@ use rustc_macros::HashStable;
70
70
use syntax:: ast;
71
71
use syntax:: attr;
72
72
use syntax:: source_map:: MultiSpan ;
73
- use syntax:: edition:: Edition ;
74
73
use syntax:: feature_gate;
75
74
use syntax:: symbol:: { Symbol , keywords, InternedString } ;
76
75
use syntax_pos:: Span ;
@@ -1496,21 +1495,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1496
1495
/// because that method has a narrower effect that can be toggled
1497
1496
/// off via a separate `-Z` flag, at least for the short term.
1498
1497
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
1500
1499
}
1501
1500
1502
1501
/// If true, we should use a naive AST walk to determine if match
1503
1502
/// guard could perform bad mutations (or mutable-borrows).
1504
1503
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 ( )
1514
1505
}
1515
1506
1516
1507
/// 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> {
1519
1510
self . borrowck_mode ( ) . use_ast ( )
1520
1511
}
1521
1512
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
-
1528
1513
/// If true, we should use the MIR-based borrow check, but also
1529
1514
/// fall back on the AST borrow check if the MIR-based one errors.
1530
1515
pub fn migrate_borrowck ( self ) -> bool {
@@ -1541,38 +1526,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1541
1526
/// statements (which simulate the maximal effect of executing the
1542
1527
/// patterns in a match arm).
1543
1528
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
1561
1530
}
1562
1531
1563
1532
/// What mode(s) of borrowck should we run? AST? MIR? both?
1564
1533
/// (Also considers the `#![feature(nll)]` setting.)
1565
1534
pub fn borrowck_mode ( & self ) -> BorrowckMode {
1566
1535
// Here are the main constraints we need to deal with:
1567
1536
//
1568
- // 1. An opts.borrowck_mode of `BorrowckMode::Ast ` is
1537
+ // 1. An opts.borrowck_mode of `BorrowckMode::Migrate ` is
1569
1538
// 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.
1574
1539
//
1575
- // 3 . We want to allow developers on the Nightly channel
1540
+ // 2 . We want to allow developers on the Nightly channel
1576
1541
// to opt back into the "hard error" mode for NLL,
1577
1542
// (which they can do via specifying `#![feature(nll)]`
1578
1543
// explicitly in their crate).
@@ -1585,24 +1550,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1585
1550
// a user's attempt to specify `-Z borrowck=compare`, which
1586
1551
// we arguably do not need anymore and should remove.)
1587
1552
//
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
1591
1554
//
1592
1555
// * Otherwise, use the behavior requested via `-Z borrowck=...`
1593
1556
1594
1557
if self . features ( ) . nll { return BorrowckMode :: Mir ; }
1595
1558
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
1606
1560
}
1607
1561
1608
1562
#[ inline]
0 commit comments