- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
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-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code: playground
fn foo() -> bool {
    &
    if true { true } else { false }
}The current output is:
error[E0308]: mismatched types
 --> src/lib.rs:2:5
  |
1 |   fn foo() -> bool {
  |               ---- expected `bool` because of return type
2 | /     &
3 | |     if true { true } else { false }
  | |___________________________________^ expected `bool`, found `&bool`
  |
help: consider removing the borrow
  |
2 -     &
2 +     if true { true } else { false }
What's wrong
The suggestion looks weird, seeming to suggest removing & and replacing it with a duplicate of the line that follows it.
The actual fixup'd code (via cargo fix) isn't actually broken. cargo fix does the change as expected, removing just the &. So this leads me to believe this is instead just a bug in the code that renders suggestions.
@camelid spotted this in #91545 but this is not related to that PR.
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-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.