Skip to content

Align path_buf_push_overwrite with join_absolute_paths - #17822

Closed
schneems wants to merge 1 commit into
rust-lang:masterfrom
schneems:schneems/absolute-push
Closed

schneems wants to merge 1 commit into
rust-lang:masterfrom
schneems:schneems/absolute-push

Conversation

@schneems

@schneems schneems commented Sep 30, 2026 •

Copy link
Copy Markdown
changelog: [`path_buf_push_overwrite`]: Moved to `suspicious` group from nursery, and updated to match `join_absolute_paths` logic

LLM disclosure: I iterated on this with an LLM for code review, research, and experimenting. All prose in the PR here, code comments, and the commit message is mine. I've manually reviewed all changes locally using gitx visual diff and again on GitHub's UI before moving it out of "draft". I (human) fully own this being up to my standards and ready for review.


What

The path_buf_push_overwrite and join_absolute_paths lints are basically the same thing. However, path_buf_push_overwrite was proposed first (#3954) and is still in the nursery (due to #4012), while join_absolute_paths came later (2026 #11453) and is currently in the suspicious group. This PR aligns path_buf_push_overwrite to match join_absolute_paths logic and moves it to the suspicious group.

This PR updates path_buf_push_overwrite to match join_absolute_paths (tests, docs, behavior). It delivers different suggestions that handle deref similar to swap_with_temporary. I also propose we move it from the nursery to suspicious to match join_absolute_paths (which this PR also does).

This came up from a discussion on Zulip https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Path.20redesign/near/627828098.

@schneems schneems changed the title Align path_buf_overwrite with join_absolute_paths Align path_buf_push_overwrite with join_absolute_paths Sep 30, 2026
@schneems
schneems force-pushed the schneems/absolute-push branch from 16cbb5c to f2e6fd5 Compare September 30, 2026 19:47
Comment thread clippy_lints/src/methods/path_buf_push_overwrite.rs Outdated
@schneems
schneems force-pushed the schneems/absolute-push branch 3 times, most recently from c83a3a3 to ceeac02 Compare September 30, 2026 23:00
The `join_absolute_paths` lint is essentially the same logic, but for `join` instead of `push`. This change updates `path_buf_push_overwrite` to match `join_absolute_paths`, which is out of nursery and has received more recent updates:

- Copy the tests from `join_absolute_paths`.
- Add a no-lint case for `sh`.
- Adapt the detection logic from `join_absolute_paths`.
- Align the public docs and lint description.
- Add a comment to both lints as a hint that changes to one should be propagated to the other.
- Fix a typo in the `join_absolute_paths` docs: `Use instead;` => `Use instead:`.
- Add a blank line after doc headers in `path_buf_push_overwrite`. I didn't update `join_absolute_paths`.
- Move `path_buf_push_overwrite` from `nursery` to `suspicious`.

The main difference between the two is the "if this is intentional" suggestion. `Path::join` returns a new path, so its suggestion replaces only the call site:

```
LL -     path.join("/sh");
LL +     PathBuf::from("/sh");
```

`PathBuf::push` mutates in place, so its suggestion assigns to the receiver instead. When the receiver auto-derefs to the `PathBuf`, the suggestion adds one `*` per deref, the same approach `swap_with_temporary` uses:

```
LL -     path.push("/sh");
LL +     *path = PathBuf::from("/sh");
```

The `multiple_deref()` test (and some of the logic) is adapted from `swap_with_temporary` lint.
@schneems
schneems force-pushed the schneems/absolute-push branch from ceeac02 to e26c7e3 Compare October 1, 2026 14:28
@schneems
schneems marked this pull request as ready for review October 1, 2026 14:39
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. labels Oct 1, 2026
@CommanderStorm

Copy link
Copy Markdown
Contributor

LLM disclosure: I iterated on this with an LLM for [...] experimenting

Could you go into more details what you mean here? Context

@schneems

schneems commented Oct 2, 2026

Copy link
Copy Markdown
Author

Good question. I wasn't totally sure how to concisely represent what I did. I read the policy before posting (I think it's good to talk more openly about this stuff, also, thanks for your work around the repo). I missed the "originally created" description at the bottom. I didn't always start with human code. So, I should have gone through the full "experiment" flow and pre-arranged a reviewer. Sorry, I didn't do that.

Specifically, I had an LLM write code that I then edited. And often threw away. Repeatedly, not always in that order. I'm aiming for higher rigor (like https://rfd.shared.oxide.computer/rfd/0576). This output is mine, as in I own it fully. I stand behind it and cannot improve it without further assistance, but would like to.

I'll take more care in the future, and I'll look for a reviewer in the morning.

@CommanderStorm CommanderStorm added the llm-assisted For PRs that were partially or completely done with assistance of AI/LLM tools label Oct 2, 2026
@schneems

schneems commented Oct 3, 2026

Copy link
Copy Markdown
Author

After a conversation on zulip it sounds like it will be helpful for me to rewrite this by hand. The project seems to be drowning in these LLM tagged PRs and few maintainers (especially compared to mainline rust). It is worth it to increase the signal to noise ratio to close and redo by hand. That's my plan.

@schneems schneems closed this Oct 3, 2026
@rustbot rustbot removed S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm-assisted For PRs that were partially or completely done with assistance of AI/LLM tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants