Merge pull request #1978 from rust-lang-nursery/fix-768

fix #768 by checking for message macro expansion
This commit is contained in:
Oliver Schneider 2017-08-22 10:15:32 +02:00 committed by GitHub
commit 6649cb3672
3 changed files with 11 additions and 10 deletions

View File

@ -45,7 +45,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
is_direct_expn_of(expr.span, "panic").is_some(),
let LitKind::Str(ref string, _) = lit.node,
let Some(par) = string.as_str().find('{'),
string.as_str()[par..].contains('}')
string.as_str()[par..].contains('}'),
params[0].span.source_callee().is_none()
], {
span_lint(cx, PANIC_PARAMS, params[0].span,
"you probably are missing some parameter in your format string");

View File

@ -34,10 +34,18 @@ fn ok_bracket() {
}
}
const ONE : u32= 1;
fn ok_nomsg() {
assert!({ 1 == ONE });
assert!(if 1 == ONE { ONE == 1 } else { false });
}
fn main() {
missing();
ok_single();
ok_multiple();
ok_bracket();
ok_inner();
ok_nomsg();
}

View File

@ -18,13 +18,5 @@ error: you probably are missing some parameter in your format string
12 | assert!(true, "here be missing values: {}");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you probably are missing some parameter in your format string
--> $DIR/panic.rs:22:5
|
22 | assert!("foo bar".contains(&format!("foo {}", "bar")));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in a macro outside of the current crate
error: aborting due to 4 previous errors
error: aborting due to 3 previous errors