Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrectly suggests replacing end characters of function call with double quotes #125595

Closed
berrymot opened this issue May 27, 2024 · 1 comment · Fixed by #125640
Closed

Incorrectly suggests replacing end characters of function call with double quotes #125595

berrymot opened this issue May 27, 2024 · 1 comment · Fixed by #125640
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@berrymot
Copy link

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

@berrymot berrymot added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 27, 2024
@berrymot berrymot changed the title Incorrectly suggests replacing Incorrectly suggests replacing end characters of function call with double quotes May 27, 2024
@workingjubilee workingjubilee added D-papercut Diagnostics: An error or lint that needs small tweaks. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels May 27, 2024
@fmease fmease added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. and removed D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels May 28, 2024
@fmease
Copy link
Member

fmease commented May 28, 2024

has to have regressed in #122217.

@fmease fmease self-assigned this May 28, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this issue May 28, 2024
Don't suggest turning non-char-literal exprs of ty `char` into string literals

Fixes rust-lang#125595.
Fixes rust-lang#125081.

r? estebank (rust-lang#122217) or compiler
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 28, 2024
Rollup merge of rust-lang#125640 - fmease:plz-no-stringify, r=estebank

Don't suggest turning non-char-literal exprs of ty `char` into string literals

Fixes rust-lang#125595.
Fixes rust-lang#125081.

r? estebank (rust-lang#122217) or compiler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants