cmp_owned current suggestion for multiple deref

This commit is contained in:
Josh Mcguigan 2018-10-11 05:03:02 -07:00
parent d41615548e
commit 0b65462ca5
2 changed files with 2 additions and 2 deletions

View File

@ -546,7 +546,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
} else if other_gets_derefed {
// suggest dropping the to_owned on the left and the deref on the right
let other_snippet = snippet(cx, other.span, "..").into_owned();
let other_without_deref = other_snippet.trim_left_matches('*');
let other_without_deref = other_snippet.replacen('*', "", 1);
(expr.span.to(other.span), format!("{} == {}", snip.to_string(), other_without_deref))
} else {

View File

@ -46,7 +46,7 @@ error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:47:5
|
47 | y.to_owned() == **x;
| ^^^^^^^^^^^^^^^^^^^ help: try: `y == x`
| ^^^^^^^^^^^^^^^^^^^ help: try: `y == *x`
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:54:9