@@ -24,7 +24,8 @@ at all.
24
24
enum lint {
25
25
ctypes,
26
26
unused_imports,
27
- while_true
27
+ while_true,
28
+ path_statement,
28
29
}
29
30
30
31
enum level {
@@ -56,7 +57,13 @@ fn get_lint_dict() -> lint_dict {
56
57
( "while_true" ,
57
58
@{ lint: while_true,
58
59
desc: "suggest using loop { } instead of while(true) { }" ,
60
+ default : warn} ) ,
61
+
62
+ ( "path_statement" ,
63
+ @{ lint: path_statement,
64
+ desc: "path statements with no effect" ,
59
65
default : warn} )
66
+
60
67
] ;
61
68
hash_from_strs ( v)
62
69
}
@@ -177,6 +184,7 @@ fn check_item(cx: ctxt, i: @ast::item) {
177
184
ctypes { check_item_ctypes( cx, level, i) ; }
178
185
unused_imports { check_item_unused_imports( cx, level, i) ; }
179
186
while_true { check_item_while_true( cx, level, i) ; }
187
+ path_statement { check_item_path_statement( cx, level, i) ; }
180
188
}
181
189
}
182
190
}
@@ -252,6 +260,25 @@ fn check_item_ctypes(cx: ctxt, level: level, it: @ast::item) {
252
260
}
253
261
}
254
262
263
+ fn check_item_path_statement ( cx : ctxt , level : level , it : @ast:: item ) {
264
+ let visit = visit:: mk_simple_visitor ( @{
265
+ visit_stmt : fn @( s: @ast:: stmt) {
266
+ alt s. node {
267
+ ast:: stmt_semi ( @{ id: _,
268
+ node: ast:: expr_path ( @path) ,
269
+ span: _} , _) {
270
+ cx. span_lint (
271
+ level, s. span ,
272
+ "path statement with no effect" ) ;
273
+ }
274
+ _ { }
275
+ }
276
+ }
277
+ with * visit:: default_simple_visitor ( )
278
+ } ) ;
279
+ visit:: visit_item ( it, ( ) , visit) ;
280
+ }
281
+
255
282
256
283
fn check_crate ( tcx : ty:: ctxt , crate : @ast:: crate ,
257
284
lint_opts : [ ( lint , level ) ] , time_pass : bool ) {
0 commit comments