When suggesting to borrow, remove useless clones
This commit is contained in:
parent
0e4a56b4b0
commit
bdb05a84f3
3 changed files with 24 additions and 0 deletions
6
src/test/ui/issues/issue-61106.rs
Normal file
6
src/test/ui/issues/issue-61106.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
fn main() {
|
||||
let x = String::new();
|
||||
foo(x.clone()); //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn foo(_: &str) {}
|
||||
15
src/test/ui/issues/issue-61106.stderr
Normal file
15
src/test/ui/issues/issue-61106.stderr
Normal 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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue