@@ -148,19 +148,19 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
148148 }
149149 ty:: Foreign ( _) => {
150150 self . found = Some ( NonStructuralMatchTy :: Foreign ) ;
151- return true ; // Stop visiting
151+ return true ; // Stop visiting.
152152 }
153153 ty:: Opaque ( ..) => {
154154 self . found = Some ( NonStructuralMatchTy :: Opaque ) ;
155- return true ;
155+ return true ; // Stop visiting.
156156 }
157157 ty:: Projection ( ..) => {
158158 self . found = Some ( NonStructuralMatchTy :: Projection ) ;
159- return true ;
159+ return true ; // Stop visiting.
160160 }
161161 ty:: Generator ( ..) | ty:: GeneratorWitness ( ..) => {
162162 self . found = Some ( NonStructuralMatchTy :: Generator ) ;
163- return true ;
163+ return true ; // Stop visiting.
164164 }
165165 ty:: RawPtr ( ..) => {
166166 // structural-match ignores substructure of
@@ -178,31 +178,36 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
178178 // structural equality on `T` does not recur into the raw
179179 // pointer. Therefore, one can still use `C` in a pattern.
180180
181- // (But still tell caller to continue search.)
181+ // (But still tell the caller to continue search.)
182182 return false ;
183183 }
184184 ty:: FnDef ( ..) | ty:: FnPtr ( ..) => {
185185 // Types of formals and return in `fn(_) -> _` are also irrelevant;
186186 // so we do not recur into them via `super_visit_with`
187187 //
188- // (But still tell caller to continue search.)
188+ // (But still tell the caller to continue search.)
189189 return false ;
190190 }
191191 ty:: Array ( _, n)
192192 if { n. try_eval_usize ( self . tcx ( ) , ty:: ParamEnv :: reveal_all ( ) ) == Some ( 0 ) } =>
193193 {
194194 // rust-lang/rust#62336: ignore type of contents
195195 // for empty array.
196+ //
197+ // (But still tell the caller to continue search.)
196198 return false ;
197199 }
198200 ty:: Bool | ty:: Char | ty:: Int ( _) | ty:: Uint ( _) | ty:: Float ( _) | ty:: Str | ty:: Never => {
199201 // These primitive types are always structural match.
200202 //
201203 // `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.)
202206 return false ;
203207 }
204208
205209 ty:: Array ( ..) | ty:: Slice ( _) | ty:: Ref ( ..) | ty:: Tuple ( ..) => {
210+ // First check all contained types and then tell the caller to continue searching.
206211 ty. super_visit_with ( self ) ;
207212 return false ;
208213 }
@@ -217,13 +222,15 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
217222 self . tcx ( ) . sess . delay_span_bug ( self . span , "ty::Error in structural-match check" ) ;
218223 // We still want to check other types after encountering an error,
219224 // as this may still emit relevant errors.
225+ //
226+ // So we continue searching here.
220227 return false ;
221228 }
222229 } ;
223230
224231 if !self . seen . insert ( adt_def. did ) {
225232 debug ! ( "Search already seen adt_def: {:?}" , adt_def) ;
226- // let caller continue its search
233+ // Let caller continue its search.
227234 return false ;
228235 }
229236
0 commit comments