Closed
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
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the compiler team, which will review and decide on the PR/issue.