-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics
Description
Currently, attempting to compile code that expects a String
while providing an &'static str
causes the following to be shown:
error[E0308]: mismatched types
--> src/incoming.rs:70:90
|
70 | timestamp: headers.get_raw("x-timestamp").unwrap_or(ErrorKind::MissingHeader("x-timestamp"))?,
| ^^^^^^^^^^^^^ expected struct `std::string::String`, found reference
|
= note: expected type `std::string::String`
found type `&'static str`
= help: here are some functions which might fulfill your needs:
- .escape_debug()
- .escape_default()
- .escape_unicode()
- .to_lowercase()
- .to_uppercase()
I'm guessing that these suggestions are automatically generated/derived by the compiler, but none of them are good "generic" suggestions.
The compiler should probably suggest either .to_owned()
or .into()
in this case instead.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics