mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Fix false-positive in panic_params
It might still have false positives, but it’s even less likely.
This commit is contained in:
parent
7eef989ff4
commit
0774b203f4
2 changed files with 19 additions and 4 deletions
|
@ -37,7 +37,8 @@ impl LateLintPass for PanicPass {
|
||||||
match_path(path, &BEGIN_UNWIND),
|
match_path(path, &BEGIN_UNWIND),
|
||||||
let ExprLit(ref lit) = params[0].node,
|
let ExprLit(ref lit) = params[0].node,
|
||||||
let LitKind::Str(ref string, _) = lit.node,
|
let LitKind::Str(ref string, _) = lit.node,
|
||||||
string.contains('{'),
|
let Some(par) = string.find('{'),
|
||||||
|
string[par..].contains('}'),
|
||||||
let Some(sp) = cx.sess().codemap()
|
let Some(sp) = cx.sess().codemap()
|
||||||
.with_expn_info(expr.span.expn_id,
|
.with_expn_info(expr.span.expn_id,
|
||||||
|info| info.map(|i| i.call_site))
|
|info| info.map(|i| i.call_site))
|
||||||
|
|
|
@ -4,10 +4,14 @@
|
||||||
#[deny(panic_params)]
|
#[deny(panic_params)]
|
||||||
|
|
||||||
fn missing() {
|
fn missing() {
|
||||||
panic!("{}"); //~ERROR: You probably are missing some parameter
|
if true {
|
||||||
|
panic!("{}"); //~ERROR: You probably are missing some parameter
|
||||||
|
} else {
|
||||||
|
panic!("{:?}"); //~ERROR: You probably are missing some parameter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ok_sigle() {
|
fn ok_single() {
|
||||||
panic!("foo bar");
|
panic!("foo bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +19,18 @@ fn ok_multiple() {
|
||||||
panic!("{}", "This is {ok}");
|
panic!("{}", "This is {ok}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn ok_bracket() {
|
||||||
|
// the match is just here because of #759, it serves no other purpose for the lint
|
||||||
|
match 42 {
|
||||||
|
1337 => panic!("{so is this"),
|
||||||
|
666 => panic!("so is this}"),
|
||||||
|
_ => panic!("}so is that{"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
missing();
|
missing();
|
||||||
ok_sigle();
|
ok_single();
|
||||||
ok_multiple();
|
ok_multiple();
|
||||||
|
ok_bracket();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue