-
Notifications
You must be signed in to change notification settings - Fork 893
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
fix: reject leading .
, )
without prefix as item marker
#5839
Conversation
c026b4b
to
f809481
Compare
cc @anforowicz to also take a look (who authorized #5423) |
@ytmimi Could you take a look? Since the bug and fix are both very straightforward, and it's newly introduced. Thanks. |
@xxchan I'm traveling over the next few days, but I should have some time to review this early next week. |
src/comment.rs
Outdated
if prefix.len() <= 2 && prefix.chars().all(|c| char::is_ascii_digit(&c)) { | ||
if (1..=2).contains(&prefix.len()) |
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.
Oh I see. If the prefix.len() == 0
the condition would still pass. Good catch. I'm wondering if there's a more obvious way to write this since it took me a few seconds to figure out what (1..=2).contains(..)
was doing.
Maybe assigning the condition to a meaningful variable name would help.
let has_leading_digits = (1..=2).contains(&prefix.len()) && prefix.chars().all(|c| char::is_ascii_digit(&c));
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.
@xxchan thanks for making the edit!
To further prevent this regression it would be great to add the example from #5835 (comment) as a test case in tests/target/
.
Happy to merge this after we add that test case and rebase on the latest master 😁
I haven't had a chance to look at this, but before merging, can we confirm this won't introduce a formatting diff (i.e. that this won't try to modify the output/result of a prior rustfmt run)? |
Yes, because it makes a condition triggering the fmt change more restrictive. |
a467946
to
7f9e3bb
Compare
@calebcartwright I ran the diff check job before the rebase and it failed ❌ for the same reason I explained in #5853 (comment). I'm running the job again now that the branch has been rebased. I'm assuming we should be good now 🤞🏼, but I'll follow up once the job completes. |
@xxchan the issue mentions that |
b4f78c7
to
9a8cc7e
Compare
@xxchan thanks again for your help on this one! |
fix #5835