Skip to content

Commit ea47fdf

Browse files
committed
comment return sites
1 parent 5a5017e commit ea47fdf

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/librustc_trait_selection/traits/structural_match.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,19 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
149149
}
150150
ty::Foreign(_) => {
151151
self.found = Some(NonStructuralMatchTy::Foreign);
152-
return true; // Stop visiting
152+
return true; // Stop visiting.
153153
}
154154
ty::Opaque(..) => {
155155
self.found = Some(NonStructuralMatchTy::Opaque);
156-
return true;
156+
return true; // Stop visiting.
157157
}
158158
ty::Projection(..) => {
159159
self.found = Some(NonStructuralMatchTy::Projection);
160-
return true;
160+
return true; // Stop visiting.
161161
}
162162
ty::Generator(..) | ty::GeneratorWitness(..) => {
163163
self.found = Some(NonStructuralMatchTy::Generator);
164-
return true;
164+
return true; // Stop visiting.
165165
}
166166
ty::RawPtr(..) => {
167167
// structural-match ignores substructure of
@@ -179,31 +179,36 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
179179
// structural equality on `T` does not recur into the raw
180180
// pointer. Therefore, one can still use `C` in a pattern.
181181

182-
// (But still tell caller to continue search.)
182+
// (But still tell the caller to continue search.)
183183
return false;
184184
}
185185
ty::FnDef(..) | ty::FnPtr(..) => {
186186
// Types of formals and return in `fn(_) -> _` are also irrelevant;
187187
// so we do not recur into them via `super_visit_with`
188188
//
189-
// (But still tell caller to continue search.)
189+
// (But still tell the caller to continue search.)
190190
return false;
191191
}
192192
ty::Array(_, n)
193193
if { n.try_eval_usize(self.tcx(), ty::ParamEnv::reveal_all()) == Some(0) } =>
194194
{
195195
// rust-lang/rust#62336: ignore type of contents
196196
// for empty array.
197+
//
198+
// (But still tell the caller to continue search.)
197199
return false;
198200
}
199201
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => {
200202
// These primitive types are always structural match.
201203
//
202204
// `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.)
203207
return false;
204208
}
205209

206210
ty::Array(..) | ty::Slice(_) | ty::Ref(..) | ty::Tuple(..) => {
211+
// First check all contained types and then tell the caller to continue searching.
207212
ty.super_visit_with(self);
208213
return false;
209214
}
@@ -214,13 +219,15 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
214219
self.tcx().sess.delay_span_bug(self.span, "ty::Error in structural-match check");
215220
// We still want to check other types after encountering an error,
216221
// as this may still emit relevant errors.
222+
//
223+
// So we continue searching here.
217224
return false;
218225
}
219226
};
220227

221228
if !self.seen.insert(adt_def.did) {
222229
debug!("Search already seen adt_def: {:?}", adt_def);
223-
// let caller continue its search
230+
// Let caller continue its search.
224231
return false;
225232
}
226233

0 commit comments

Comments
 (0)