@@ -13,6 +13,9 @@ pub enum NonStructuralMatchTy<'tcx> {
1313 Param ,
1414 Dynamic ,
1515 Foreign ,
16+ Opaque ,
17+ Generator ,
18+ Projection ,
1619}
1720
1821/// This method traverses the structure of `ty`, trying to find an
@@ -147,6 +150,18 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
147150 self . found = Some ( NonStructuralMatchTy :: Foreign ) ;
148151 return true ; // Stop visiting
149152 }
153+ ty:: Opaque ( ..) => {
154+ self . found = Some ( NonStructuralMatchTy :: Opaque ) ;
155+ return true ;
156+ }
157+ ty:: Projection ( ..) => {
158+ self . found = Some ( NonStructuralMatchTy :: Projection ) ;
159+ return true ;
160+ }
161+ ty:: Generator ( ..) | ty:: GeneratorWitness ( ..) => {
162+ self . found = Some ( NonStructuralMatchTy :: Generator ) ;
163+ return true ;
164+ }
150165 ty:: RawPtr ( ..) => {
151166 // structural-match ignores substructure of
152167 // `*const _`/`*mut _`, so skip `super_visit_with`.
@@ -180,39 +195,26 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
180195 // for empty array.
181196 return false ;
182197 }
183- ty:: Bool
184- | ty:: Char
185- | ty:: Int ( _)
186- | ty:: Uint ( _)
187- | ty:: Float ( _)
188- | ty:: Str
189- | ty:: Never => {
198+ ty:: Bool | ty:: Char | ty:: Int ( _) | ty:: Uint ( _) | ty:: Float ( _) | ty:: Str | ty:: Never => {
190199 // These primitive types are always structural match.
191200 //
192201 // `Never` is kind of special here, but as it is not inhabitable, this should be fine.
193202 return false ;
194203 }
195204
196- ty:: Array ( ..)
197- | ty:: Slice ( _)
198- | ty:: Ref ( ..)
199- | ty:: Closure ( ..)
200- | ty:: Generator ( ..)
201- | ty:: Tuple ( ..)
202- | ty:: Projection ( ..)
203- | ty:: Opaque ( ..)
204- | ty:: GeneratorWitness ( ..) => {
205+ ty:: Array ( ..) | ty:: Slice ( _) | ty:: Ref ( ..) | ty:: Tuple ( ..) => {
205206 ty. super_visit_with ( self ) ;
206207 return false ;
207208 }
209+ ty:: Closure ( ..)
208210 | ty:: Infer ( _)
209211 | ty:: Placeholder ( _)
210212 | ty:: UnnormalizedProjection ( ..)
211213 | ty:: Bound ( ..) => {
212214 bug ! ( "unexpected type during structural-match checking: {:?}" , ty) ;
213215 }
214216 ty:: Error => {
215- self . tcx ( ) . delay_span_bug ( self . span , "ty::Error in structural-match check" ) ;
217+ self . tcx ( ) . sess . delay_span_bug ( self . span , "ty::Error in structural-match check" ) ;
216218 // We still want to check other types after encountering an error,
217219 // as this may still emit relevant errors.
218220 return false ;
0 commit comments