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