mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 06:35:27 +00:00
cmp_owned current suggestion for multiple deref
This commit is contained in:
parent
d41615548e
commit
0b65462ca5
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user