@@ -62,7 +62,6 @@ use syntax::ast_map;
62
62
use syntax:: attr;
63
63
use syntax:: attr:: { AttrMetaMethods , AttributeMethods } ;
64
64
use syntax:: codemap:: Span ;
65
- use syntax:: codemap;
66
65
use syntax:: parse:: token;
67
66
use syntax:: { ast, ast_util, visit} ;
68
67
use syntax:: ast_util:: IdVisitingOperation ;
@@ -590,11 +589,16 @@ fn check_while_true_expr(cx: &Context, e: &ast::Expr) {
590
589
match e. node {
591
590
ast:: ExprWhile ( cond, _) => {
592
591
match cond. node {
593
- ast:: ExprLit ( @codemap:: Spanned {
594
- node : ast:: LitBool ( true ) , ..} ) =>
595
- {
596
- cx. span_lint ( WhileTrue , e. span ,
597
- "denote infinite loops with loop { ... }" ) ;
592
+ ast:: ExprLit ( lit) => {
593
+ match lit. node {
594
+ ast:: LitBool ( true ) => {
595
+ cx. span_lint ( WhileTrue ,
596
+ e. span ,
597
+ "denote infinite loops with loop \
598
+ { ... }") ;
599
+ }
600
+ _ => { }
601
+ }
598
602
}
599
603
_ => ( )
600
604
}
@@ -989,9 +993,15 @@ fn check_heap_expr(cx: &Context, e: &ast::Expr) {
989
993
990
994
fn check_path_statement ( cx : & Context , s : & ast:: Stmt ) {
991
995
match s. node {
992
- ast:: StmtSemi ( @ast:: Expr { node : ast:: ExprPath ( _) , .. } , _) => {
993
- cx. span_lint ( PathStatement , s. span ,
994
- "path statement with no effect" ) ;
996
+ ast:: StmtSemi ( expr, _) => {
997
+ match expr. node {
998
+ ast:: ExprPath ( _) => {
999
+ cx. span_lint ( PathStatement ,
1000
+ s. span ,
1001
+ "path statement with no effect" ) ;
1002
+ }
1003
+ _ => { }
1004
+ }
995
1005
}
996
1006
_ => ( )
997
1007
}
@@ -1132,7 +1142,9 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
1132
1142
ast:: ExprVstore ( e2, ast:: ExprVstoreUniq ) |
1133
1143
ast:: ExprVstore ( e2, ast:: ExprVstoreBox ) => {
1134
1144
match e2. node {
1135
- ast:: ExprLit ( @codemap:: Spanned { node : ast:: LitStr ( ..) , ..} ) |
1145
+ ast:: ExprLit ( lit) if ast_util:: lit_is_str ( lit) => {
1146
+ VectorAllocation
1147
+ }
1136
1148
ast:: ExprVec ( ..) => VectorAllocation ,
1137
1149
_ => return
1138
1150
}
@@ -1152,18 +1164,27 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
1152
1164
adjustments. get ( ) . find_copy ( & e. id )
1153
1165
} ;
1154
1166
match adjustment {
1155
- Some ( @ty:: AutoDerefRef ( ty:: AutoDerefRef { autoref, .. } ) ) => {
1156
- match ( allocation, autoref) {
1157
- ( VectorAllocation , Some ( ty:: AutoBorrowVec ( ..) ) ) => {
1158
- report ( "unnecessary allocation, the sigil can be removed" ) ;
1159
- }
1160
- ( BoxAllocation , Some ( ty:: AutoPtr ( _, ast:: MutImmutable ) ) ) => {
1161
- report ( "unnecessary allocation, use & instead" ) ;
1162
- }
1163
- ( BoxAllocation , Some ( ty:: AutoPtr ( _, ast:: MutMutable ) ) ) => {
1164
- report ( "unnecessary allocation, use &mut instead" ) ;
1167
+ Some ( adjustment) => {
1168
+ match * adjustment {
1169
+ ty:: AutoDerefRef ( ty:: AutoDerefRef { autoref, .. } ) => {
1170
+ match ( allocation, autoref) {
1171
+ ( VectorAllocation , Some ( ty:: AutoBorrowVec ( ..) ) ) => {
1172
+ report ( "unnecessary allocation, the sigil can be \
1173
+ removed") ;
1174
+ }
1175
+ ( BoxAllocation ,
1176
+ Some ( ty:: AutoPtr ( _, ast:: MutImmutable ) ) ) => {
1177
+ report ( "unnecessary allocation, use & instead" ) ;
1178
+ }
1179
+ ( BoxAllocation ,
1180
+ Some ( ty:: AutoPtr ( _, ast:: MutMutable ) ) ) => {
1181
+ report ( "unnecessary allocation, use &mut \
1182
+ instead") ;
1183
+ }
1184
+ _ => ( )
1185
+ }
1165
1186
}
1166
- _ => ( )
1187
+ _ => { }
1167
1188
}
1168
1189
}
1169
1190
0 commit comments