@@ -149,19 +149,19 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
149
149
}
150
150
ty:: Foreign ( _) => {
151
151
self . found = Some ( NonStructuralMatchTy :: Foreign ) ;
152
- return true ; // Stop visiting
152
+ return true ; // Stop visiting.
153
153
}
154
154
ty:: Opaque ( ..) => {
155
155
self . found = Some ( NonStructuralMatchTy :: Opaque ) ;
156
- return true ;
156
+ return true ; // Stop visiting.
157
157
}
158
158
ty:: Projection ( ..) => {
159
159
self . found = Some ( NonStructuralMatchTy :: Projection ) ;
160
- return true ;
160
+ return true ; // Stop visiting.
161
161
}
162
162
ty:: Generator ( ..) | ty:: GeneratorWitness ( ..) => {
163
163
self . found = Some ( NonStructuralMatchTy :: Generator ) ;
164
- return true ;
164
+ return true ; // Stop visiting.
165
165
}
166
166
ty:: RawPtr ( ..) => {
167
167
// structural-match ignores substructure of
@@ -179,31 +179,36 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
179
179
// structural equality on `T` does not recur into the raw
180
180
// pointer. Therefore, one can still use `C` in a pattern.
181
181
182
- // (But still tell caller to continue search.)
182
+ // (But still tell the caller to continue search.)
183
183
return false ;
184
184
}
185
185
ty:: FnDef ( ..) | ty:: FnPtr ( ..) => {
186
186
// Types of formals and return in `fn(_) -> _` are also irrelevant;
187
187
// so we do not recur into them via `super_visit_with`
188
188
//
189
- // (But still tell caller to continue search.)
189
+ // (But still tell the caller to continue search.)
190
190
return false ;
191
191
}
192
192
ty:: Array ( _, n)
193
193
if { n. try_eval_usize ( self . tcx ( ) , ty:: ParamEnv :: reveal_all ( ) ) == Some ( 0 ) } =>
194
194
{
195
195
// rust-lang/rust#62336: ignore type of contents
196
196
// for empty array.
197
+ //
198
+ // (But still tell the caller to continue search.)
197
199
return false ;
198
200
}
199
201
ty:: Bool | ty:: Char | ty:: Int ( _) | ty:: Uint ( _) | ty:: Float ( _) | ty:: Str | ty:: Never => {
200
202
// These primitive types are always structural match.
201
203
//
202
204
// `Never` is kind of special here, but as it is not inhabitable, this should be fine.
205
+ //
206
+ // (But still tell the caller to continue search.)
203
207
return false ;
204
208
}
205
209
206
210
ty:: Array ( ..) | ty:: Slice ( _) | ty:: Ref ( ..) | ty:: Tuple ( ..) => {
211
+ // First check all contained types and then tell the caller to continue searching.
207
212
ty. super_visit_with ( self ) ;
208
213
return false ;
209
214
}
@@ -214,13 +219,15 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
214
219
self . tcx ( ) . sess . delay_span_bug ( self . span , "ty::Error in structural-match check" ) ;
215
220
// We still want to check other types after encountering an error,
216
221
// as this may still emit relevant errors.
222
+ //
223
+ // So we continue searching here.
217
224
return false ;
218
225
}
219
226
} ;
220
227
221
228
if !self . seen . insert ( adt_def. did ) {
222
229
debug ! ( "Search already seen adt_def: {:?}" , adt_def) ;
223
- // let caller continue its search
230
+ // Let caller continue its search.
224
231
return false ;
225
232
}
226
233
0 commit comments