methods: people might be using to_string() to make a copy; add a hint for that

This commit is contained in:
Georg Brandl 2015-08-25 12:45:52 +02:00
parent 802d56c46c
commit 81ef3da03c
1 changed files with 2 additions and 1 deletions

View File

@ -41,7 +41,8 @@ impl LintPass for MethodsPass {
if obj_ty.sty == ty::TyStr {
span_lint(cx, STR_TO_STRING, expr.span, "`str.to_owned()` is faster");
} else if match_type(cx, obj_ty, &STRING_PATH) {
span_lint(cx, STRING_TO_STRING, expr.span, "`String.to_string()` is a no-op");
span_lint(cx, STRING_TO_STRING, expr.span, "`String.to_string()` is a no-op; use \
`clone()` to make a copy");
}
}
}