1
1
use rustc:: lint:: * ;
2
2
use rustc_front:: hir:: * ;
3
3
use syntax:: ast:: LitKind ;
4
- use utils:: { span_lint, in_external_macro , match_path, BEGIN_UNWIND } ;
4
+ use utils:: { span_lint, is_direct_expn_of , match_path, BEGIN_UNWIND } ;
5
5
6
6
/// **What it does:** This lint checks for missing parameters in `panic!`.
7
7
///
@@ -28,24 +28,20 @@ impl LintPass for PanicPass {
28
28
impl LateLintPass for PanicPass {
29
29
fn check_expr ( & mut self , cx : & LateContext , expr : & Expr ) {
30
30
if_let_chain ! { [
31
- in_external_macro( cx, expr. span) ,
32
31
let ExprBlock ( ref block) = expr. node,
33
32
let Some ( ref ex) = block. expr,
34
33
let ExprCall ( ref fun, ref params) = ex. node,
35
34
params. len( ) == 2 ,
36
35
let ExprPath ( None , ref path) = fun. node,
37
36
match_path( path, & BEGIN_UNWIND ) ,
38
37
let ExprLit ( ref lit) = params[ 0 ] . node,
38
+ is_direct_expn_of( cx, params[ 0 ] . span, "panic" ) . is_some( ) ,
39
39
let LitKind :: Str ( ref string, _) = lit. node,
40
40
let Some ( par) = string. find( '{' ) ,
41
- string[ par..] . contains( '}' ) ,
42
- let Some ( sp) = cx. sess( ) . codemap( )
43
- . with_expn_info( expr. span. expn_id,
44
- |info| info. map( |i| i. call_site) )
41
+ string[ par..] . contains( '}' )
45
42
] , {
46
-
47
- span_lint( cx, PANIC_PARAMS , sp,
48
- "You probably are missing some parameter in your `panic!` call" ) ;
43
+ span_lint( cx, PANIC_PARAMS , params[ 0 ] . span,
44
+ "you probably are missing some parameter in your format string" ) ;
49
45
} }
50
46
}
51
47
}
0 commit comments