1
Fork 0

Use ControlFlow results for visitors that are only looking for a single value

This commit is contained in:
Oli Scherer 2024-07-05 15:00:40 +00:00
parent d2e6cf7fa7
commit 7dca61b68b
6 changed files with 59 additions and 87 deletions

View file

@ -805,10 +805,11 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeVisitable<TyCtxt<'tcx>>>(
.unwrap()
.contains(&data.trait_ref(self.tcx).def_id);
// only walk contained types if it's not a super trait
if is_supertrait_of_current_trait {
ControlFlow::Continue(()) // do not walk contained types, do not report error, do collect $200
ControlFlow::Continue(())
} else {
t.super_visit_with(self) // DO walk contained types, POSSIBLY reporting an error
t.super_visit_with(self) // POSSIBLY reporting an error
}
}
_ => t.super_visit_with(self), // walk contained types, if any

View file

@ -640,8 +640,6 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
}
impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
type Result = ();
fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result {
debug!("wf bounds for t={:?} t.kind={:#?}", t, t.kind());