1 //! See docs in build/expr/mod.rs
3 use crate::build::expr::category::Category;
4 use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
5 use crate::build::{BlockAnd, BlockAndExtension, Builder, Capture, CaptureMap};
6 use rustc_hir::def_id::LocalDefId;
7 use rustc_middle::hir::place::Projection as HirProjection;
8 use rustc_middle::hir::place::ProjectionKind as HirProjectionKind;
9 use rustc_middle::middle::region;
10 use rustc_middle::mir::AssertKind::BoundsCheck;
11 use rustc_middle::mir::*;
12 use rustc_middle::thir::*;
13 use rustc_middle::ty::AdtDef;
14 use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt, Variance};
16 use rustc_target::abi::VariantIdx;
18 use rustc_index::vec::Idx;
20 use std::assert_matches::assert_matches;
23 /// The "outermost" place that holds this value.
24 #[derive(Copy, Clone, Debug, PartialEq)]
25 pub(crate) enum PlaceBase {
26 /// Denotes the start of a `Place`.
29 /// When building place for an expression within a closure, the place might start off a
30 /// captured path. When `capture_disjoint_fields` is enabled, we might not know the capture
31 /// index (within the desugared closure) of the captured path until most of the projections
32 /// are applied. We use `PlaceBase::Upvar` to keep track of the root variable off of which the
33 /// captured path starts, the closure the capture belongs to and the trait the closure
36 /// Once we have figured out the capture index, we can convert the place builder to start from
37 /// `PlaceBase::Local`.
39 /// Consider the following example
41 /// let t = (((10, 10), 10), 10);
44 /// println!("{}", t.0.0.0);
47 /// Here the THIR expression for `t.0.0.0` will be something like
49 /// ```ignore (illustrative)
56 /// When `capture_disjoint_fields` is enabled, `t.0.0.0` is captured and we won't be able to
57 /// figure out that it is captured until all the `Field` projections are applied.
59 /// HirId of the upvar
60 var_hir_id: LocalVarId,
61 /// DefId of the closure
62 closure_def_id: LocalDefId,
66 /// `PlaceBuilder` is used to create places during MIR construction. It allows you to "build up" a
67 /// place by pushing more and more projections onto the end, and then convert the final set into a
68 /// place using the `into_place` method.
70 /// This is used internally when building a place for an expression like `a.b.c`. The fields `b`
71 /// and `c` can be progressively pushed onto the place builder that is created when converting `a`.
72 #[derive(Clone, Debug, PartialEq)]
73 pub(in crate::build) struct PlaceBuilder<'tcx> {
75 projection: Vec<PlaceElem<'tcx>>,
78 /// Given a list of MIR projections, convert them to list of HIR ProjectionKind.
79 /// The projections are truncated to represent a path that might be captured by a
80 /// closure/generator. This implies the vector returned from this function doesn't contain
81 /// ProjectionElems `Downcast`, `ConstantIndex`, `Index`, or `Subslice` because those will never be
82 /// part of a path that is captured by a closure. We stop applying projections once we see the first
83 /// projection that isn't captured by a closure.
84 fn convert_to_hir_projections_and_truncate_for_capture<'tcx>(
85 mir_projections: &[PlaceElem<'tcx>],
86 ) -> Vec<HirProjectionKind> {
87 let mut hir_projections = Vec::new();
88 let mut variant = None;
90 for mir_projection in mir_projections {
91 let hir_projection = match mir_projection {
92 ProjectionElem::Deref => HirProjectionKind::Deref,
93 ProjectionElem::Field(field, _) => {
94 let variant = variant.unwrap_or(VariantIdx::new(0));
95 HirProjectionKind::Field(field.index() as u32, variant)
97 ProjectionElem::Downcast(.., idx) => {
98 // We don't expect to see multi-variant enums here, as earlier
99 // phases will have truncated them already. However, there can
100 // still be downcasts, thanks to single-variant enums.
101 // We keep track of VariantIdx so we can use this information
102 // if the next ProjectionElem is a Field.
103 variant = Some(*idx);
106 // These do not affect anything, they just make sure we know the right type.
107 ProjectionElem::OpaqueCast(_) => continue,
108 ProjectionElem::Index(..)
109 | ProjectionElem::ConstantIndex { .. }
110 | ProjectionElem::Subslice { .. } => {
111 // We don't capture array-access projections.
112 // We can stop here as arrays are captured completely.
117 hir_projections.push(hir_projection);
123 /// Return true if the `proj_possible_ancestor` represents an ancestor path
124 /// to `proj_capture` or `proj_possible_ancestor` is same as `proj_capture`,
125 /// assuming they both start off of the same root variable.
127 /// **Note:** It's the caller's responsibility to ensure that both lists of projections
128 /// start off of the same root variable.
130 /// Eg: 1. `foo.x` which is represented using `projections=[Field(x)]` is an ancestor of
131 /// `foo.x.y` which is represented using `projections=[Field(x), Field(y)]`.
132 /// Note both `foo.x` and `foo.x.y` start off of the same root variable `foo`.
133 /// 2. Since we only look at the projections here function will return `bar.x` as an a valid
134 /// ancestor of `foo.x.y`. It's the caller's responsibility to ensure that both projections
135 /// list are being applied to the same root variable.
136 fn is_ancestor_or_same_capture(
137 proj_possible_ancestor: &[HirProjectionKind],
138 proj_capture: &[HirProjectionKind],
140 // We want to make sure `is_ancestor_or_same_capture("x.0.0", "x.0")` to return false.
141 // Therefore we can't just check if all projections are same in the zipped iterator below.
142 if proj_possible_ancestor.len() > proj_capture.len() {
146 iter::zip(proj_possible_ancestor, proj_capture).all(|(a, b)| a == b)
149 /// Given a closure, returns the index of a capture within the desugared closure struct and the
150 /// `ty::CapturedPlace` which is the ancestor of the Place represented using the `var_hir_id`
151 /// and `projection`.
153 /// Note there will be at most one ancestor for any given Place.
155 /// Returns None, when the ancestor is not found.
156 fn find_capture_matching_projections<'a, 'tcx>(
157 upvars: &'a CaptureMap<'tcx>,
158 var_hir_id: LocalVarId,
159 projections: &[PlaceElem<'tcx>],
160 ) -> Option<(usize, &'a Capture<'tcx>)> {
161 let hir_projections = convert_to_hir_projections_and_truncate_for_capture(projections);
163 upvars.get_by_key_enumerated(var_hir_id.0).find(|(_, capture)| {
164 let possible_ancestor_proj_kinds: Vec<_> =
165 capture.captured_place.place.projections.iter().map(|proj| proj.kind).collect();
166 is_ancestor_or_same_capture(&possible_ancestor_proj_kinds, &hir_projections)
170 /// Takes a PlaceBuilder and resolves the upvar (if any) within it, so that the
171 /// `PlaceBuilder` now starts from `PlaceBase::Local`.
173 /// Returns a Result with the error being the PlaceBuilder (`from_builder`) that was not found.
174 #[instrument(level = "trace", skip(cx), ret)]
175 fn to_upvars_resolved_place_builder<'tcx>(
176 from_builder: PlaceBuilder<'tcx>,
177 cx: &Builder<'_, 'tcx>,
178 ) -> Result<PlaceBuilder<'tcx>, PlaceBuilder<'tcx>> {
179 match from_builder.base {
180 PlaceBase::Local(_) => Ok(from_builder),
181 PlaceBase::Upvar { var_hir_id, closure_def_id } => {
182 let Some((capture_index, capture)) =
183 find_capture_matching_projections(
186 &from_builder.projection,
188 let closure_span = cx.tcx.def_span(closure_def_id);
189 if !enable_precise_capture(cx.tcx, closure_span) {
191 "No associated capture found for {:?}[{:#?}] even though \
192 capture_disjoint_fields isn't enabled",
194 from_builder.projection
198 "No associated capture found for {:?}[{:#?}]",
199 var_hir_id, from_builder.projection,
202 return Err(from_builder);
205 // Access the capture by accessing the field within the Closure struct.
206 let capture_info = &cx.upvars[capture_index];
208 let mut upvar_resolved_place_builder = PlaceBuilder::from(capture_info.use_place);
210 // We used some of the projections to build the capture itself,
211 // now we apply the remaining to the upvar resolved place.
212 trace!(?capture.captured_place, ?from_builder.projection);
213 let remaining_projections = strip_prefix(
214 capture.captured_place.place.base_ty,
215 from_builder.projection,
216 &capture.captured_place.place.projections,
218 upvar_resolved_place_builder.projection.extend(remaining_projections);
220 Ok(upvar_resolved_place_builder)
225 /// Returns projections remaining after stripping an initial prefix of HIR
228 /// Supports only HIR projection kinds that represent a path that might be
229 /// captured by a closure or a generator, i.e., an `Index` or a `Subslice`
230 /// projection kinds are unsupported.
231 fn strip_prefix<'tcx>(
232 mut base_ty: Ty<'tcx>,
233 projections: Vec<PlaceElem<'tcx>>,
234 prefix_projections: &[HirProjection<'tcx>],
235 ) -> impl Iterator<Item = PlaceElem<'tcx>> {
236 let mut iter = projections
238 // Filter out opaque casts, they are unnecessary in the prefix.
239 .filter(|elem| !matches!(elem, ProjectionElem::OpaqueCast(..)));
240 for projection in prefix_projections {
241 match projection.kind {
242 HirProjectionKind::Deref => {
243 assert_matches!(iter.next(), Some(ProjectionElem::Deref));
245 HirProjectionKind::Field(..) => {
246 if base_ty.is_enum() {
247 assert_matches!(iter.next(), Some(ProjectionElem::Downcast(..)));
249 assert_matches!(iter.next(), Some(ProjectionElem::Field(..)));
251 HirProjectionKind::Index | HirProjectionKind::Subslice => {
252 bug!("unexpected projection kind: {:?}", projection);
255 base_ty = projection.ty;
260 impl<'tcx> PlaceBuilder<'tcx> {
261 pub(in crate::build) fn into_place(self, cx: &Builder<'_, 'tcx>) -> Place<'tcx> {
262 if let PlaceBase::Local(local) = self.base {
263 Place { local, projection: cx.tcx.intern_place_elems(&self.projection) }
265 self.expect_upvars_resolved(cx).into_place(cx)
269 fn expect_upvars_resolved(self, cx: &Builder<'_, 'tcx>) -> PlaceBuilder<'tcx> {
270 to_upvars_resolved_place_builder(self, cx).unwrap()
273 /// Attempts to resolve the `PlaceBuilder`.
274 /// On success, it will return the resolved `PlaceBuilder`.
275 /// On failure, it will return itself.
277 /// Upvars resolve may fail for a `PlaceBuilder` when attempting to
278 /// resolve a disjoint field whose root variable is not captured
279 /// (destructured assignments) or when attempting to resolve a root
280 /// variable (discriminant matching with only wildcard arm) that is
281 /// not captured. This can happen because the final mir that will be
282 /// generated doesn't require a read for this place. Failures will only
283 /// happen inside closures.
284 pub(in crate::build) fn try_upvars_resolved(
286 cx: &Builder<'_, 'tcx>,
287 ) -> Result<PlaceBuilder<'tcx>, PlaceBuilder<'tcx>> {
288 to_upvars_resolved_place_builder(self, cx)
291 pub(crate) fn base(&self) -> PlaceBase {
295 pub(crate) fn projection(&self) -> &[PlaceElem<'tcx>] {
299 pub(crate) fn field(self, f: Field, ty: Ty<'tcx>) -> Self {
300 self.project(PlaceElem::Field(f, ty))
303 pub(crate) fn deref(self) -> Self {
304 self.project(PlaceElem::Deref)
307 pub(crate) fn downcast(self, adt_def: AdtDef<'tcx>, variant_index: VariantIdx) -> Self {
308 self.project(PlaceElem::Downcast(Some(adt_def.variant(variant_index).name), variant_index))
311 fn index(self, index: Local) -> Self {
312 self.project(PlaceElem::Index(index))
315 pub(crate) fn project(mut self, elem: PlaceElem<'tcx>) -> Self {
316 self.projection.push(elem);
321 impl<'tcx> From<Local> for PlaceBuilder<'tcx> {
322 fn from(local: Local) -> Self {
323 Self { base: PlaceBase::Local(local), projection: Vec::new() }
327 impl<'tcx> From<PlaceBase> for PlaceBuilder<'tcx> {
328 fn from(base: PlaceBase) -> Self {
329 Self { base, projection: Vec::new() }
333 impl<'tcx> From<Place<'tcx>> for PlaceBuilder<'tcx> {
334 fn from(p: Place<'tcx>) -> Self {
335 Self { base: PlaceBase::Local(p.local), projection: p.projection.to_vec() }
339 impl<'a, 'tcx> Builder<'a, 'tcx> {
340 /// Compile `expr`, yielding a place that we can move from etc.
342 /// WARNING: Any user code might:
343 /// * Invalidate any slice bounds checks performed.
344 /// * Change the address that this `Place` refers to.
345 /// * Modify the memory that this place refers to.
346 /// * Invalidate the memory that this place refers to, this will be caught
347 /// by borrow checking.
349 /// Extra care is needed if any user code is allowed to run between calling
350 /// this method and using it, as is the case for `match` and index
352 pub(crate) fn as_place(
354 mut block: BasicBlock,
356 ) -> BlockAnd<Place<'tcx>> {
357 let place_builder = unpack!(block = self.as_place_builder(block, expr));
358 block.and(place_builder.into_place(self))
361 /// This is used when constructing a compound `Place`, so that we can avoid creating
362 /// intermediate `Place` values until we know the full set of projections.
363 pub(crate) fn as_place_builder(
367 ) -> BlockAnd<PlaceBuilder<'tcx>> {
368 self.expr_as_place(block, expr, Mutability::Mut, None)
371 /// Compile `expr`, yielding a place that we can move from etc.
372 /// Mutability note: The caller of this method promises only to read from the resulting
373 /// place. The place itself may or may not be mutable:
374 /// * If this expr is a place expr like a.b, then we will return that place.
375 /// * Otherwise, a temporary is created: in that event, it will be an immutable temporary.
376 pub(crate) fn as_read_only_place(
378 mut block: BasicBlock,
380 ) -> BlockAnd<Place<'tcx>> {
381 let place_builder = unpack!(block = self.as_read_only_place_builder(block, expr));
382 block.and(place_builder.into_place(self))
385 /// This is used when constructing a compound `Place`, so that we can avoid creating
386 /// intermediate `Place` values until we know the full set of projections.
387 /// Mutability note: The caller of this method promises only to read from the resulting
388 /// place. The place itself may or may not be mutable:
389 /// * If this expr is a place expr like a.b, then we will return that place.
390 /// * Otherwise, a temporary is created: in that event, it will be an immutable temporary.
391 fn as_read_only_place_builder(
395 ) -> BlockAnd<PlaceBuilder<'tcx>> {
396 self.expr_as_place(block, expr, Mutability::Not, None)
401 mut block: BasicBlock,
403 mutability: Mutability,
404 fake_borrow_temps: Option<&mut Vec<Local>>,
405 ) -> BlockAnd<PlaceBuilder<'tcx>> {
406 debug!("expr_as_place(block={:?}, expr={:?}, mutability={:?})", block, expr, mutability);
409 let expr_span = expr.span;
410 let source_info = this.source_info(expr_span);
412 ExprKind::Scope { region_scope, lint_level, value } => {
413 this.in_scope((region_scope, source_info), lint_level, |this| {
414 this.expr_as_place(block, &this.thir[value], mutability, fake_borrow_temps)
417 ExprKind::Field { lhs, variant_index, name } => {
418 let lhs = &this.thir[lhs];
419 let mut place_builder =
420 unpack!(block = this.expr_as_place(block, lhs, mutability, fake_borrow_temps,));
421 if let ty::Adt(adt_def, _) = lhs.ty.kind() {
422 if adt_def.is_enum() {
423 place_builder = place_builder.downcast(*adt_def, variant_index);
426 block.and(place_builder.field(name, expr.ty))
428 ExprKind::Deref { arg } => {
429 let place_builder = unpack!(
431 this.expr_as_place(block, &this.thir[arg], mutability, fake_borrow_temps,)
433 block.and(place_builder.deref())
435 ExprKind::Index { lhs, index } => this.lower_index_expression(
445 ExprKind::UpvarRef { closure_def_id, var_hir_id } => {
446 this.lower_captured_upvar(block, closure_def_id.expect_local(), var_hir_id)
449 ExprKind::VarRef { id } => {
450 let place_builder = if this.is_bound_var_in_guard(id) {
451 let index = this.var_local_id(id, RefWithinGuard);
452 PlaceBuilder::from(index).deref()
454 let index = this.var_local_id(id, OutsideGuard);
455 PlaceBuilder::from(index)
457 block.and(place_builder)
460 ExprKind::PlaceTypeAscription { source, ref user_ty } => {
461 let place_builder = unpack!(
462 block = this.expr_as_place(
469 if let Some(user_ty) = user_ty {
470 let annotation_index =
471 this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
472 span: source_info.span,
473 user_ty: user_ty.clone(),
474 inferred_ty: expr.ty,
477 let place = place_builder.clone().into_place(this);
482 kind: StatementKind::AscribeUserType(
485 UserTypeProjection { base: annotation_index, projs: vec![] },
492 block.and(place_builder)
494 ExprKind::ValueTypeAscription { source, ref user_ty } => {
495 let source = &this.thir[source];
497 unpack!(block = this.as_temp(block, source.temp_lifetime, source, mutability));
498 if let Some(user_ty) = user_ty {
499 let annotation_index =
500 this.canonical_user_type_annotations.push(CanonicalUserTypeAnnotation {
501 span: source_info.span,
502 user_ty: user_ty.clone(),
503 inferred_ty: expr.ty,
509 kind: StatementKind::AscribeUserType(
512 UserTypeProjection { base: annotation_index, projs: vec![] },
519 block.and(PlaceBuilder::from(temp))
522 ExprKind::Array { .. }
523 | ExprKind::Tuple { .. }
524 | ExprKind::Adt { .. }
525 | ExprKind::Closure { .. }
526 | ExprKind::Unary { .. }
527 | ExprKind::Binary { .. }
528 | ExprKind::LogicalOp { .. }
529 | ExprKind::Box { .. }
530 | ExprKind::Cast { .. }
531 | ExprKind::Use { .. }
532 | ExprKind::NeverToAny { .. }
533 | ExprKind::Pointer { .. }
534 | ExprKind::Repeat { .. }
535 | ExprKind::Borrow { .. }
536 | ExprKind::AddressOf { .. }
537 | ExprKind::Match { .. }
538 | ExprKind::If { .. }
539 | ExprKind::Loop { .. }
540 | ExprKind::Block { .. }
541 | ExprKind::Let { .. }
542 | ExprKind::Assign { .. }
543 | ExprKind::AssignOp { .. }
544 | ExprKind::Break { .. }
545 | ExprKind::Continue { .. }
546 | ExprKind::Return { .. }
547 | ExprKind::Literal { .. }
548 | ExprKind::NamedConst { .. }
549 | ExprKind::NonHirLiteral { .. }
550 | ExprKind::ZstLiteral { .. }
551 | ExprKind::ConstParam { .. }
552 | ExprKind::ConstBlock { .. }
553 | ExprKind::StaticRef { .. }
554 | ExprKind::InlineAsm { .. }
555 | ExprKind::Yield { .. }
556 | ExprKind::ThreadLocalRef(_)
557 | ExprKind::Call { .. } => {
558 // these are not places, so we need to make a temporary.
559 debug_assert!(!matches!(Category::of(&expr.kind), Some(Category::Place)));
561 unpack!(block = this.as_temp(block, expr.temp_lifetime, expr, mutability));
562 block.and(PlaceBuilder::from(temp))
567 /// Lower a captured upvar. Note we might not know the actual capture index,
568 /// so we create a place starting from `PlaceBase::Upvar`, which will be resolved
569 /// once all projections that allow us to identify a capture have been applied.
570 fn lower_captured_upvar(
573 closure_def_id: LocalDefId,
574 var_hir_id: LocalVarId,
575 ) -> BlockAnd<PlaceBuilder<'tcx>> {
576 block.and(PlaceBuilder::from(PlaceBase::Upvar { var_hir_id, closure_def_id }))
579 /// Lower an index expression
581 /// This has two complications;
583 /// * We need to do a bounds check.
584 /// * We need to ensure that the bounds check can't be invalidated using an
585 /// expression like `x[1][{x = y; 2}]`. We use fake borrows here to ensure
586 /// that this is the case.
587 fn lower_index_expression(
589 mut block: BasicBlock,
592 mutability: Mutability,
593 fake_borrow_temps: Option<&mut Vec<Local>>,
594 temp_lifetime: Option<region::Scope>,
596 source_info: SourceInfo,
597 ) -> BlockAnd<PlaceBuilder<'tcx>> {
598 let base_fake_borrow_temps = &mut Vec::new();
599 let is_outermost_index = fake_borrow_temps.is_none();
600 let fake_borrow_temps = fake_borrow_temps.unwrap_or(base_fake_borrow_temps);
603 unpack!(block = self.expr_as_place(block, base, mutability, Some(fake_borrow_temps),));
605 // Making this a *fresh* temporary means we do not have to worry about
606 // the index changing later: Nothing will ever change this temporary.
607 // The "retagging" transformation (for Stacked Borrows) relies on this.
608 let idx = unpack!(block = self.as_temp(block, temp_lifetime, index, Mutability::Not,));
610 block = self.bounds_check(block, base_place.clone(), idx, expr_span, source_info);
612 if is_outermost_index {
613 self.read_fake_borrows(block, fake_borrow_temps, source_info)
615 base_place = base_place.expect_upvars_resolved(self);
616 self.add_fake_borrows_of_base(
625 block.and(base_place.index(idx))
631 slice: PlaceBuilder<'tcx>,
634 source_info: SourceInfo,
636 let usize_ty = self.tcx.types.usize;
637 let bool_ty = self.tcx.types.bool;
639 let len = self.temp(usize_ty, expr_span);
640 let lt = self.temp(bool_ty, expr_span);
643 self.cfg.push_assign(block, source_info, len, Rvalue::Len(slice.into_place(self)));
645 self.cfg.push_assign(
651 Box::new((Operand::Copy(Place::from(index)), Operand::Copy(len))),
654 let msg = BoundsCheck { len: Operand::Move(len), index: Operand::Copy(Place::from(index)) };
655 // assert!(lt, "...")
656 self.assert(block, Operand::Move(lt), true, msg, expr_span)
659 fn add_fake_borrows_of_base(
661 base_place: &PlaceBuilder<'tcx>,
663 fake_borrow_temps: &mut Vec<Local>,
665 source_info: SourceInfo,
668 let local = match base_place.base {
669 PlaceBase::Local(local) => local,
670 PlaceBase::Upvar { .. } => bug!("Expected PlacseBase::Local found Upvar"),
673 let place_ty = Place::ty_from(local, &base_place.projection, &self.local_decls, tcx);
674 if let ty::Slice(_) = place_ty.ty.kind() {
675 // We need to create fake borrows to ensure that the bounds
676 // check that we just did stays valid. Since we can't assign to
677 // unsized values, we only need to ensure that none of the
678 // pointers in the base place are modified.
679 for (idx, elem) in base_place.projection.iter().enumerate().rev() {
681 ProjectionElem::Deref => {
682 let fake_borrow_deref_ty = Place::ty_from(
684 &base_place.projection[..idx],
690 tcx.mk_imm_ref(tcx.lifetimes.re_erased, fake_borrow_deref_ty);
691 let fake_borrow_temp =
692 self.local_decls.push(LocalDecl::new(fake_borrow_ty, expr_span));
693 let projection = tcx.intern_place_elems(&base_place.projection[..idx]);
694 self.cfg.push_assign(
697 fake_borrow_temp.into(),
699 tcx.lifetimes.re_erased,
701 Place { local, projection },
704 fake_borrow_temps.push(fake_borrow_temp);
706 ProjectionElem::Index(_) => {
707 let index_ty = Place::ty_from(
709 &base_place.projection[..idx],
713 match index_ty.ty.kind() {
714 // The previous index expression has already
715 // done any index expressions needed here.
716 ty::Slice(_) => break,
718 _ => bug!("unexpected index base"),
721 ProjectionElem::Field(..)
722 | ProjectionElem::Downcast(..)
723 | ProjectionElem::OpaqueCast(..)
724 | ProjectionElem::ConstantIndex { .. }
725 | ProjectionElem::Subslice { .. } => (),
731 fn read_fake_borrows(
734 fake_borrow_temps: &mut Vec<Local>,
735 source_info: SourceInfo,
737 // All indexes have been evaluated now, read all of the
738 // fake borrows so that they are live across those index
740 for temp in fake_borrow_temps {
741 self.cfg.push_fake_read(bb, source_info, FakeReadCause::ForIndex, Place::from(*temp));
746 /// Precise capture is enabled if the feature gate `capture_disjoint_fields` is enabled or if
747 /// user is using Rust Edition 2021 or higher.
748 fn enable_precise_capture(tcx: TyCtxt<'_>, closure_span: Span) -> bool {
749 tcx.features().capture_disjoint_fields || closure_span.rust_2021()