]> git.lizzy.rs Git - rust.git/commitdiff
TypeVisitor: use `ControlFlow` in clippy
authorLeSeulArtichaut <leseulartichaut@gmail.com>
Wed, 21 Oct 2020 12:27:32 +0000 (14:27 +0200)
committerLeSeulArtichaut <leseulartichaut@gmail.com>
Fri, 30 Oct 2020 11:27:45 +0000 (12:27 +0100)
clippy_lints/src/lib.rs
clippy_lints/src/redundant_clone.rs

index 2d37496984609b213df72b51794fcb1ca0be4cba..e97fa543a093d286c19ff53e25bb04c98340b3fe 100644 (file)
@@ -11,6 +11,7 @@
 #![feature(or_patterns)]
 #![feature(rustc_private)]
 #![feature(stmt_expr_attributes)]
+#![feature(control_flow_enum)]
 #![recursion_limit = "512"]
 #![cfg_attr(feature = "deny-warnings", deny(warnings))]
 #![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)]
index b4502c668dcbe3567a7358da470616a233e6cec4..7f6627358a1861e020e747511c1a0d7a1275a64b 100644 (file)
@@ -18,6 +18,7 @@
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 use rustc_span::source_map::{BytePos, Span};
 use std::convert::TryFrom;
+use std::ops::ControlFlow;
 
 macro_rules! unwrap_or_continue {
     ($x:expr) => {
@@ -517,7 +518,7 @@ fn visit_assign(&mut self, place: &mir::Place<'tcx>, rvalue: &mir::Rvalue<'_>, _
                 self.possible_borrower.add(borrowed.local, lhs);
             },
             other => {
-                if !ContainsRegion.visit_ty(place.ty(&self.body.local_decls, self.cx.tcx).ty) {
+                if ContainsRegion.visit_ty(place.ty(&self.body.local_decls, self.cx.tcx).ty) == ControlFlow::CONTINUE {
                     return;
                 }
                 rvalue_locals(other, |rhs| {
@@ -539,7 +540,7 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'_>, _loc: mir::Loca
             // If the call returns something with lifetimes,
             // let's conservatively assume the returned value contains lifetime of all the arguments.
             // For example, given `let y: Foo<'a> = foo(x)`, `y` is considered to be a possible borrower of `x`.
-            if !ContainsRegion.visit_ty(&self.body.local_decls[*dest].ty) {
+            if ContainsRegion.visit_ty(&self.body.local_decls[*dest].ty) == ControlFlow::CONTINUE {
                 return;
             }
 
@@ -558,8 +559,8 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'_>, _loc: mir::Loca
 struct ContainsRegion;
 
 impl TypeVisitor<'_> for ContainsRegion {
-    fn visit_region(&mut self, _: ty::Region<'_>) -> bool {
-        true
+    fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<(), ()> {
+        ControlFlow::BREAK
     }
 }