From 1905f8c441fa2050de5c4574bb7f6594abc31274 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 19 Sep 2022 15:33:36 +0000 Subject: [PATCH] Document projection condition --- compiler/rustc_mir_build/src/build/matches/util.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_mir_build/src/build/matches/util.rs b/compiler/rustc_mir_build/src/build/matches/util.rs index d77d296f20653..b854ba47f8f61 100644 --- a/compiler/rustc_mir_build/src/build/matches/util.rs +++ b/compiler/rustc_mir_build/src/build/matches/util.rs @@ -106,6 +106,9 @@ impl<'pat, 'tcx> MatchPair<'pat, 'tcx> { let mut place = match place.try_upvars_resolved(cx) { Ok(val) | Err(val) => val, }; + + // Only add the OpaqueCast projection if the given place is an opaque type and the + // expected type from the pattern is not. let may_need_cast = match place.base() { PlaceBase::Local(local) => { let ty = Place::ty_from(local, place.projection(), &cx.local_decls, cx.tcx).ty;