@@ -145,19 +145,16 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
145145 if let ( true , Some ( borrow_temp) ) =
146146 ( tcx. emit_read_for_match ( ) , borrowed_input_temp. clone ( ) )
147147 {
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`.
155149 let pattern_source_info = self . source_info ( pattern. span ) ;
156150 self . cfg . push (
157151 * pre_binding_block,
158152 Statement {
159153 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+ ) ,
161158 } ,
162159 ) ;
163160 }
@@ -266,19 +263,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
266263 unpack ! ( block = self . into( & place, block, initializer) ) ;
267264
268265
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`.
282267 let source_info = self . source_info ( irrefutable_pat. span ) ;
283268 self . cfg . push (
284269 block,
@@ -329,9 +314,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
329314 } ,
330315 ) ;
331316
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`.
335318 self . cfg . push (
336319 block,
337320 Statement {
0 commit comments