-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
On type mismatch with a suggestion to borrow in order to dereference a String
into a &str
, we should notice unnecessary .clone()
calls:
error[E0308]: mismatched types
--> src/main.rs:7:38
|
7 | assert_eq!(make_lipographic('e', passage.clone()), passage);
| ^^^^^^^^^^^^^^^
| |
| expected &str, found struct `std::string::String`
| help: consider borrowing here: `&passage.clone()`
|
= note: expected type `&str`
found type `std::string::String`
and suggest their removal:
error[E0308]: mismatched types
--> src/main.rs:7:38
|
7 | assert_eq!(make_lipographic('e', passage.clone()), passage);
| ^^^^^^^^^^^^^^^
| |
| expected &str, found struct `std::string::String`
| help: consider borrowing and avoiding the clone here: `&passage`
|
= note: expected type `&str`
found type `std::string::String`
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.