Closed
Description
Code
fn example() -> char { 't' }
let mut s = "rus".to_string();
s += example();
Current output
error[E0308]: mismatched types
--> src\tools.rs:100:10
|
100 | s += example();
| ^^^^^^^^^ expected `&str`, found `char`
|
help: if you meant to write a string literal, use double quotes
|
100 | s += "xample(";
| ~ ~
Desired output
error[E0308]: mismatched types
--> src\tools.rs:100:10
|
100 | s += example();
| ^^^^^^^^^ expected `&str`, found `char`
|
help: [something better]
|
100 | s += &example().to_string();
| + ++++++++++++
Rationale and extra context
No response
Other cases
No response
Rust Version
rustc 1.80.0-nightly (78a775127 2024-05-11)
binary: rustc
commit-hash: 78a77512702ab786f6f9345872d36d852454612c
commit-date: 2024-05-11
host: x86_64-pc-windows-msvc
release: 1.80.0-nightly
LLVM version: 18.1.4
Anything else?
No response
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: A structured suggestion resulting in incorrect code.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.