@@ -68,7 +68,6 @@ use rustc_target::spec::abi;
68
68
use syntax:: ast;
69
69
use syntax:: attr;
70
70
use syntax:: source_map:: MultiSpan ;
71
- use syntax:: edition:: Edition ;
72
71
use syntax:: feature_gate;
73
72
use syntax:: symbol:: { Symbol , keywords, InternedString } ;
74
73
use syntax_pos:: Span ;
@@ -1472,21 +1471,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1472
1471
/// because that method has a narrower effect that can be toggled
1473
1472
/// off via a separate `-Z` flag, at least for the short term.
1474
1473
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
1476
1475
}
1477
1476
1478
1477
/// If true, we should use a naive AST walk to determine if match
1479
1478
/// guard could perform bad mutations (or mutable-borrows).
1480
1479
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 ( )
1490
1481
}
1491
1482
1492
1483
/// 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> {
1495
1486
self . borrowck_mode ( ) . use_ast ( )
1496
1487
}
1497
1488
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
-
1504
1489
/// If true, we should use the MIR-based borrow check, but also
1505
1490
/// fall back on the AST borrow check if the MIR-based one errors.
1506
1491
pub fn migrate_borrowck ( self ) -> bool {
@@ -1517,38 +1502,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1517
1502
/// statements (which simulate the maximal effect of executing the
1518
1503
/// patterns in a match arm).
1519
1504
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
1537
1506
}
1538
1507
1539
1508
/// What mode(s) of borrowck should we run? AST? MIR? both?
1540
1509
/// (Also considers the `#![feature(nll)]` setting.)
1541
1510
pub fn borrowck_mode ( & self ) -> BorrowckMode {
1542
1511
// Here are the main constraints we need to deal with:
1543
1512
//
1544
- // 1. An opts.borrowck_mode of `BorrowckMode::Ast ` is
1513
+ // 1. An opts.borrowck_mode of `BorrowckMode::Migrate ` is
1545
1514
// 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.
1550
1515
//
1551
- // 3 . We want to allow developers on the Nightly channel
1516
+ // 2 . We want to allow developers on the Nightly channel
1552
1517
// to opt back into the "hard error" mode for NLL,
1553
1518
// (which they can do via specifying `#![feature(nll)]`
1554
1519
// explicitly in their crate).
@@ -1561,24 +1526,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1561
1526
// a user's attempt to specify `-Z borrowck=compare`, which
1562
1527
// we arguably do not need anymore and should remove.)
1563
1528
//
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
1567
1530
//
1568
1531
// * Otherwise, use the behavior requested via `-Z borrowck=...`
1569
1532
1570
1533
if self . features ( ) . nll { return BorrowckMode :: Mir ; }
1571
1534
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
1582
1536
}
1583
1537
1584
1538
#[ inline]
0 commit comments