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

[pathbuf_init_then_push]: Checks for calls to push immediately a… #11700

Merged
merged 1 commit into from
Jul 21, 2024

Conversation

lengyijun
Copy link
Contributor

changelog: [pathbuf_init_then_push]: new lint: Checks for calls to push immediately after creating a new PathBuf

Just a mirror of VEC_INIT_THEN_PUSH

@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2023

r? @Manishearth

(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 Oct 23, 2023
clippy_lints/src/pathbuf_init_then_push.rs Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@Manishearth
Copy link
Member

r? @Centri3

@lengyijun
Copy link
Contributor Author

Someone may care about the performance: .join() introduce an implicit clone
But personally, I don't care

@lengyijun lengyijun force-pushed the pathbuf_join branch 2 times, most recently from c7d7211 to bb0c6a0 Compare October 24, 2023 00:19
@bors
Copy link
Contributor

bors commented Nov 14, 2023

☔ The latest upstream changes (presumably #11791) made this pull request unmergeable. Please resolve the merge conflicts.

@xFrednet
Copy link
Member

xFrednet commented Apr 1, 2024

Hey @lengyijun, would you mind rebasing this on master?

@ARandomDev99 This might be a good PR to review. There are some conflicts, but the implementation should be unaffected by the rebase.

If you comment something on this PR, I can also add you as an assignee

r? xFrednet

@rustbot rustbot assigned xFrednet and unassigned Centri3 Apr 1, 2024
@lengyijun lengyijun force-pushed the pathbuf_join branch 2 times, most recently from 98cf1bd to 7183542 Compare April 1, 2024 11:38
@ARandomDev99
Copy link
Contributor

I concur with Centri3. Instead of multiple calls to PathBuf::join, it is better to suggest using PathBuf::from while dealing with only string literals. Additionally, I believe this lint should be in the pedantic category instead of complexity.

@xFrednet
Copy link
Member

xFrednet commented Apr 1, 2024

Additionally, I believe this lint should be in the pedantic category instead of complexity.

Could you explain why you feel this should be pedantic?

clippy::vec_init_then_push is warn-by-default and if this is free from FPs I think it's reasonable to have it as warn-by-default as well. We can bikeshed this part and leave it to the FCP before we merge this :)

@lengyijun lengyijun force-pushed the pathbuf_join branch 5 times, most recently from 565bac6 to a72ad23 Compare April 2, 2024 08:43
@ARandomDev99
Copy link
Contributor

ARandomDev99 commented Apr 2, 2024

Could you explain why you feel this should be pedantic?

@lengyijun said:

Someone may care about the performance: .join() introduce an implicit clone

This doesn't seem like a change that everyone would prefer. Having it allowed by default seems more appropriate to me. Unlike clippy::vec_init_then_push which improves performance, this lint only suggests replacing calls to push with join. This could stay in the complexity category if it replaced the calls to push with a single call to PathBuf::from.

We can bikeshed this part and leave it to the FCP before we merge this

I'm still relatively new around here. What does FCP mean? 😅

@xFrednet
Copy link
Member

xFrednet commented Apr 2, 2024

This doesn't seem like a change that everyone would prefer.

Ahh, yep you're right. Then pedantic would be the safe choice 👍

I'm still relatively new around here. What does FCP mean? 😅

No problem, FCP stands for final comment period it's a new concept for Clippy. When a new lint is ready to be merged, we create a topic on zulip to get feedback. If no concerns are raised within ~1 week we merge the PR, otherwise we discuss the issues :)

Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

The implementation looks good to me overall. I would like to see more tests, also negative examples of code that shouldn't trigger the lint. I left some example comments.

There is also a random binary file called c. Can you remove that one?

If you rebase, we could also take a look at the lintcheck output in our CI :D


Sorry, that it took this long, it again slipped my mind 🙈

clippy_lints/src/pathbuf_init_then_push.rs Outdated Show resolved Hide resolved
tests/ui/pathbuf_init_then_push.rs Outdated Show resolved Hide resolved
tests/ui/pathbuf_init_then_push.rs Outdated Show resolved Hide resolved
clippy_lints/src/pathbuf_init_then_push.rs Show resolved Hide resolved
tests/ui/pathbuf_init_then_push.rs Show resolved Hide resolved
@xFrednet
Copy link
Member

Let me know when this PR is ready to be reviewed again. I'm assuming the last commits are not ready yet due to their name :)

@bors
Copy link
Contributor

bors commented Jun 27, 2024

☔ The latest upstream changes (presumably #12999) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

I left some more comments, they should hopefully all be easy to fix. They are hopefully not too nitpicky ^^'

Let me know, if you have any question :D

clippy_lints/src/pathbuf_init_then_push.rs Outdated Show resolved Hide resolved
clippy_lints/src/pathbuf_init_then_push.rs Outdated Show resolved Hide resolved
clippy_lints/src/pathbuf_init_then_push.rs Outdated Show resolved Hide resolved
clippy_lints/src/pathbuf_init_then_push.rs Outdated Show resolved Hide resolved
@lengyijun lengyijun force-pushed the pathbuf_join branch 2 times, most recently from 598fcd1 to c7e4ef4 Compare July 1, 2024 06:08
Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

LGTM, I've started the FCP: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/FCP.3A.20.60pathbuf_init_then_push.60.20rust-clippy.2311700/near/449299039

I have one last tiny comment. Could you maybe also squash the smaller commits? Having one review commit or so is totally fine :D

clippy_lints/src/pathbuf_init_then_push.rs Outdated Show resolved Hide resolved
@xFrednet xFrednet added S-final-comment-period Status: final comment period it will be merged unless new objections are raised (~1 week) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jul 5, 2024
@bors
Copy link
Contributor

bors commented Jul 9, 2024

☔ The latest upstream changes (presumably #13080) made this pull request unmergeable. Please resolve the merge conflicts.

@xFrednet
Copy link
Member

I assume the Emmm is referring to the comment?

You can use span_contains_comment to check if there is a comment between the creation and the push

@xFrednet
Copy link
Member

Okay, I'd say the FCP has concluded. It sounds like the lint is okay, but we had others suggest the restriction group instead, since it might be more readable but has a performance overhead. Could you change the lint group? Then it should be ready for merge. With the addition of span_contains_comment as mentioned above :D

@xFrednet xFrednet added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-final-comment-period Status: final comment period it will be merged unless new objections are raised (~1 week) labels Jul 12, 2024
@lengyijun lengyijun force-pushed the pathbuf_join branch 3 times, most recently from 0bd7839 to 53eb717 Compare July 19, 2024 07:12
@xFrednet
Copy link
Member

This version looks good to me, and the two detected cases in our CI are also very good: https://github.com/rust-lang/rust-clippy/actions/runs/10004116830?pr=11700

Thank you for the last changes. I left a tiny nit, which should be simple to fix. Then you can r=me


Roses are red,
This PR is good,
I delegate this,
To bors the bot

@bors
Copy link
Contributor

bors commented Jul 20, 2024

✌️ @lengyijun, you can now approve this pull request!

If @xFrednet told you to "r=me" after making some further change, please make that change, then do @bors r=@xFrednet

@lengyijun lengyijun force-pushed the pathbuf_join branch 2 times, most recently from 6d3a91e to 4e849ef Compare July 21, 2024 06:10
…ter creating a new `PathBuf`

Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
@lengyijun
Copy link
Contributor Author

@bors r=@xFrednet

@bors
Copy link
Contributor

bors commented Jul 21, 2024

📌 Commit cb77f12 has been approved by xFrednet

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 21, 2024

⌛ Testing commit cb77f12 with merge 8fe5c75...

@bors
Copy link
Contributor

bors commented Jul 21, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing 8fe5c75 to master...

@bors bors merged commit 8fe5c75 into rust-lang:master Jul 21, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants