@@ -345,20 +345,18 @@ impl IrMaps {
345
345
}
346
346
}
347
347
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) ;
353
351
}
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) ;
356
354
}
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) ;
359
357
}
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) ;
362
360
}
363
361
}
364
362
@@ -419,12 +417,11 @@ fn visit_fn(v: &mut LivenessVisitor,
419
417
} ;
420
418
421
419
// 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) ;
424
422
425
423
// check for various error conditions
426
- let mut check_vt = ErrorCheckVisitor ;
427
- check_vt. visit_block ( body, lsets) ;
424
+ lsets. visit_block ( body, ( ) ) ;
428
425
lsets. check_ret ( id, sp, fk, entry_ln) ;
429
426
lsets. warn_about_unused_args ( decl, entry_ln) ;
430
427
}
@@ -1423,7 +1420,7 @@ impl Liveness {
1423
1420
// _______________________________________________________________________
1424
1421
// Checking for error conditions
1425
1422
1426
- fn check_local( vt : & mut ErrorCheckVisitor , local : @Local , this : @ Liveness ) {
1423
+ fn check_local( this : & mut Liveness , local : @Local ) {
1427
1424
match local. init {
1428
1425
Some ( _) => {
1429
1426
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) {
1449
1446
}
1450
1447
}
1451
1448
1452
- visit:: walk_local ( vt , local, this ) ;
1449
+ visit:: walk_local ( this , local, ( ) ) ;
1453
1450
}
1454
1451
1455
- fn check_arm( vt : & mut ErrorCheckVisitor , arm : & Arm , this : @ Liveness ) {
1452
+ fn check_arm( this : & mut Liveness , arm : & Arm ) {
1456
1453
do this. arm_pats_bindings ( arm. pats ) |ln, var, sp, id| {
1457
1454
this. warn_about_unused ( sp, id, ln, var) ;
1458
1455
}
1459
- visit:: walk_arm ( vt , arm, this ) ;
1456
+ visit:: walk_arm ( this , arm, ( ) ) ;
1460
1457
}
1461
1458
1462
- fn check_expr ( vt : & mut ErrorCheckVisitor , expr : @Expr , this : @ Liveness ) {
1459
+ fn check_expr ( this : & mut Liveness , expr : @Expr ) {
1463
1460
match expr. node {
1464
1461
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, ( ) ) ;
1467
1464
1468
- visit:: walk_expr ( vt , expr, this ) ;
1465
+ visit:: walk_expr ( this , expr, ( ) ) ;
1469
1466
}
1470
1467
1471
1468
ExprAssignOp ( _, _, l, _) => {
1472
- this. check_lvalue ( l, vt ) ;
1469
+ this. check_lvalue ( l) ;
1473
1470
1474
- visit:: walk_expr ( vt , expr, this ) ;
1471
+ visit:: walk_expr ( this , expr, ( ) ) ;
1475
1472
}
1476
1473
1477
1474
ExprInlineAsm ( ref ia) => {
1478
1475
for & ( _, input) in ia. inputs . iter ( ) {
1479
- vt . visit_expr ( input, this ) ;
1476
+ this . visit_expr ( input, ( ) ) ;
1480
1477
}
1481
1478
1482
1479
// Output operands must be lvalues
1483
1480
for & ( _, out) in ia. outputs . iter ( ) {
1484
1481
match out. node {
1485
1482
ExprAddrOf ( _, inner) => {
1486
- this. check_lvalue ( inner, vt ) ;
1483
+ this. check_lvalue ( inner) ;
1487
1484
}
1488
1485
_ => { }
1489
1486
}
1490
- vt . visit_expr ( out, this ) ;
1487
+ this . visit_expr ( out, ( ) ) ;
1491
1488
}
1492
1489
1493
- visit:: walk_expr ( vt , expr, this ) ;
1490
+ visit:: walk_expr ( this , expr, ( ) ) ;
1494
1491
}
1495
1492
1496
1493
// no correctness conditions related to liveness
@@ -1502,19 +1499,18 @@ fn check_expr(vt: &mut ErrorCheckVisitor, expr: @Expr, this: @Liveness) {
1502
1499
ExprAgain ( * ) | ExprLit ( _) | ExprBlock ( * ) |
1503
1500
ExprMac ( * ) | ExprAddrOf ( * ) | ExprStruct ( * ) | ExprRepeat ( * ) |
1504
1501
ExprParen ( * ) | ExprFnBlock ( * ) | ExprPath ( * ) | ExprSelf ( * ) => {
1505
- visit:: walk_expr ( vt , expr, this ) ;
1502
+ visit:: walk_expr ( this , expr, ( ) ) ;
1506
1503
}
1507
1504
ExprForLoop ( * ) => fail ! ( "non-desugared expr_for_loop" )
1508
1505
}
1509
1506
}
1510
1507
1511
- fn check_fn ( _v : & mut ErrorCheckVisitor ,
1508
+ fn check_fn ( _v : & Liveness ,
1512
1509
_fk : & visit:: fn_kind ,
1513
1510
_decl : & fn_decl ,
1514
1511
_body : & Block ,
1515
1512
_sp : Span ,
1516
- _id : NodeId ,
1517
- _self : @Liveness ) {
1513
+ _id : NodeId ) {
1518
1514
// do not check contents of nested fns
1519
1515
}
1520
1516
@@ -1549,7 +1545,7 @@ impl Liveness {
1549
1545
}
1550
1546
}
1551
1547
1552
- pub fn check_lvalue ( @ self , expr : @Expr , vt : & mut ErrorCheckVisitor ) {
1548
+ pub fn check_lvalue ( & mut self , expr : @Expr ) {
1553
1549
match expr. node {
1554
1550
ExprPath ( _) => {
1555
1551
match self . tcx . def_map . get_copy ( & expr. id ) {
@@ -1578,7 +1574,7 @@ impl Liveness {
1578
1574
_ => {
1579
1575
// For other kinds of lvalues, no checks are required,
1580
1576
// and any embedded expressions are actually rvalues
1581
- visit:: walk_expr ( vt , expr, self ) ;
1577
+ visit:: walk_expr ( self , expr, ( ) ) ;
1582
1578
}
1583
1579
}
1584
1580
}
0 commit comments