@@ -38,7 +38,7 @@ use middle::const_eval::{eval_const_expr_partial, ConstVal};
38
38
use middle:: const_eval:: EvalHint :: ExprTypeChecked ;
39
39
use rustc:: front:: map as hir_map;
40
40
use util:: nodemap:: { FnvHashMap , FnvHashSet , NodeSet } ;
41
- use lint:: { Level , LateContext , LintContext , LintPass , LintArray , Lint } ;
41
+ use lint:: { Level , LateContext , EarlyContext , LintContext , LintPass , LintArray , Lint } ;
42
42
43
43
use std:: collections:: HashSet ;
44
44
use std:: collections:: hash_map:: Entry :: { Occupied , Vacant } ;
@@ -1390,9 +1390,9 @@ declare_lint! {
1390
1390
pub struct UnusedParens ;
1391
1391
1392
1392
impl UnusedParens {
1393
- fn check_unused_parens_core ( & self , cx : & LateContext , value : & hir :: Expr , msg : & str ,
1393
+ fn check_unused_parens_core ( & self , cx : & EarlyContext , value : & ast :: Expr , msg : & str ,
1394
1394
struct_lit_needs_parens : bool ) {
1395
- if let hir :: ExprParen ( ref inner) = value. node {
1395
+ if let ast :: ExprParen ( ref inner) = value. node {
1396
1396
let necessary = struct_lit_needs_parens && contains_exterior_struct_lit ( & * * inner) ;
1397
1397
if !necessary {
1398
1398
cx. span_lint ( UNUSED_PARENS , value. span ,
@@ -1405,27 +1405,27 @@ impl UnusedParens {
1405
1405
/// delimiters, e.g. `X { y: 1 }`, `X { y: 1 }.method()`, `foo
1406
1406
/// == X { y: 1 }` and `X { y: 1 } == foo` all do, but `(X {
1407
1407
/// y: 1 }) == foo` does not.
1408
- fn contains_exterior_struct_lit ( value : & hir :: Expr ) -> bool {
1408
+ fn contains_exterior_struct_lit ( value : & ast :: Expr ) -> bool {
1409
1409
match value. node {
1410
- hir :: ExprStruct ( ..) => true ,
1410
+ ast :: ExprStruct ( ..) => true ,
1411
1411
1412
- hir :: ExprAssign ( ref lhs, ref rhs) |
1413
- hir :: ExprAssignOp ( _, ref lhs, ref rhs) |
1414
- hir :: ExprBinary ( _, ref lhs, ref rhs) => {
1412
+ ast :: ExprAssign ( ref lhs, ref rhs) |
1413
+ ast :: ExprAssignOp ( _, ref lhs, ref rhs) |
1414
+ ast :: ExprBinary ( _, ref lhs, ref rhs) => {
1415
1415
// X { y: 1 } + X { y: 2 }
1416
1416
contains_exterior_struct_lit ( & * * lhs) ||
1417
1417
contains_exterior_struct_lit ( & * * rhs)
1418
1418
}
1419
- hir :: ExprUnary ( _, ref x) |
1420
- hir :: ExprCast ( ref x, _) |
1421
- hir :: ExprField ( ref x, _) |
1422
- hir :: ExprTupField ( ref x, _) |
1423
- hir :: ExprIndex ( ref x, _) => {
1419
+ ast :: ExprUnary ( _, ref x) |
1420
+ ast :: ExprCast ( ref x, _) |
1421
+ ast :: ExprField ( ref x, _) |
1422
+ ast :: ExprTupField ( ref x, _) |
1423
+ ast :: ExprIndex ( ref x, _) => {
1424
1424
// &X { y: 1 }, X { y: 1 }.y
1425
1425
contains_exterior_struct_lit ( & * * x)
1426
1426
}
1427
1427
1428
- hir :: ExprMethodCall ( _, _, ref exprs) => {
1428
+ ast :: ExprMethodCall ( _, _, ref exprs) => {
1429
1429
// X { y: 1 }.bar(...)
1430
1430
contains_exterior_struct_lit ( & * exprs[ 0 ] )
1431
1431
}
@@ -1441,28 +1441,28 @@ impl LintPass for UnusedParens {
1441
1441
lint_array ! ( UNUSED_PARENS )
1442
1442
}
1443
1443
1444
- fn check_expr ( & mut self , cx : & LateContext , e : & hir :: Expr ) {
1444
+ fn check_ast_expr ( & mut self , cx : & EarlyContext , e : & ast :: Expr ) {
1445
1445
let ( value, msg, struct_lit_needs_parens) = match e. node {
1446
- hir :: ExprIf ( ref cond, _, _) => ( cond, "`if` condition" , true ) ,
1447
- hir :: ExprWhile ( ref cond, _, _) => ( cond, "`while` condition" , true ) ,
1448
- hir :: ExprMatch ( ref head, _, source) => match source {
1449
- hir :: MatchSource :: Normal => ( head, "`match` head expression" , true ) ,
1450
- hir :: MatchSource :: IfLetDesugar { .. } => ( head, "`if let` head expression" , true ) ,
1451
- hir :: MatchSource :: WhileLetDesugar => ( head, "`while let` head expression" , true ) ,
1452
- hir :: MatchSource :: ForLoopDesugar => ( head, "`for` head expression" , true ) ,
1446
+ ast :: ExprIf ( ref cond, _, _) => ( cond, "`if` condition" , true ) ,
1447
+ ast :: ExprWhile ( ref cond, _, _) => ( cond, "`while` condition" , true ) ,
1448
+ ast :: ExprMatch ( ref head, _, source) => match source {
1449
+ ast :: MatchSource :: Normal => ( head, "`match` head expression" , true ) ,
1450
+ ast :: MatchSource :: IfLetDesugar { .. } => ( head, "`if let` head expression" , true ) ,
1451
+ ast :: MatchSource :: WhileLetDesugar => ( head, "`while let` head expression" , true ) ,
1452
+ ast :: MatchSource :: ForLoopDesugar => ( head, "`for` head expression" , true ) ,
1453
1453
} ,
1454
- hir :: ExprRet ( Some ( ref value) ) => ( value, "`return` value" , false ) ,
1455
- hir :: ExprAssign ( _, ref value) => ( value, "assigned value" , false ) ,
1456
- hir :: ExprAssignOp ( _, _, ref value) => ( value, "assigned value" , false ) ,
1454
+ ast :: ExprRet ( Some ( ref value) ) => ( value, "`return` value" , false ) ,
1455
+ ast :: ExprAssign ( _, ref value) => ( value, "assigned value" , false ) ,
1456
+ ast :: ExprAssignOp ( _, _, ref value) => ( value, "assigned value" , false ) ,
1457
1457
_ => return
1458
1458
} ;
1459
1459
self . check_unused_parens_core ( cx, & * * value, msg, struct_lit_needs_parens) ;
1460
1460
}
1461
1461
1462
- fn check_stmt ( & mut self , cx : & LateContext , s : & hir :: Stmt ) {
1462
+ fn check_ast_stmt ( & mut self , cx : & EarlyContext , s : & ast :: Stmt ) {
1463
1463
let ( value, msg) = match s. node {
1464
- hir :: StmtDecl ( ref decl, _) => match decl. node {
1465
- hir :: DeclLocal ( ref local) => match local. init {
1464
+ ast :: StmtDecl ( ref decl, _) => match decl. node {
1465
+ ast :: DeclLocal ( ref local) => match local. init {
1466
1466
Some ( ref value) => ( value, "assigned value" ) ,
1467
1467
None => return
1468
1468
} ,
0 commit comments