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

View File

@ -41,7 +41,8 @@ impl LintPass for MethodsPass {
if obj_ty.sty == ty::TyStr { if obj_ty.sty == ty::TyStr {
span_lint(cx, STR_TO_STRING, expr.span, "`str.to_owned()` is faster"); span_lint(cx, STR_TO_STRING, expr.span, "`str.to_owned()` is faster");
} else if match_type(cx, obj_ty, &STRING_PATH) { } 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");
} }
} }
} }