@@ -13,6 +13,9 @@ pub enum NonStructuralMatchTy<'tcx> {
13
13
Param ,
14
14
Dynamic ,
15
15
Foreign ,
16
+ Opaque ,
17
+ Generator ,
18
+ Projection ,
16
19
}
17
20
18
21
/// This method traverses the structure of `ty`, trying to find an
@@ -147,6 +150,18 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
147
150
self . found = Some ( NonStructuralMatchTy :: Foreign ) ;
148
151
return true ; // Stop visiting
149
152
}
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
+ }
150
165
ty:: RawPtr ( ..) => {
151
166
// structural-match ignores substructure of
152
167
// `*const _`/`*mut _`, so skip `super_visit_with`.
@@ -180,39 +195,26 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
180
195
// for empty array.
181
196
return false ;
182
197
}
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 => {
190
199
// These primitive types are always structural match.
191
200
//
192
201
// `Never` is kind of special here, but as it is not inhabitable, this should be fine.
193
202
return false ;
194
203
}
195
204
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 ( ..) => {
205
206
ty. super_visit_with ( self ) ;
206
207
return false ;
207
208
}
209
+ ty:: Closure ( ..)
208
210
| ty:: Infer ( _)
209
211
| ty:: Placeholder ( _)
210
212
| ty:: UnnormalizedProjection ( ..)
211
213
| ty:: Bound ( ..) => {
212
214
bug ! ( "unexpected type during structural-match checking: {:?}" , ty) ;
213
215
}
214
216
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" ) ;
216
218
// We still want to check other types after encountering an error,
217
219
// as this may still emit relevant errors.
218
220
return false ;
0 commit comments