@@ -575,35 +575,35 @@ pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R {
575
575
f ( )
576
576
}
577
577
578
+ /// Context that provides information local to a place under investigation.
578
579
#[ derive( Clone ) ]
579
- pub ( crate ) struct PatCtxt < ' a , ' p , Cx : MatchCx > {
580
+ pub ( crate ) struct PlaceCtxt < ' a , ' p , Cx : MatchCx > {
580
581
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 ,
586
582
/// An arena to store the wildcards we produce during analysis.
587
583
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 ,
588
588
}
589
589
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.
592
592
#[ cfg_attr( not( feature = "rustc" ) , allow( dead_code) ) ]
593
593
pub ( crate ) fn new_dummy (
594
594
cx : & ' a Cx ,
595
595
ty : Cx :: Ty ,
596
596
wildcard_arena : & ' a TypedArena < DeconstructedPat < ' p , Cx > > ,
597
597
) -> Self {
598
- PatCtxt { cx, ty, is_top_level : false , wildcard_arena }
598
+ PlaceCtxt { cx, ty, is_scrutinee : false , wildcard_arena }
599
599
}
600
600
}
601
601
602
- impl < ' a , ' p , Cx : MatchCx > Copy for PatCtxt < ' a , ' p , Cx > { }
602
+ impl < ' a , ' p , Cx : MatchCx > Copy for PlaceCtxt < ' a , ' p , Cx > { }
603
603
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 > {
605
605
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 ( )
607
607
}
608
608
}
609
609
@@ -714,7 +714,7 @@ impl<'a, 'p, Cx: MatchCx> PatStack<'a, 'p, Cx> {
714
714
/// Only call if `ctor.is_covered_by(self.head().ctor())` is true.
715
715
fn pop_head_constructor (
716
716
& self ,
717
- pcx : & PatCtxt < ' a , ' p , Cx > ,
717
+ pcx : & PlaceCtxt < ' a , ' p , Cx > ,
718
718
ctor : & Constructor < Cx > ,
719
719
) -> PatStack < ' a , ' p , Cx > {
720
720
// 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> {
785
785
/// Only call if `ctor.is_covered_by(self.head().ctor())` is true.
786
786
fn pop_head_constructor (
787
787
& self ,
788
- pcx : & PatCtxt < ' a , ' p , Cx > ,
788
+ pcx : & PlaceCtxt < ' a , ' p , Cx > ,
789
789
ctor : & Constructor < Cx > ,
790
790
parent_row : usize ,
791
791
) -> MatrixRow < ' a , ' p , Cx > {
@@ -914,7 +914,7 @@ impl<'a, 'p, Cx: MatchCx> Matrix<'a, 'p, Cx> {
914
914
/// This computes `specialize(ctor, self)`. See top of the file for explanations.
915
915
fn specialize_constructor (
916
916
& self ,
917
- pcx : & PatCtxt < ' a , ' p , Cx > ,
917
+ pcx : & PlaceCtxt < ' a , ' p , Cx > ,
918
918
ctor : & Constructor < Cx > ,
919
919
) -> Matrix < ' a , ' p , Cx > {
920
920
let wildcard_row = self . wildcard_row . pop_head_constructor ( pcx, ctor) ;
@@ -1064,7 +1064,7 @@ impl<Cx: MatchCx> WitnessStack<Cx> {
1064
1064
/// pats: [(false, "foo"), _, true]
1065
1065
/// result: [Enum::Variant { a: (false, "foo"), b: _ }, true]
1066
1066
/// ```
1067
- fn apply_constructor ( & mut self , pcx : & PatCtxt < ' _ , ' _ , Cx > , ctor : & Constructor < Cx > ) {
1067
+ fn apply_constructor ( & mut self , pcx : & PlaceCtxt < ' _ , ' _ , Cx > , ctor : & Constructor < Cx > ) {
1068
1068
let len = self . 0 . len ( ) ;
1069
1069
let arity = ctor. arity ( pcx) ;
1070
1070
let fields = self . 0 . drain ( ( len - arity) ..) . rev ( ) . collect ( ) ;
@@ -1114,7 +1114,7 @@ impl<Cx: MatchCx> WitnessMatrix<Cx> {
1114
1114
/// Reverses specialization by `ctor`. See the section on `unspecialize` at the top of the file.
1115
1115
fn apply_constructor (
1116
1116
& mut self ,
1117
- pcx : & PatCtxt < ' _ , ' _ , Cx > ,
1117
+ pcx : & PlaceCtxt < ' _ , ' _ , Cx > ,
1118
1118
missing_ctors : & [ Constructor < Cx > ] ,
1119
1119
ctor : & Constructor < Cx > ,
1120
1120
report_individual_missing_ctors : bool ,
@@ -1202,7 +1202,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: MatchCx>(
1202
1202
} ;
1203
1203
1204
1204
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 } ;
1206
1206
1207
1207
// Whether the place/column we are inspecting is known to contain valid data.
1208
1208
let place_validity = matrix. place_validity [ 0 ] ;
0 commit comments