@@ -145,19 +145,16 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
145
145
if let ( true , Some ( borrow_temp) ) =
146
146
( tcx. emit_read_for_match ( ) , borrowed_input_temp. clone ( ) )
147
147
{
148
- // inject a fake read of the borrowed input at
149
- // the start of each arm's pattern testing
150
- // code.
151
- //
152
- // This should ensure that you cannot change
153
- // the variant for an enum while you are in
154
- // the midst of matching on it.
148
+ // Inject a fake read, see comments on `FakeReadCause::ForMatch`.
155
149
let pattern_source_info = self . source_info ( pattern. span ) ;
156
150
self . cfg . push (
157
151
* pre_binding_block,
158
152
Statement {
159
153
source_info : pattern_source_info,
160
- kind : StatementKind :: FakeRead ( FakeReadCause :: ForMatch , borrow_temp. clone ( ) ) ,
154
+ kind : StatementKind :: FakeRead (
155
+ FakeReadCause :: ForMatch ,
156
+ borrow_temp. clone ( ) ,
157
+ ) ,
161
158
} ,
162
159
) ;
163
160
}
@@ -266,19 +263,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
266
263
unpack ! ( block = self . into( & place, block, initializer) ) ;
267
264
268
265
269
- // Officially, the semantics of
270
- //
271
- // `let pattern = <expr>;`
272
- //
273
- // is that `<expr>` is evaluated into a temporary and then this temporary is
274
- // into the pattern.
275
- //
276
- // However, if we see the simple pattern `let var = <expr>`, we optimize this to
277
- // evaluate `<expr>` directly into the variable `var`. This is mostly unobservable,
278
- // but in some cases it can affect the borrow checker, as in #53695.
279
- // Therefore, we insert a "fake read" here to ensure that we get
280
- // appropriate errors.
281
- //
266
+ // Inject a fake read, see comments on `FakeReadCause::ForLet`.
282
267
let source_info = self . source_info ( irrefutable_pat. span ) ;
283
268
self . cfg . push (
284
269
block,
@@ -329,9 +314,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
329
314
} ,
330
315
) ;
331
316
332
- // Similarly to the `let var = <expr>` case, we insert a "fake read" here to
333
- // ensure that we get appropriate errors when this usually unobservable
334
- // optimization affects the borrow checker.
317
+ // Inject a fake read, see comments on `FakeReadCause::ForLet`.
335
318
self . cfg . push (
336
319
block,
337
320
Statement {
0 commit comments