@@ -18,6 +18,7 @@ use rustc_mir::dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, Re
18
18
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
19
19
use rustc_span:: source_map:: { BytePos , Span } ;
20
20
use std:: convert:: TryFrom ;
21
+ use std:: ops:: ControlFlow ;
21
22
22
23
macro_rules! unwrap_or_continue {
23
24
( $x: expr) => {
@@ -517,7 +518,10 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
517
518
self . possible_borrower . add ( borrowed. local , lhs) ;
518
519
} ,
519
520
other => {
520
- if !ContainsRegion . visit_ty ( place. ty ( & self . body . local_decls , self . cx . tcx ) . ty ) {
521
+ if ContainsRegion
522
+ . visit_ty ( place. ty ( & self . body . local_decls , self . cx . tcx ) . ty )
523
+ . is_continue ( )
524
+ {
521
525
return ;
522
526
}
523
527
rvalue_locals ( other, |rhs| {
@@ -539,7 +543,7 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
539
543
// If the call returns something with lifetimes,
540
544
// let's conservatively assume the returned value contains lifetime of all the arguments.
541
545
// For example, given `let y: Foo<'a> = foo(x)`, `y` is considered to be a possible borrower of `x`.
542
- if ! ContainsRegion . visit_ty ( & self . body . local_decls [ * dest] . ty ) {
546
+ if ContainsRegion . visit_ty ( & self . body . local_decls [ * dest] . ty ) . is_continue ( ) {
543
547
return ;
544
548
}
545
549
@@ -558,8 +562,8 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
558
562
struct ContainsRegion ;
559
563
560
564
impl TypeVisitor < ' _ > for ContainsRegion {
561
- fn visit_region ( & mut self , _: ty:: Region < ' _ > ) -> bool {
562
- true
565
+ fn visit_region ( & mut self , _: ty:: Region < ' _ > ) -> ControlFlow < ( ) > {
566
+ ControlFlow :: BREAK
563
567
}
564
568
}
565
569
0 commit comments