Fix useless_format false positive
This commit is contained in:
parent
3fc8dae46c
commit
20dbb277cf
@ -12,6 +12,7 @@
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::sym;
|
||||
use rustc_span::symbol::kw;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for the use of `format!("string literal with no
|
||||
@ -157,7 +158,8 @@ fn on_new_v1_fmt<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<S
|
||||
if let ExprKind::Array(pieces) = arr.kind;
|
||||
if pieces.len() == 1;
|
||||
if let ExprKind::Lit(ref lit) = pieces[0].kind;
|
||||
if let LitKind::Str(..) = lit.node;
|
||||
if let LitKind::Str(symbol, _) = lit.node;
|
||||
if symbol == kw::Empty;
|
||||
// Argument 2 in `new_v1_formatted()`
|
||||
if let ExprKind::AddrOf(BorrowKind::Ref, _, arg1) = args[1].kind;
|
||||
if let ExprKind::Match(matchee, arms, MatchSource::Normal) = arg1.kind;
|
||||
|
@ -69,4 +69,6 @@ fn main() {
|
||||
// Wrap it with braces
|
||||
let v: Vec<String> = vec!["foo".to_string(), "bar".to_string()];
|
||||
let _s: String = (&*v.join("\n")).to_string();
|
||||
|
||||
format!("prepend {:+}", "s");
|
||||
}
|
||||
|
@ -71,4 +71,6 @@ fn main() {
|
||||
// Wrap it with braces
|
||||
let v: Vec<String> = vec!["foo".to_string(), "bar".to_string()];
|
||||
let _s: String = format!("{}", &*v.join("\n"));
|
||||
|
||||
format!("prepend {:+}", "s");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user