Skip to content
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

New lint [four_forward_slashes] #11140

Merged
merged 2 commits into from
Jul 18, 2023
Merged

Conversation

Centri3
Copy link
Member

@Centri3 Centri3 commented Jul 12, 2023

Closes #9212

changelog: New lint [four_forward_slashes]

@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 2023

r? @xFrednet

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 12, 2023
@xFrednet
Copy link
Member

r$ @blyxyas

(xFrednet has picked a reviewer for you, use r$ to override)

Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

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

I cannot stop thinking about rustc_ast::util::comments::gather_comments, it returns a Vec<Comment> and that could be used to check if the comment starts with // or //// (I'm not sure Comment also includes the initial //).

It would be simpler, but we'd have to do a benchmark to verify speed. Maybe SPEEDTEST can help with that?

clippy_lints/src/four_forward_slashes.rs Outdated Show resolved Hide resolved
tests/ui/four_forward_slashes.stderr Outdated Show resolved Hide resolved
@Centri3
Copy link
Member Author

Centri3 commented Jul 12, 2023

gather_comments may work, but from what I can see it'd do a lot more work for the same result. Even just allocating an empty Vec, then increasing its capacity every time a comment is found, would be slow.

Perhaps we can use the lexer though. I hadn't thought to and that may be nicer

@Centri3
Copy link
Member Author

Centri3 commented Jul 13, 2023

Unfortunately gather_comments won't work. It doesn't give the span of the comment, only the column it starts at (Comment.pos).

Make it trim the contents
Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks! ❤️
cc @xFrednet

@xFrednet
Copy link
Member

I'm sadly busy until Tuesday/Wednesday, but then I'll do the last check. :)

@xFrednet
Copy link
Member

I have full trust in your review:

@bors r=blyxyas

@bors
Copy link
Contributor

bors commented Jul 18, 2023

📌 Commit 2e43d0c has been approved by blyxyas

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 18, 2023

⌛ Testing commit 2e43d0c with merge 9f0cbfd...

@bors
Copy link
Contributor

bors commented Jul 18, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: blyxyas
Pushing 9f0cbfd to master...

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.

Lint for 4 / (////) to help detect broken doc comments
5 participants