// option. This file may not be copied, modified, or distributed
// except according to those terms.
-
use crate::rustc::hir::*;
use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use crate::rustc::{declare_tool_lint, lint_array};
-use if_chain::if_chain;
use crate::rustc::ty;
+use crate::rustc::{declare_tool_lint, lint_array};
+use crate::rustc_errors::Applicability;
use crate::syntax::ast::LitKind;
use crate::utils::paths;
-use crate::utils::{in_macro, is_expn_of, last_path_segment, match_def_path, match_type, opt_def_id, resolve_node, snippet, span_lint_and_then, walk_ptrs_ty};
-use crate::rustc_errors::Applicability;
+use crate::utils::{
+ in_macro, is_expn_of, last_path_segment, match_def_path, match_type, opt_def_id, resolve_node, snippet,
+ span_lint_and_then, walk_ptrs_ty,
+};
+use if_chain::if_chain;
/// **What it does:** Checks for the use of `format!("string literal with no
/// argument")` and `format!("{}", foo)` where `foo` is a string.
}
},
// `format!("foo")` expansion contains `match () { () => [], }`
- ExprKind::Match(ref matchee, _, _) => if let ExprKind::Tup(ref tup) = matchee.node {
- if tup.is_empty() {
- let sugg = format!("{}.to_string()", snippet(cx, expr.span, "<expr>").into_owned());
- span_lint_and_then(cx, USELESS_FORMAT, span, "useless use of `format!`", |db| {
- db.span_suggestion_with_applicability(
- span,
- "consider using .to_string()",
- sugg,
- Applicability::MachineApplicable, // snippet
- );
- });
+ ExprKind::Match(ref matchee, _, _) => {
+ if let ExprKind::Tup(ref tup) = matchee.node {
+ if tup.is_empty() {
+ let sugg = format!("{}.to_string()", snippet(cx, expr.span, "<expr>").into_owned());
+ span_lint_and_then(cx, USELESS_FORMAT, span, "useless use of `format!`", |db| {
+ db.span_suggestion_with_applicability(
+ span,
+ "consider using .to_string()",
+ sugg,
+ Applicability::MachineApplicable, // snippet
+ );
+ });
+ }
}
},
_ => (),