When suggesting to borrow, remove useless clones

This commit is contained in:
Esteban Küber 2019-05-24 18:24:20 -07:00
parent 0e4a56b4b0
commit bdb05a84f3
3 changed files with 24 additions and 0 deletions

View file

@ -0,0 +1,6 @@
fn main() {
let x = String::new();
foo(x.clone()); //~ ERROR mismatched types
}
fn foo(_: &str) {}

View file

@ -0,0 +1,15 @@
error[E0308]: mismatched types
--> $DIR/issue-61106.rs:3:9
|
LL | foo(x.clone());
| ^^^^^^^^^
| |
| expected &str, found struct `std::string::String`
| help: consider borrowing here: `&x`
|
= note: expected type `&str`
found type `std::string::String`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.