@@ -11,7 +11,13 @@ use rustc_span::Span;
1111use std:: ops:: ControlFlow ;
1212
1313#[ derive( Debug ) ]
14- pub enum NonStructuralMatchTy < ' tcx > {
14+ pub struct NonStructuralMatchTy < ' tcx > {
15+ pub ty : Ty < ' tcx > ,
16+ pub kind : NonStructuralMatchTyKind < ' tcx > ,
17+ }
18+
19+ #[ derive( Debug ) ]
20+ pub enum NonStructuralMatchTyKind < ' tcx > {
1521 Adt ( AdtDef < ' tcx > ) ,
1622 Param ,
1723 Dynamic ,
@@ -137,25 +143,32 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
137143 let ( adt_def, substs) = match * ty. kind ( ) {
138144 ty:: Adt ( adt_def, substs) => ( adt_def, substs) ,
139145 ty:: Param ( _) => {
140- return ControlFlow :: Break ( NonStructuralMatchTy :: Param ) ;
146+ let kind = NonStructuralMatchTyKind :: Param ;
147+ return ControlFlow :: Break ( NonStructuralMatchTy { ty, kind } ) ;
141148 }
142149 ty:: Dynamic ( ..) => {
143- return ControlFlow :: Break ( NonStructuralMatchTy :: Dynamic ) ;
150+ let kind = NonStructuralMatchTyKind :: Dynamic ;
151+ return ControlFlow :: Break ( NonStructuralMatchTy { ty, kind } ) ;
144152 }
145153 ty:: Foreign ( _) => {
146- return ControlFlow :: Break ( NonStructuralMatchTy :: Foreign ) ;
154+ let kind = NonStructuralMatchTyKind :: Foreign ;
155+ return ControlFlow :: Break ( NonStructuralMatchTy { ty, kind } ) ;
147156 }
148157 ty:: Opaque ( ..) => {
149- return ControlFlow :: Break ( NonStructuralMatchTy :: Opaque ) ;
158+ let kind = NonStructuralMatchTyKind :: Opaque ;
159+ return ControlFlow :: Break ( NonStructuralMatchTy { ty, kind } ) ;
150160 }
151161 ty:: Projection ( ..) => {
152- return ControlFlow :: Break ( NonStructuralMatchTy :: Projection ) ;
162+ let kind = NonStructuralMatchTyKind :: Projection ;
163+ return ControlFlow :: Break ( NonStructuralMatchTy { ty, kind } ) ;
153164 }
154165 ty:: Closure ( ..) => {
155- return ControlFlow :: Break ( NonStructuralMatchTy :: Closure ) ;
166+ let kind = NonStructuralMatchTyKind :: Closure ;
167+ return ControlFlow :: Break ( NonStructuralMatchTy { ty, kind } ) ;
156168 }
157169 ty:: Generator ( ..) | ty:: GeneratorWitness ( ..) => {
158- return ControlFlow :: Break ( NonStructuralMatchTy :: Generator ) ;
170+ let kind = NonStructuralMatchTyKind :: Generator ;
171+ return ControlFlow :: Break ( NonStructuralMatchTy { ty, kind } ) ;
159172 }
160173 ty:: RawPtr ( ..) => {
161174 // structural-match ignores substructure of
@@ -215,7 +228,8 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
215228
216229 if !self . type_marked_structural ( ty) {
217230 debug ! ( "Search found ty: {:?}" , ty) ;
218- return ControlFlow :: Break ( NonStructuralMatchTy :: Adt ( adt_def) ) ;
231+ let kind = NonStructuralMatchTyKind :: Adt ( adt_def) ;
232+ return ControlFlow :: Break ( NonStructuralMatchTy { ty, kind } ) ;
219233 }
220234
221235 // structural-match does not care about the
0 commit comments