@@ -14,6 +14,9 @@ pub enum NonStructuralMatchTy<'tcx> {
1414 Param ,
1515 Dynamic ,
1616 Foreign ,
17+ Opaque ,
18+ Generator ,
19+ Projection ,
1720}
1821
1922/// This method traverses the structure of `ty`, trying to find an
@@ -148,6 +151,18 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
148151 self . found = Some ( NonStructuralMatchTy :: Foreign ) ;
149152 return true ; // Stop visiting
150153 }
154+ ty:: Opaque ( ..) => {
155+ self . found = Some ( NonStructuralMatchTy :: Opaque ) ;
156+ return true ;
157+ }
158+ ty:: Projection ( ..) => {
159+ self . found = Some ( NonStructuralMatchTy :: Projection ) ;
160+ return true ;
161+ }
162+ ty:: Generator ( ..) | ty:: GeneratorWitness ( ..) => {
163+ self . found = Some ( NonStructuralMatchTy :: Generator ) ;
164+ return true ;
165+ }
151166 ty:: RawPtr ( ..) => {
152167 // structural-match ignores substructure of
153168 // `*const _`/`*mut _`, so skip `super_visit_with`.
@@ -181,39 +196,22 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
181196 // for empty array.
182197 return false ;
183198 }
184- ty:: Bool
185- | ty:: Char
186- | ty:: Int ( _)
187- | ty:: Uint ( _)
188- | ty:: Float ( _)
189- | ty:: Str
190- | ty:: Never => {
199+ ty:: Bool | ty:: Char | ty:: Int ( _) | ty:: Uint ( _) | ty:: Float ( _) | ty:: Str | ty:: Never => {
191200 // These primitive types are always structural match.
192201 //
193202 // `Never` is kind of special here, but as it is not inhabitable, this should be fine.
194203 return false ;
195204 }
196205
197- ty:: Array ( ..)
198- | ty:: Slice ( _)
199- | ty:: Ref ( ..)
200- | ty:: Closure ( ..)
201- | ty:: Generator ( ..)
202- | ty:: Tuple ( ..)
203- | ty:: Projection ( ..)
204- | ty:: Opaque ( ..)
205- | ty:: GeneratorWitness ( ..) => {
206+ ty:: Array ( ..) | ty:: Slice ( _) | ty:: Ref ( ..) | ty:: Tuple ( ..) => {
206207 ty. super_visit_with ( self ) ;
207208 return false ;
208209 }
209- | ty:: Infer ( _)
210- | ty:: Placeholder ( _)
211- | ty:: UnnormalizedProjection ( ..)
212- | ty:: Bound ( ..) => {
210+ ty:: Closure ( ..) | ty:: Infer ( _) | ty:: Placeholder ( _) | ty:: Bound ( ..) => {
213211 bug ! ( "unexpected type during structural-match checking: {:?}" , ty) ;
214212 }
215213 ty:: Error => {
216- self . tcx ( ) . delay_span_bug ( self . span , "ty::Error in structural-match check" ) ;
214+ self . tcx ( ) . sess . delay_span_bug ( self . span , "ty::Error in structural-match check" ) ;
217215 // We still want to check other types after encountering an error,
218216 // as this may still emit relevant errors.
219217 return false ;
0 commit comments