use rustc_middle::mir::FakeReadCause;
use rustc_middle::ty::{self, adjustment, TyCtxt};
use rustc_target::abi::VariantIdx;
+use std::iter;
use crate::mem_categorization as mc;
if needs_to_be_read {
self.borrow_expr(&discr, ty::ImmBorrow);
} else {
+ let closure_def_id = match discr_place.place.base {
+ PlaceBase::Upvar(upvar_id) => Some(upvar_id.closure_expr_id.to_def_id()),
+ _ => None,
+ };
+
self.delegate.fake_read(
discr_place.place.clone(),
- FakeReadCause::ForMatchedPlace,
+ FakeReadCause::ForMatchedPlace(closure_def_id),
discr_place.hir_id,
);
for (op, _op_sp) in asm.operands {
match op {
hir::InlineAsmOperand::In { expr, .. }
- | hir::InlineAsmOperand::Const { expr, .. }
| hir::InlineAsmOperand::Sym { expr, .. } => self.consume_expr(expr),
hir::InlineAsmOperand::Out { expr, .. } => {
if let Some(expr) = expr {
self.mutate_expr(out_expr);
}
}
+ hir::InlineAsmOperand::Const { .. } => {}
}
}
}
hir::ExprKind::LlvmInlineAsm(ref ia) => {
- for (o, output) in ia.inner.outputs.iter().zip(ia.outputs_exprs) {
+ for (o, output) in iter::zip(&ia.inner.outputs, ia.outputs_exprs) {
if o.is_indirect {
self.consume_expr(output);
} else {
}
fn walk_arm(&mut self, discr_place: &PlaceWithHirId<'tcx>, arm: &hir::Arm<'_>) {
+ let closure_def_id = match discr_place.place.base {
+ PlaceBase::Upvar(upvar_id) => Some(upvar_id.closure_expr_id.to_def_id()),
+ _ => None,
+ };
+
self.delegate.fake_read(
discr_place.place.clone(),
- FakeReadCause::ForMatchedPlace,
+ FakeReadCause::ForMatchedPlace(closure_def_id),
discr_place.hir_id,
);
self.walk_pat(discr_place, &arm.pat);
/// Walks a pat that occurs in isolation (i.e., top-level of fn argument or
/// let binding, and *not* a match arm or nested pat.)
fn walk_irrefutable_pat(&mut self, discr_place: &PlaceWithHirId<'tcx>, pat: &hir::Pat<'_>) {
+ let closure_def_id = match discr_place.place.base {
+ PlaceBase::Upvar(upvar_id) => Some(upvar_id.closure_expr_id.to_def_id()),
+ _ => None,
+ };
+
self.delegate.fake_read(
discr_place.place.clone(),
- FakeReadCause::ForLet,
+ FakeReadCause::ForLet(closure_def_id),
discr_place.hir_id,
);
self.walk_pat(discr_place, pat);
/// In the following example the closures `c` only captures `p.x`` even though `incr`
/// is a capture of the nested closure
///
- /// ```rust,ignore(cannot-test-this-because-pseduo-code)
+ /// ```rust,ignore(cannot-test-this-because-pseudo-code)
/// let p = ..;
/// let c = || {
/// let incr = 10;
// The only places we want to fake read before creating the parent closure are the ones that
// are not local to it/ defined by it.
//
- // ```rust,ignore(cannot-test-this-because-pseduo-code)
+ // ```rust,ignore(cannot-test-this-because-pseudo-code)
// let v1 = (0, 1);
// let c = || { // fake reads: v1
// let v2 = (0, 1);