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