mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 06:35:27 +00:00
cmp_owned correct error message if rhs is deref
This commit is contained in:
parent
0b65462ca5
commit
c9718fa589
@ -579,6 +579,10 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if other_gets_derefed {
|
||||
db.span_label(lint_span, "try implementing the comparison without allocating");
|
||||
return;
|
||||
}
|
||||
db.span_suggestion_with_applicability(
|
||||
lint_span,
|
||||
"try",
|
||||
|
@ -40,13 +40,13 @@ error: this creates an owned instance just for comparison
|
||||
--> $DIR/cmp_owned.rs:42:5
|
||||
|
|
||||
42 | y.to_owned() == *x;
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `y == x`
|
||||
| ^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating
|
||||
|
||||
error: this creates an owned instance just for comparison
|
||||
--> $DIR/cmp_owned.rs:47:5
|
||||
|
|
||||
47 | y.to_owned() == **x;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try: `y == *x`
|
||||
| ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating
|
||||
|
||||
error: this creates an owned instance just for comparison
|
||||
--> $DIR/cmp_owned.rs:54:9
|
||||
|
Loading…
Reference in New Issue
Block a user