@@ -345,20 +345,18 @@ impl IrMaps {
345345 }
346346}
347347
348- struct ErrorCheckVisitor ;
349-
350- impl Visitor < @Liveness > for ErrorCheckVisitor {
351- fn visit_fn ( & mut self , fk : & fn_kind , fd : & fn_decl , b : & Block , s : Span , n : NodeId , e : @Liveness ) {
352- check_fn ( self , fk, fd, b, s, n, e) ;
348+ impl Visitor < ( ) > for Liveness {
349+ fn visit_fn ( & mut self , fk : & fn_kind , fd : & fn_decl , b : & Block , s : Span , n : NodeId , _: ( ) ) {
350+ check_fn ( self , fk, fd, b, s, n) ;
353351 }
354- fn visit_local ( & mut self , l : @Local , e : @ Liveness ) {
355- check_local ( self , l, e ) ;
352+ fn visit_local ( & mut self , l : @Local , _ : ( ) ) {
353+ check_local ( self , l) ;
356354 }
357- fn visit_expr ( & mut self , ex : @Expr , e : @ Liveness ) {
358- check_expr ( self , ex, e ) ;
355+ fn visit_expr ( & mut self , ex : @Expr , _ : ( ) ) {
356+ check_expr ( self , ex) ;
359357 }
360- fn visit_arm ( & mut self , a : & Arm , e : @ Liveness ) {
361- check_arm ( self , a, e ) ;
358+ fn visit_arm ( & mut self , a : & Arm , _ : ( ) ) {
359+ check_arm ( self , a) ;
362360 }
363361}
364362
@@ -419,12 +417,11 @@ fn visit_fn(v: &mut LivenessVisitor,
419417 } ;
420418
421419 // compute liveness
422- let lsets = @ Liveness ( fn_maps, specials) ;
423- let entry_ln = ( * lsets) . compute ( decl, body) ;
420+ let mut lsets = Liveness ( fn_maps, specials) ;
421+ let entry_ln = lsets. compute ( decl, body) ;
424422
425423 // check for various error conditions
426- let mut check_vt = ErrorCheckVisitor ;
427- check_vt. visit_block ( body, lsets) ;
424+ lsets. visit_block ( body, ( ) ) ;
428425 lsets. check_ret ( id, sp, fk, entry_ln) ;
429426 lsets. warn_about_unused_args ( decl, entry_ln) ;
430427}
@@ -1423,7 +1420,7 @@ impl Liveness {
14231420// _______________________________________________________________________
14241421// Checking for error conditions
14251422
1426- fn check_local( vt : & mut ErrorCheckVisitor , local : @Local , this : @ Liveness ) {
1423+ fn check_local( this : & mut Liveness , local : @Local ) {
14271424 match local. init {
14281425 Some ( _) => {
14291426 this. warn_about_unused_or_dead_vars_in_pat ( local. pat ) ;
@@ -1449,48 +1446,48 @@ fn check_local(vt: &mut ErrorCheckVisitor, local: @Local, this: @Liveness) {
14491446 }
14501447 }
14511448
1452- visit:: walk_local ( vt , local, this ) ;
1449+ visit:: walk_local ( this , local, ( ) ) ;
14531450}
14541451
1455- fn check_arm( vt : & mut ErrorCheckVisitor , arm : & Arm , this : @ Liveness ) {
1452+ fn check_arm( this : & mut Liveness , arm : & Arm ) {
14561453 do this. arm_pats_bindings ( arm. pats ) |ln, var, sp, id| {
14571454 this. warn_about_unused ( sp, id, ln, var) ;
14581455 }
1459- visit:: walk_arm ( vt , arm, this ) ;
1456+ visit:: walk_arm ( this , arm, ( ) ) ;
14601457}
14611458
1462- fn check_expr ( vt : & mut ErrorCheckVisitor , expr : @Expr , this : @ Liveness ) {
1459+ fn check_expr ( this : & mut Liveness , expr : @Expr ) {
14631460 match expr. node {
14641461 ExprAssign ( l, r) => {
1465- this. check_lvalue ( l, vt ) ;
1466- vt . visit_expr ( r, this ) ;
1462+ this. check_lvalue ( l) ;
1463+ this . visit_expr ( r, ( ) ) ;
14671464
1468- visit:: walk_expr ( vt , expr, this ) ;
1465+ visit:: walk_expr ( this , expr, ( ) ) ;
14691466 }
14701467
14711468 ExprAssignOp ( _, _, l, _) => {
1472- this. check_lvalue ( l, vt ) ;
1469+ this. check_lvalue ( l) ;
14731470
1474- visit:: walk_expr ( vt , expr, this ) ;
1471+ visit:: walk_expr ( this , expr, ( ) ) ;
14751472 }
14761473
14771474 ExprInlineAsm ( ref ia) => {
14781475 for & ( _, input) in ia. inputs . iter ( ) {
1479- vt . visit_expr ( input, this ) ;
1476+ this . visit_expr ( input, ( ) ) ;
14801477 }
14811478
14821479 // Output operands must be lvalues
14831480 for & ( _, out) in ia. outputs . iter ( ) {
14841481 match out. node {
14851482 ExprAddrOf ( _, inner) => {
1486- this. check_lvalue ( inner, vt ) ;
1483+ this. check_lvalue ( inner) ;
14871484 }
14881485 _ => { }
14891486 }
1490- vt . visit_expr ( out, this ) ;
1487+ this . visit_expr ( out, ( ) ) ;
14911488 }
14921489
1493- visit:: walk_expr ( vt , expr, this ) ;
1490+ visit:: walk_expr ( this , expr, ( ) ) ;
14941491 }
14951492
14961493 // no correctness conditions related to liveness
@@ -1502,19 +1499,18 @@ fn check_expr(vt: &mut ErrorCheckVisitor, expr: @Expr, this: @Liveness) {
15021499 ExprAgain ( * ) | ExprLit ( _) | ExprBlock ( * ) |
15031500 ExprMac ( * ) | ExprAddrOf ( * ) | ExprStruct ( * ) | ExprRepeat ( * ) |
15041501 ExprParen ( * ) | ExprFnBlock ( * ) | ExprPath ( * ) | ExprSelf ( * ) => {
1505- visit:: walk_expr ( vt , expr, this ) ;
1502+ visit:: walk_expr ( this , expr, ( ) ) ;
15061503 }
15071504 ExprForLoop ( * ) => fail ! ( "non-desugared expr_for_loop" )
15081505 }
15091506}
15101507
1511- fn check_fn ( _v : & mut ErrorCheckVisitor ,
1508+ fn check_fn ( _v : & Liveness ,
15121509 _fk : & visit:: fn_kind ,
15131510 _decl : & fn_decl ,
15141511 _body : & Block ,
15151512 _sp : Span ,
1516- _id : NodeId ,
1517- _self : @Liveness ) {
1513+ _id : NodeId ) {
15181514 // do not check contents of nested fns
15191515}
15201516
@@ -1549,7 +1545,7 @@ impl Liveness {
15491545 }
15501546 }
15511547
1552- pub fn check_lvalue ( @ self , expr : @Expr , vt : & mut ErrorCheckVisitor ) {
1548+ pub fn check_lvalue ( & mut self , expr : @Expr ) {
15531549 match expr. node {
15541550 ExprPath ( _) => {
15551551 match self . tcx . def_map . get_copy ( & expr. id ) {
@@ -1578,7 +1574,7 @@ impl Liveness {
15781574 _ => {
15791575 // For other kinds of lvalues, no checks are required,
15801576 // and any embedded expressions are actually rvalues
1581- visit:: walk_expr ( vt , expr, self ) ;
1577+ visit:: walk_expr ( self , expr, ( ) ) ;
15821578 }
15831579 }
15841580 }
0 commit comments