-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
chore: multipart_suggestions for manual_assert #13787
base: master
Are you sure you want to change the base?
chore: multipart_suggestions for manual_assert #13787
Conversation
a2618b9
to
09589ff
Compare
I could use a pointer on this one. We're trying to avoid displaying any comments that are captured within the span including the if/assert block, and only retain them in the tool-applied suggestion: rust-clippy/clippy_lints/src/manual_assert.rs Lines 68 to 84 in f83a227
I've preserved this here by keeping the tool-only suggestion, and replacing only the
The second case fails the testing, because the if/assert has not been removed. I think this is the correct behaviour from the runtime perspective, but because the testing framework automatically diverges when there are multiple suggestions, i'm stuck. Options I see:
Any tips @y21 ? |
I suppose there would also be the option to have a single multipart suggestion that removes the |
Cheers @y21 - i'll add them back in and see where we land 🙌 |
bc9e5a6
to
e146ead
Compare
@@ -77,19 +77,25 @@ LL | | panic!("panic with comment") // comment after `panic!` | |||
LL | | } | |||
| |_____^ | |||
| | |||
help: try instead | |||
help: replace `if`-then-`panic!` with `assert!` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@y21 here's the change discussed in action with the comment preservation in the UI output
Hey @y21 , do you have a chance to look at this? We are inches away from finishing the whole issue 🤣 |
Sorry for the delay, will try to get to this soon (probably this weekend). I have a bunch of other PRs + other stuff going on at the same time |
Sorry I figured it might’ve fallen through the cracks! It’s probably not a high priority so no stress. Hope you can have a good break! |
clippy_lints/src/manual_assert.rs
Outdated
let suggestions = if comments.is_empty() { | ||
vec![(expr.span, base_sugg.clone())] | ||
} else { | ||
vec![(expr.span.shrink_to_lo(), comments), (expr.span, base_sugg.clone())] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current suggestion looks a little weird in the diagnostic with the colors
I suspect this is because the two replacements are at the same span, but I think it would be nice for this to also be properly indented.
We could probably combine these two replacement strings comments + base_sugg
into one, and pass that combined string to the util function reindent_multiline
, with the indent obtained from the other util function indent_of(expr.span)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @y21 good catch! i'm running on low capacity until after the break but i'll polish this up and ping you in the coming weeks 💪
This comment has been minimized.
This comment has been minimized.
7a68957
to
a805a6f
Compare
a805a6f
to
5e448ee
Compare
This should address #13099 for the let_unit test.
changelog: [manual_assert]: Updated manual_assert to use multipart_suggestions where appropriate