use crate::utils::paths;
use crate::utils::{
- is_expn_of, is_type_diagnostic_item, last_path_segment, match_def_path, match_function_call, snippet,
+ is_expn_of, is_type_diagnostic_item, last_path_segment, match_def_path, match_function_call, snippet, snippet_opt,
span_lint_and_then,
};
use if_chain::if_chain;
then {
// `format!("foo")` expansion contains `match () { () => [], }`
if tup.is_empty() {
- return Some(format!("{:?}.to_string()", s.as_str()));
+ if let Some(s_src) = snippet_opt(cx, lit.span) {
+ // Simulate macro expansion, converting {{ and }} to { and }.
+ let s_expand = s_src.replace("{{", "{").replace("}}", "}");
+ return Some(format!("{}.to_string()", s_expand))
+ }
} else if s.as_str().is_empty() {
return on_argumentv1_new(cx, &tup[0], arms);
}
LL | | r##"foo {{}}
LL | | " bar"##
LL | | );
- | |______^ help: consider using `.to_string()`: `"foo {}/n/" bar".to_string();`
+ | |______^
+ |
+help: consider using `.to_string()`
+ |
+LL | r##"foo {}
+LL | " bar"##.to_string();
+ |
error: useless use of `format!`
--> $DIR/format.rs:21:5