diff options
Diffstat (limited to 'compiler/rustc_mir_build/src/build/block.rs')
-rw-r--r-- | compiler/rustc_mir_build/src/build/block.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/rustc_mir_build/src/build/block.rs b/compiler/rustc_mir_build/src/build/block.rs index 49d7136a2..2643d33ce 100644 --- a/compiler/rustc_mir_build/src/build/block.rs +++ b/compiler/rustc_mir_build/src/build/block.rs @@ -231,7 +231,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { remainder_span, pattern, None, - Some((None, initializer_span)), + Some((Some(&destination), initializer_span)), ); this.visit_primary_bindings( pattern, @@ -373,7 +373,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // the case of `!`, no return value is required, as the block will never return. // Opaque types of empty bodies also need this unit assignment, in order to infer that their // type is actually unit. Otherwise there will be no defining use found in the MIR. - if destination_ty.is_unit() || matches!(destination_ty.kind(), ty::Opaque(..)) { + if destination_ty.is_unit() + || matches!(destination_ty.kind(), ty::Alias(ty::Opaque, ..)) + { // We only want to assign an implicit `()` as the return value of the block if the // block does not diverge. (Otherwise, we may try to assign a unit to a `!`-type.) this.cfg.push_assign_unit(block, source_info, destination, this.tcx); |