From 507ea97a3e245887bc8cbea0f0fe8474d082bd0e Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Mon, 26 Nov 2018 09:35:23 +0100 Subject: [PATCH] Properly name the flag for `&&` -> `&` conversion --- src/librustc/mir/mod.rs | 10 +++++----- src/librustc_mir/build/mod.rs | 2 +- src/librustc_mir/hair/cx/expr.rs | 4 ++-- src/librustc_mir/hair/cx/mod.rs | 8 ++++---- src/librustc_mir/transform/qualify_consts.rs | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index a82a7b555a05..3968d9aece21 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -153,7 +153,7 @@ pub struct Mir<'tcx> { /// `||` expression into `&` or `|` respectively. This is problematic because if we ever stop /// this conversion from happening and use short circuiting, we will cause the following code /// to change the value of `x`: `let mut x = 42; false && { x = 55; true };` - pub const_can_have_let_mut_bindings: bool, + pub control_flow_destroyed: bool, /// A span representing this MIR, for error reporting pub span: Span, @@ -173,7 +173,7 @@ impl<'tcx> Mir<'tcx> { arg_count: usize, upvar_decls: Vec, span: Span, - const_can_have_let_mut_bindings: bool, + control_flow_destroyed: bool, ) -> Self { // We need `arg_count` locals, and one for the return place assert!( @@ -198,7 +198,7 @@ impl<'tcx> Mir<'tcx> { spread_arg: None, span, cache: cache::Cache::new(), - const_can_have_let_mut_bindings, + control_flow_destroyed, } } @@ -429,7 +429,7 @@ impl_stable_hash_for!(struct Mir<'tcx> { arg_count, upvar_decls, spread_arg, - const_can_have_let_mut_bindings, + control_flow_destroyed, span, cache }); @@ -2983,7 +2983,7 @@ BraceStructTypeFoldableImpl! { arg_count, upvar_decls, spread_arg, - const_can_have_let_mut_bindings, + control_flow_destroyed, span, cache, } diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index ab19cd9dd5be..80cab0cf6868 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -864,7 +864,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { self.arg_count, self.upvar_decls, self.fn_span, - self.hir.const_can_have_let_mut_bindings(), + self.hir.control_flow_destroyed(), ) } diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 951651aa1ce1..5acff380f284 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -372,7 +372,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, // FIXME(eddyb) use logical ops in constants when // they can handle that kind of control-flow. (hir::BinOpKind::And, hir::Constness::Const) => { - cx.const_can_have_let_mut_bindings = false; + cx.control_flow_destroyed = true; ExprKind::Binary { op: BinOp::BitAnd, lhs: lhs.to_ref(), @@ -380,7 +380,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } (hir::BinOpKind::Or, hir::Constness::Const) => { - cx.const_can_have_let_mut_bindings = false; + cx.control_flow_destroyed = true; ExprKind::Binary { op: BinOp::BitOr, lhs: lhs.to_ref(), diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 8ee1eac0e331..76dde4ed02bc 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -58,7 +58,7 @@ pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { check_overflow: bool, /// See field with the same name on `Mir` - const_can_have_let_mut_bindings: bool, + control_flow_destroyed: bool, } impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { @@ -99,12 +99,12 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { constness, body_owner_kind, check_overflow, - const_can_have_let_mut_bindings: true, + control_flow_destroyed: false, } } - pub fn const_can_have_let_mut_bindings(&self) -> bool { - self.const_can_have_let_mut_bindings + pub fn control_flow_destroyed(&self) -> bool { + self.control_flow_destroyed } } diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 8eae45376642..b9c33ae8c1af 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -1183,7 +1183,7 @@ impl MirPass for QualifyAndPromoteConstants { // Do the actual promotion, now that we know what's viable. promote_consts::promote_candidates(mir, tcx, temps, candidates); } else { - if !mir.const_can_have_let_mut_bindings { + if mir.control_flow_destroyed { for local in mir.mut_vars_iter() { let span = mir.local_decls[local].source_info.span; tcx.sess.span_err(