@@ -18,6 +18,7 @@ use rustc_mir::dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, Re
1818use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
1919use rustc_span:: source_map:: { BytePos , Span } ;
2020use std:: convert:: TryFrom ;
21+ use std:: ops:: ControlFlow ;
2122
2223macro_rules! unwrap_or_continue {
2324 ( $x: expr) => {
@@ -517,7 +518,10 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
517518 self . possible_borrower . add ( borrowed. local , lhs) ;
518519 } ,
519520 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+ {
521525 return ;
522526 }
523527 rvalue_locals ( other, |rhs| {
@@ -539,7 +543,7 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
539543 // If the call returns something with lifetimes,
540544 // let's conservatively assume the returned value contains lifetime of all the arguments.
541545 // 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 ( ) {
543547 return ;
544548 }
545549
@@ -558,8 +562,8 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
558562struct ContainsRegion ;
559563
560564impl 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
563567 }
564568}
565569
0 commit comments