@@ -247,7 +247,7 @@ fn eq_label_lt(lt1: &Option<ast::Lifetime>, lt2: &Option<ast::Lifetime>) -> bool
247247
248248struct TreeWithDepthIterator {
249249 preorder : Preorder < RustLanguage > ,
250- depth : i32 ,
250+ depth : u32 ,
251251}
252252
253253impl TreeWithDepthIterator {
@@ -258,33 +258,31 @@ impl TreeWithDepthIterator {
258258}
259259
260260impl < ' a > Iterator for TreeWithDepthIterator {
261- type Item = ( ast:: Expr , i32 ) ;
261+ type Item = ( ast:: Expr , u32 ) ;
262262
263263 fn next ( & mut self ) -> Option < Self :: Item > {
264- while let Some ( ( event, expr ) ) = self . preorder . find_map ( |ev| match ev {
265- WalkEvent :: Enter ( it) => Some ( WalkEvent :: Enter ( ( ) ) ) . zip ( ast:: Expr :: cast ( it) ) ,
266- WalkEvent :: Leave ( it) => Some ( WalkEvent :: Leave ( ( ) ) ) . zip ( ast:: Expr :: cast ( it) ) ,
264+ while let Some ( event) = self . preorder . find_map ( |ev| match ev {
265+ WalkEvent :: Enter ( it) => ast:: Expr :: cast ( it) . map ( WalkEvent :: Enter ) ,
266+ WalkEvent :: Leave ( it) => ast:: Expr :: cast ( it) . map ( WalkEvent :: Leave ) ,
267267 } ) {
268- match ( event, expr) {
269- (
270- WalkEvent :: Enter ( _) ,
268+ match event {
269+ WalkEvent :: Enter (
271270 ast:: Expr :: LoopExpr ( _) | ast:: Expr :: WhileExpr ( _) | ast:: Expr :: ForExpr ( _) ,
272271 ) => {
273272 self . depth += 1 ;
274273 }
275- (
276- WalkEvent :: Leave ( _) ,
274+ WalkEvent :: Leave (
277275 ast:: Expr :: LoopExpr ( _) | ast:: Expr :: WhileExpr ( _) | ast:: Expr :: ForExpr ( _) ,
278276 ) => {
279277 self . depth -= 1 ;
280278 }
281- ( WalkEvent :: Enter ( _ ) , ast:: Expr :: BlockExpr ( e) ) if e. label ( ) . is_some ( ) => {
279+ WalkEvent :: Enter ( ast:: Expr :: BlockExpr ( e) ) if e. label ( ) . is_some ( ) => {
282280 self . depth += 1 ;
283281 }
284- ( WalkEvent :: Leave ( _ ) , ast:: Expr :: BlockExpr ( e) ) if e. label ( ) . is_some ( ) => {
282+ WalkEvent :: Leave ( ast:: Expr :: BlockExpr ( e) ) if e. label ( ) . is_some ( ) => {
285283 self . depth -= 1 ;
286284 }
287- ( WalkEvent :: Enter ( _ ) , expr) => return Some ( ( expr, self . depth ) ) ,
285+ WalkEvent :: Enter ( expr) => return Some ( ( expr, self . depth ) ) ,
288286 _ => ( ) ,
289287 }
290288 }
0 commit comments