Skip to content

Commit

Permalink
TypeVisitor: use ControlFlow in clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSeulArtichaut committed Oct 30, 2020
1 parent 61f8182 commit 8e4cf0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_lints/src/lib.rs
Expand Up @@ -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)]
Expand Down
9 changes: 5 additions & 4 deletions src/tools/clippy/clippy_lints/src/redundant_clone.rs
Expand Up @@ -18,6 +18,7 @@ use rustc_mir::dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, Re
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) => {
Expand Down Expand Up @@ -517,7 +518,7 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
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| {
Expand All @@ -539,7 +540,7 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
// 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;
}

Expand All @@ -558,8 +559,8 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
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
}
}

Expand Down

0 comments on commit 8e4cf0b

Please sign in to comment.