Skip to content

Commit 507ea97

Browse files
committed
Properly name the flag for && -> & conversion
1 parent d62bcad commit 507ea97

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

src/librustc/mir/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub struct Mir<'tcx> {
153153
/// `||` expression into `&` or `|` respectively. This is problematic because if we ever stop
154154
/// this conversion from happening and use short circuiting, we will cause the following code
155155
/// to change the value of `x`: `let mut x = 42; false && { x = 55; true };`
156-
pub const_can_have_let_mut_bindings: bool,
156+
pub control_flow_destroyed: bool,
157157

158158
/// A span representing this MIR, for error reporting
159159
pub span: Span,
@@ -173,7 +173,7 @@ impl<'tcx> Mir<'tcx> {
173173
arg_count: usize,
174174
upvar_decls: Vec<UpvarDecl>,
175175
span: Span,
176-
const_can_have_let_mut_bindings: bool,
176+
control_flow_destroyed: bool,
177177
) -> Self {
178178
// We need `arg_count` locals, and one for the return place
179179
assert!(
@@ -198,7 +198,7 @@ impl<'tcx> Mir<'tcx> {
198198
spread_arg: None,
199199
span,
200200
cache: cache::Cache::new(),
201-
const_can_have_let_mut_bindings,
201+
control_flow_destroyed,
202202
}
203203
}
204204

@@ -429,7 +429,7 @@ impl_stable_hash_for!(struct Mir<'tcx> {
429429
arg_count,
430430
upvar_decls,
431431
spread_arg,
432-
const_can_have_let_mut_bindings,
432+
control_flow_destroyed,
433433
span,
434434
cache
435435
});
@@ -2983,7 +2983,7 @@ BraceStructTypeFoldableImpl! {
29832983
arg_count,
29842984
upvar_decls,
29852985
spread_arg,
2986-
const_can_have_let_mut_bindings,
2986+
control_flow_destroyed,
29872987
span,
29882988
cache,
29892989
}

src/librustc_mir/build/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
864864
self.arg_count,
865865
self.upvar_decls,
866866
self.fn_span,
867-
self.hir.const_can_have_let_mut_bindings(),
867+
self.hir.control_flow_destroyed(),
868868
)
869869
}
870870

src/librustc_mir/hair/cx/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,15 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
372372
// FIXME(eddyb) use logical ops in constants when
373373
// they can handle that kind of control-flow.
374374
(hir::BinOpKind::And, hir::Constness::Const) => {
375-
cx.const_can_have_let_mut_bindings = false;
375+
cx.control_flow_destroyed = true;
376376
ExprKind::Binary {
377377
op: BinOp::BitAnd,
378378
lhs: lhs.to_ref(),
379379
rhs: rhs.to_ref(),
380380
}
381381
}
382382
(hir::BinOpKind::Or, hir::Constness::Const) => {
383-
cx.const_can_have_let_mut_bindings = false;
383+
cx.control_flow_destroyed = true;
384384
ExprKind::Binary {
385385
op: BinOp::BitOr,
386386
lhs: lhs.to_ref(),

src/librustc_mir/hair/cx/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
5858
check_overflow: bool,
5959

6060
/// See field with the same name on `Mir`
61-
const_can_have_let_mut_bindings: bool,
61+
control_flow_destroyed: bool,
6262
}
6363

6464
impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
@@ -99,12 +99,12 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
9999
constness,
100100
body_owner_kind,
101101
check_overflow,
102-
const_can_have_let_mut_bindings: true,
102+
control_flow_destroyed: false,
103103
}
104104
}
105105

106-
pub fn const_can_have_let_mut_bindings(&self) -> bool {
107-
self.const_can_have_let_mut_bindings
106+
pub fn control_flow_destroyed(&self) -> bool {
107+
self.control_flow_destroyed
108108
}
109109
}
110110

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ impl MirPass for QualifyAndPromoteConstants {
11831183
// Do the actual promotion, now that we know what's viable.
11841184
promote_consts::promote_candidates(mir, tcx, temps, candidates);
11851185
} else {
1186-
if !mir.const_can_have_let_mut_bindings {
1186+
if mir.control_flow_destroyed {
11871187
for local in mir.mut_vars_iter() {
11881188
let span = mir.local_decls[local].source_info.span;
11891189
tcx.sess.span_err(

0 commit comments

Comments
 (0)