into_string() -> to_owned() (fix #27)
This commit is contained in:
parent
b7ecb6e7c7
commit
538db34e60
@ -49,7 +49,7 @@ impl LintPass for MiscPass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare_lint!(pub STR_TO_STRING, Warn, "Warn when a String could use into_string() instead of to_string()");
|
declare_lint!(pub STR_TO_STRING, Warn, "Warn when a String could use to_owned() instead of to_string()");
|
||||||
|
|
||||||
#[allow(missing_copy_implementations)]
|
#[allow(missing_copy_implementations)]
|
||||||
pub struct StrToStringPass;
|
pub struct StrToStringPass;
|
||||||
@ -64,7 +64,7 @@ impl LintPass for StrToStringPass {
|
|||||||
ast::ExprMethodCall(ref method, _, ref args)
|
ast::ExprMethodCall(ref method, _, ref args)
|
||||||
if method.node.as_str() == "to_string"
|
if method.node.as_str() == "to_string"
|
||||||
&& is_str(cx, &*args[0]) => {
|
&& is_str(cx, &*args[0]) => {
|
||||||
cx.span_lint(STR_TO_STRING, expr.span, "str.into_string() is faster");
|
cx.span_lint(STR_TO_STRING, expr.span, "str.to_owned() is faster");
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user