@@ -575,35 +575,35 @@ pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R {
575575 f ( )
576576}
577577
578+ /// Context that provides information local to a place under investigation.
578579#[ derive( Clone ) ]
579- pub ( crate ) struct PatCtxt < ' a , ' p , Cx : MatchCx > {
580+ pub ( crate ) struct PlaceCtxt < ' a , ' p , Cx : MatchCx > {
580581 pub ( crate ) cx : & ' a Cx ,
581- /// Type of the current column under investigation.
582- pub ( crate ) ty : Cx :: Ty ,
583- /// Whether the current pattern is the whole pattern as found in a match arm, or if it's a
584- /// subpattern.
585- pub ( crate ) is_top_level : bool ,
586582 /// An arena to store the wildcards we produce during analysis.
587583 pub ( crate ) wildcard_arena : & ' a TypedArena < DeconstructedPat < ' p , Cx > > ,
584+ /// Type of the place under investigation.
585+ pub ( crate ) ty : Cx :: Ty ,
586+ /// Whether the place is the original scrutinee place, as opposed to a subplace of it.
587+ pub ( crate ) is_scrutinee : bool ,
588588}
589589
590- impl < ' a , ' p , Cx : MatchCx > PatCtxt < ' a , ' p , Cx > {
591- /// A `PatCtxt ` when code other than `is_useful` needs one.
590+ impl < ' a , ' p , Cx : MatchCx > PlaceCtxt < ' a , ' p , Cx > {
591+ /// A `PlaceCtxt ` when code other than `is_useful` needs one.
592592 #[ cfg_attr( not( feature = "rustc" ) , allow( dead_code) ) ]
593593 pub ( crate ) fn new_dummy (
594594 cx : & ' a Cx ,
595595 ty : Cx :: Ty ,
596596 wildcard_arena : & ' a TypedArena < DeconstructedPat < ' p , Cx > > ,
597597 ) -> Self {
598- PatCtxt { cx, ty, is_top_level : false , wildcard_arena }
598+ PlaceCtxt { cx, ty, is_scrutinee : false , wildcard_arena }
599599 }
600600}
601601
602- impl < ' a , ' p , Cx : MatchCx > Copy for PatCtxt < ' a , ' p , Cx > { }
602+ impl < ' a , ' p , Cx : MatchCx > Copy for PlaceCtxt < ' a , ' p , Cx > { }
603603
604- impl < ' a , ' p , Cx : MatchCx > fmt:: Debug for PatCtxt < ' a , ' p , Cx > {
604+ impl < ' a , ' p , Cx : MatchCx > fmt:: Debug for PlaceCtxt < ' a , ' p , Cx > {
605605 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
606- f. debug_struct ( "PatCtxt " ) . field ( "ty" , & self . ty ) . finish ( )
606+ f. debug_struct ( "PlaceCtxt " ) . field ( "ty" , & self . ty ) . finish ( )
607607 }
608608}
609609
@@ -714,7 +714,7 @@ impl<'a, 'p, Cx: MatchCx> PatStack<'a, 'p, Cx> {
714714 /// Only call if `ctor.is_covered_by(self.head().ctor())` is true.
715715 fn pop_head_constructor (
716716 & self ,
717- pcx : & PatCtxt < ' a , ' p , Cx > ,
717+ pcx : & PlaceCtxt < ' a , ' p , Cx > ,
718718 ctor : & Constructor < Cx > ,
719719 ) -> PatStack < ' a , ' p , Cx > {
720720 // We pop the head pattern and push the new fields extracted from the arguments of
@@ -785,7 +785,7 @@ impl<'a, 'p, Cx: MatchCx> MatrixRow<'a, 'p, Cx> {
785785 /// Only call if `ctor.is_covered_by(self.head().ctor())` is true.
786786 fn pop_head_constructor (
787787 & self ,
788- pcx : & PatCtxt < ' a , ' p , Cx > ,
788+ pcx : & PlaceCtxt < ' a , ' p , Cx > ,
789789 ctor : & Constructor < Cx > ,
790790 parent_row : usize ,
791791 ) -> MatrixRow < ' a , ' p , Cx > {
@@ -914,7 +914,7 @@ impl<'a, 'p, Cx: MatchCx> Matrix<'a, 'p, Cx> {
914914 /// This computes `specialize(ctor, self)`. See top of the file for explanations.
915915 fn specialize_constructor (
916916 & self ,
917- pcx : & PatCtxt < ' a , ' p , Cx > ,
917+ pcx : & PlaceCtxt < ' a , ' p , Cx > ,
918918 ctor : & Constructor < Cx > ,
919919 ) -> Matrix < ' a , ' p , Cx > {
920920 let wildcard_row = self . wildcard_row . pop_head_constructor ( pcx, ctor) ;
@@ -1064,7 +1064,7 @@ impl<Cx: MatchCx> WitnessStack<Cx> {
10641064 /// pats: [(false, "foo"), _, true]
10651065 /// result: [Enum::Variant { a: (false, "foo"), b: _ }, true]
10661066 /// ```
1067- fn apply_constructor ( & mut self , pcx : & PatCtxt < ' _ , ' _ , Cx > , ctor : & Constructor < Cx > ) {
1067+ fn apply_constructor ( & mut self , pcx : & PlaceCtxt < ' _ , ' _ , Cx > , ctor : & Constructor < Cx > ) {
10681068 let len = self . 0 . len ( ) ;
10691069 let arity = ctor. arity ( pcx) ;
10701070 let fields = self . 0 . drain ( ( len - arity) ..) . rev ( ) . collect ( ) ;
@@ -1114,7 +1114,7 @@ impl<Cx: MatchCx> WitnessMatrix<Cx> {
11141114 /// Reverses specialization by `ctor`. See the section on `unspecialize` at the top of the file.
11151115 fn apply_constructor (
11161116 & mut self ,
1117- pcx : & PatCtxt < ' _ , ' _ , Cx > ,
1117+ pcx : & PlaceCtxt < ' _ , ' _ , Cx > ,
11181118 missing_ctors : & [ Constructor < Cx > ] ,
11191119 ctor : & Constructor < Cx > ,
11201120 report_individual_missing_ctors : bool ,
@@ -1202,7 +1202,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: MatchCx>(
12021202 } ;
12031203
12041204 debug ! ( "ty: {ty:?}" ) ;
1205- let pcx = & PatCtxt { cx, ty, is_top_level, wildcard_arena } ;
1205+ let pcx = & PlaceCtxt { cx, ty, is_scrutinee : is_top_level, wildcard_arena } ;
12061206
12071207 // Whether the place/column we are inspecting is known to contain valid data.
12081208 let place_validity = matrix. place_validity [ 0 ] ;
0 commit comments