]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_lint/src/types.rs
TypeVisitor: use `ControlFlow` in rustc_{infer,lint,trait_selection}
[rust.git] / compiler / rustc_lint / src / types.rs
index bd0250305671ed923bb5edd8b68e71f8e5deed0e..2bfa17b121961d9df7716bd954d8c2090b6ef74f 100644 (file)
@@ -18,6 +18,7 @@
 use rustc_target::spec::abi::Abi as SpecAbi;
 
 use std::cmp;
+use std::ops::ControlFlow;
 use tracing::debug;
 
 declare_lint! {
@@ -1135,11 +1136,11 @@ struct ProhibitOpaqueTypes<'a, 'tcx> {
         };
 
         impl<'a, 'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueTypes<'a, 'tcx> {
-            fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
+            fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<(), ()> {
                 match ty.kind() {
                     ty::Opaque(..) => {
                         self.ty = Some(ty);
-                        true
+                        ControlFlow::BREAK
                     }
                     // Consider opaque types within projections FFI-safe if they do not normalize
                     // to more opaque types.
@@ -1148,7 +1149,11 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
 
                         // If `ty` is a opaque type directly then `super_visit_with` won't invoke
                         // this function again.
-                        if ty.has_opaque_types() { self.visit_ty(ty) } else { false }
+                        if ty.has_opaque_types() {
+                            self.visit_ty(ty)
+                        } else {
+                            ControlFlow::CONTINUE
+                        }
                     }
                     _ => ty.super_visit_with(self),
                 }