mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 09:38:26 +03:00
TypeVisitor: use ControlFlow in clippy
This commit is contained in:
@@ -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)]
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user