@@ -149,6 +149,12 @@ pub struct Mir<'tcx> {
149149 /// This is used for the "rust-call" ABI.
150150 pub spread_arg : Option < Local > ,
151151
152+ /// Mark this MIR of a const context other than const functions as having converted a `&&` or
153+ /// `||` expression into `&` or `|` respectively. This is problematic because if we ever stop
154+ /// this conversion from happening and use short circuiting, we will cause the following code
155+ /// to change the value of `x`: `let mut x = 42; false && { x = 55; true };`
156+ pub const_can_have_let_mut_bindings : bool ,
157+
152158 /// A span representing this MIR, for error reporting
153159 pub span : Span ,
154160
@@ -167,6 +173,7 @@ impl<'tcx> Mir<'tcx> {
167173 arg_count : usize ,
168174 upvar_decls : Vec < UpvarDecl > ,
169175 span : Span ,
176+ const_can_have_let_mut_bindings : bool ,
170177 ) -> Self {
171178 // We need `arg_count` locals, and one for the return place
172179 assert ! (
@@ -191,6 +198,7 @@ impl<'tcx> Mir<'tcx> {
191198 spread_arg : None ,
192199 span,
193200 cache : cache:: Cache :: new ( ) ,
201+ const_can_have_let_mut_bindings,
194202 }
195203 }
196204
@@ -421,6 +429,7 @@ impl_stable_hash_for!(struct Mir<'tcx> {
421429 arg_count,
422430 upvar_decls,
423431 spread_arg,
432+ const_can_have_let_mut_bindings,
424433 span,
425434 cache
426435} ) ;
@@ -2974,6 +2983,7 @@ BraceStructTypeFoldableImpl! {
29742983 arg_count,
29752984 upvar_decls,
29762985 spread_arg,
2986+ const_can_have_let_mut_bindings,
29772987 span,
29782988 cache,
29792989 }
0 commit comments