Skip to content

Commit d11b871

Browse files
authored
Rollup merge of rust-lang#60400 - JohnTitor:simplify-feature, r=matthewjasper
Remove functions to simplify handling of feature(bind_by_move_pattern_guards) Fixes rust-lang#59192 r? @matthewjasper
2 parents ebb6561 + 4945594 commit d11b871

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

src/librustc/ty/context.rs

-20
Original file line numberDiff line numberDiff line change
@@ -1486,26 +1486,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
14861486
self.queries.on_disk_cache.serialize(self.global_tcx(), encoder)
14871487
}
14881488

1489-
/// This checks whether one is allowed to have pattern bindings
1490-
/// that bind-by-move on a match arm that has a guard, e.g.:
1491-
///
1492-
/// ```rust
1493-
/// match foo { A(inner) if { /* something */ } => ..., ... }
1494-
/// ```
1495-
///
1496-
/// It is separate from check_for_mutation_in_guard_via_ast_walk,
1497-
/// because that method has a narrower effect that can be toggled
1498-
/// off via a separate `-Z` flag, at least for the short term.
1499-
pub fn allow_bind_by_move_patterns_with_guards(self) -> bool {
1500-
self.features().bind_by_move_pattern_guards
1501-
}
1502-
1503-
/// If true, we should use a naive AST walk to determine if match
1504-
/// guard could perform bad mutations (or mutable-borrows).
1505-
pub fn check_for_mutation_in_guard_via_ast_walk(self) -> bool {
1506-
!self.allow_bind_by_move_patterns_with_guards()
1507-
}
1508-
15091489
/// If true, we should use the AST-based borrowck (we may *also* use
15101490
/// the MIR-based borrowck).
15111491
pub fn use_ast_borrowck(self) -> bool {

src/librustc_mir/hair/pattern/check_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
147147
// Second, if there is a guard on each arm, make sure it isn't
148148
// assigning or borrowing anything mutably.
149149
if let Some(ref guard) = arm.guard {
150-
if self.tcx.check_for_mutation_in_guard_via_ast_walk() {
150+
if !self.tcx.features().bind_by_move_pattern_guards {
151151
check_for_mutation_in_guard(self, &guard);
152152
}
153153
}
@@ -562,7 +562,7 @@ fn check_legality_of_move_bindings(
562562
"cannot bind by-move with sub-bindings")
563563
.span_label(p.span, "binds an already bound by-move value by moving it")
564564
.emit();
565-
} else if has_guard && !cx.tcx.allow_bind_by_move_patterns_with_guards() {
565+
} else if has_guard && !cx.tcx.features().bind_by_move_pattern_guards {
566566
let mut err = struct_span_err!(cx.tcx.sess, p.span, E0008,
567567
"cannot bind by-move into a pattern guard");
568568
err.span_label(p.span, "moves value into pattern guard");

0 commit comments

Comments
 (0)