From fc5c4daa88d2588a1eedc8caeb8ab61fc4622e8f Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 21 Mar 2018 19:47:08 +0000 Subject: Temporarily only adding UserAssertTy on binding patterns. --- src/librustc_mir/build/block.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs index 02d2522b6ba..b2ab23024a8 100644 --- a/src/librustc_mir/build/block.rs +++ b/src/librustc_mir/build/block.rs @@ -125,11 +125,17 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { }) })); } else { - this.visit_bindings(&pattern, &mut |this, _, _, node, span, _| { - this.storage_live_binding(block, node, span); + // FIXME: We currently only insert `UserAssertTy` statements for patterns + // that are bindings, this is as we do not want to deconstruct the type + // being assertion to match the pattern. + if let PatternKind::Binding { var, .. } = *pattern.kind { if let Some(ty) = ty { - this.user_assert_ty(block, ty, node, span); + this.user_assert_ty(block, ty, var, span); } + } + + this.visit_bindings(&pattern, &mut |this, _, _, node, span, _| { + this.storage_live_binding(block, node, span); this.schedule_drop_for_binding(node, span); }) } -- cgit 1.4.1-3-g733a5