@@ -109,30 +109,43 @@ pub fn for_each_expr<'tcx, B, C: Continue>(
109
109
res : Option < B > ,
110
110
}
111
111
impl < ' tcx , B , C : Continue , F : FnMut ( & ' tcx Expr < ' tcx > ) -> ControlFlow < B , C > > Visitor < ' tcx > for V < B , F > {
112
- fn visit_expr ( & mut self , e : & ' tcx Expr < ' tcx > ) {
112
+ type Result = ControlFlow < ( ) > ;
113
+
114
+ fn visit_expr ( & mut self , e : & ' tcx Expr < ' tcx > ) -> ControlFlow < ( ) > {
113
115
if self . res . is_some ( ) {
114
- return ;
116
+ return ControlFlow :: Break ( ( ) ) ;
115
117
}
116
118
match ( self . f ) ( e) {
117
119
ControlFlow :: Continue ( c) if c. descend ( ) => walk_expr ( self , e) ,
118
- ControlFlow :: Break ( b) => self . res = Some ( b) ,
119
- ControlFlow :: Continue ( _) => ( ) ,
120
+ ControlFlow :: Break ( b) => {
121
+ self . res = Some ( b) ;
122
+ ControlFlow :: Break ( ( ) )
123
+ } ,
124
+ ControlFlow :: Continue ( _) => ControlFlow :: Continue ( ( ) ) ,
120
125
}
121
126
}
122
127
123
128
// Avoid unnecessary `walk_*` calls.
124
- fn visit_ty ( & mut self , _: & ' tcx hir:: Ty < ' tcx > ) { }
125
- fn visit_pat ( & mut self , _: & ' tcx Pat < ' tcx > ) { }
126
- fn visit_qpath ( & mut self , _: & ' tcx QPath < ' tcx > , _: HirId , _: Span ) { }
129
+ fn visit_ty ( & mut self , _: & ' tcx hir:: Ty < ' tcx > ) -> ControlFlow < ( ) > {
130
+ ControlFlow :: Continue ( ( ) )
131
+ }
132
+ fn visit_pat ( & mut self , _: & ' tcx Pat < ' tcx > ) -> ControlFlow < ( ) > {
133
+ ControlFlow :: Continue ( ( ) )
134
+ }
135
+ fn visit_qpath ( & mut self , _: & ' tcx QPath < ' tcx > , _: HirId , _: Span ) -> ControlFlow < ( ) > {
136
+ ControlFlow :: Continue ( ( ) )
137
+ }
127
138
// Avoid monomorphising all `visit_*` functions.
128
- fn visit_nested_item ( & mut self , _: ItemId ) { }
139
+ fn visit_nested_item ( & mut self , _: ItemId ) -> ControlFlow < ( ) > {
140
+ ControlFlow :: Continue ( ( ) )
141
+ }
129
142
}
130
143
let mut v = V { f, res : None } ;
131
144
node. visit ( & mut v) ;
132
145
v. res
133
146
}
134
147
135
- /// Calls the given function once for each expression contained. This will enter bodies, but not
148
+ /// Calls the given function once for each expression contained. This will enter bodies, bzut not
136
149
/// nested items.
137
150
pub fn for_each_expr_with_closures < ' tcx , B , C : Continue > (
138
151
cx : & LateContext < ' tcx > ,
0 commit comments