Skip to content

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

Closed
@mi2ebi

Description

@mi2ebi

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

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on May 27, 2024
changed the title [-]Incorrectly suggests replacing [/-] [+]Incorrectly suggests replacing end characters of function call with double quotes[/+] on May 27, 2024
added
D-papercutDiagnostics: An error or lint that needs small tweaks.
D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.
on May 27, 2024
added
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.
and removed
D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.
on May 28, 2024
fmease

fmease commented on May 28, 2024

@fmease
Member

has to have regressed in #122217.

self-assigned this
on May 28, 2024
added a commit that references this issue on May 28, 2024

Rollup merge of rust-lang#125640 - fmease:plz-no-stringify, r=estebank

01aa2e8
added a commit that references this issue on May 28, 2024
5b7e1ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @fmease@workingjubilee@mi2ebi

    Issue actions

      Incorrectly suggests replacing end characters of function call with double quotes · Issue #125595 · rust-lang/rust