@@ -882,6 +882,9 @@ pub struct VarBindingForm<'tcx> {
882882 pub opt_match_place : Option < ( Option < Place < ' tcx > > , Span ) > ,
883883 /// The span of the pattern in which this variable was bound.
884884 pub pat_span : Span ,
885+ /// A binding can be introduced multiple times, with or patterns:
886+ /// `Foo::A { x } | Foo::B { z: x }`. This stores information for each of those introductions.
887+ pub introductions : Vec < VarBindingIntroduction > ,
885888}
886889
887890#[ derive( Clone , Debug , TyEncodable , TyDecodable ) ]
@@ -891,7 +894,15 @@ pub enum BindingForm<'tcx> {
891894 /// Binding for a `self`/`&self`/`&mut self` binding where the type is implicit.
892895 ImplicitSelf ( ImplicitSelfKind ) ,
893896 /// Reference used in a guard expression to ensure immutability.
894- RefForGuard ,
897+ RefForGuard ( Local ) ,
898+ }
899+
900+ #[ derive( Clone , Debug , TyEncodable , TyDecodable , HashStable ) ]
901+ pub struct VarBindingIntroduction {
902+ /// Where this additional introduction happened.
903+ pub span : Span ,
904+ /// Is that introduction a shorthand struct pattern, i.e. `Foo { x }`.
905+ pub is_shorthand : bool ,
895906}
896907
897908mod binding_form_impl {
@@ -906,7 +917,7 @@ mod binding_form_impl {
906917 match self {
907918 Var ( binding) => binding. hash_stable ( hcx, hasher) ,
908919 ImplicitSelf ( kind) => kind. hash_stable ( hcx, hasher) ,
909- RefForGuard => ( ) ,
920+ RefForGuard ( local ) => local . hash_stable ( hcx , hasher ) ,
910921 }
911922 }
912923 }
@@ -1092,12 +1103,8 @@ impl<'tcx> LocalDecl<'tcx> {
10921103 matches ! (
10931104 self . local_info( ) ,
10941105 LocalInfo :: User (
1095- BindingForm :: Var ( VarBindingForm {
1096- binding_mode: BindingMode ( ByRef :: No , _) ,
1097- opt_ty_info: _,
1098- opt_match_place: _,
1099- pat_span: _,
1100- } ) | BindingForm :: ImplicitSelf ( ImplicitSelfKind :: Imm ) ,
1106+ BindingForm :: Var ( VarBindingForm { binding_mode: BindingMode ( ByRef :: No , _) , .. } )
1107+ | BindingForm :: ImplicitSelf ( ImplicitSelfKind :: Imm ) ,
11011108 )
11021109 )
11031110 }
@@ -1109,12 +1116,8 @@ impl<'tcx> LocalDecl<'tcx> {
11091116 matches ! (
11101117 self . local_info( ) ,
11111118 LocalInfo :: User (
1112- BindingForm :: Var ( VarBindingForm {
1113- binding_mode: BindingMode ( ByRef :: No , _) ,
1114- opt_ty_info: _,
1115- opt_match_place: _,
1116- pat_span: _,
1117- } ) | BindingForm :: ImplicitSelf ( _) ,
1119+ BindingForm :: Var ( VarBindingForm { binding_mode: BindingMode ( ByRef :: No , _) , .. } )
1120+ | BindingForm :: ImplicitSelf ( _) ,
11181121 )
11191122 )
11201123 }
@@ -1130,7 +1133,7 @@ impl<'tcx> LocalDecl<'tcx> {
11301133 /// expression that is used to access said variable for the guard of the
11311134 /// match arm.
11321135 pub fn is_ref_for_guard ( & self ) -> bool {
1133- matches ! ( self . local_info( ) , LocalInfo :: User ( BindingForm :: RefForGuard ) )
1136+ matches ! ( self . local_info( ) , LocalInfo :: User ( BindingForm :: RefForGuard ( _ ) ) )
11341137 }
11351138
11361139 /// Returns `Some` if this is a reference to a static item that is used to
0 commit comments