Skip to content

Conversation

@samueltardieu
Copy link
Member

changelog: [comparison_chain]: give explicit help message showing a clear suggestion

Close #13739

@rustbot
Copy link
Collaborator

rustbot commented Nov 30, 2024

r? @Alexendoo

rustbot has assigned @Alexendoo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 30, 2024
@samueltardieu
Copy link
Member Author

r? @y21

@rustbot rustbot assigned y21 and unassigned Alexendoo Dec 5, 2024
"`if` chain can be rewritten with `match`",
None,
"consider rewriting the `if` chain to use `cmp` and `match`",
format!("consider rewriting the `if` chain with: `match {lhs}.cmp({rhs}) {{...}}`"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point now that we're giving code snippets to the user and reference real code the user wrote (esp. with the colon) I feel like it would make sense to start giving this its own actual verbose suggestion with Applicability::HasPlaceholders. That seems like it would also help with making it easier to spot this part of the diagnostic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean like this? (I just pushed a revised version)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant span_lint_and_then + span_suggestion_verbose, so that the suggestion gets put on its own line at the bottom, but this is fine too

Copy link
Member

@y21 y21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@y21 y21 added this pull request to the merge queue Dec 10, 2024
Merged via the queue into rust-lang:master with commit 59740a8 Dec 10, 2024
9 checks passed
@samueltardieu samueltardieu deleted the push-ukyxvovullmy branch December 30, 2024 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

comparison_chain false positive when constant depends on generic parameter

4 participants