Properly name the flag for && -> & conversion
This commit is contained in:
parent
d62bcad38d
commit
507ea97a3e
5 changed files with 13 additions and 13 deletions
|
|
@ -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<UpvarDecl>,
|
||||
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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue