File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ impl LateLintPass for PanicPass {
37
37
match_path( path, & BEGIN_UNWIND ) ,
38
38
let ExprLit ( ref lit) = params[ 0 ] . node,
39
39
let LitKind :: Str ( ref string, _) = lit. node,
40
- string. contains( '{' ) ,
40
+ let Some ( par) = string. find( '{' ) ,
41
+ string[ par..] . contains( '}' ) ,
41
42
let Some ( sp) = cx. sess( ) . codemap( )
42
43
. with_expn_info( expr. span. expn_id,
43
44
|info| info. map( |i| i. call_site) )
Original file line number Diff line number Diff line change 4
4
#[ deny( panic_params) ]
5
5
6
6
fn missing ( ) {
7
- panic ! ( "{}" ) ; //~ERROR: You probably are missing some parameter
7
+ if true {
8
+ panic ! ( "{}" ) ; //~ERROR: You probably are missing some parameter
9
+ } else {
10
+ panic ! ( "{:?}" ) ; //~ERROR: You probably are missing some parameter
11
+ }
8
12
}
9
13
10
- fn ok_sigle ( ) {
14
+ fn ok_single ( ) {
11
15
panic ! ( "foo bar" ) ;
12
16
}
13
17
14
18
fn ok_multiple ( ) {
15
19
panic ! ( "{}" , "This is {ok}" ) ;
16
20
}
17
21
22
+ fn ok_bracket ( ) {
23
+ // the match is just here because of #759, it serves no other purpose for the lint
24
+ match 42 {
25
+ 1337 => panic ! ( "{so is this" ) ,
26
+ 666 => panic ! ( "so is this}" ) ,
27
+ _ => panic ! ( "}so is that{" ) ,
28
+ }
29
+ }
30
+
18
31
fn main ( ) {
19
32
missing ( ) ;
20
- ok_sigle ( ) ;
33
+ ok_single ( ) ;
21
34
ok_multiple ( ) ;
35
+ ok_bracket ( ) ;
22
36
}
You can’t perform that action at this time.
0 commit comments