Repository navigation
fix(clean): Respect --target when no package is specified - #17611
isHeSatoshi wants to merge 1 commit into
Conversation
`cargo clean --target <tuple>` removed the whole target directory, so the flag was accepted and then ignored unless `-p` was also passed. The profile directory is nested inside the target one, so it can no longer be appended up front. Compute the directories to remove after the target one instead, which leaves the behavior unchanged when `--target` is missing.
|
Thanks for the pull request, and welcome! The Rust Project has assigned @weihanglo (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
I am going to have to close this PR as our LLM policy states that LLM-created code changes require a reviewer to be pre-arranged. One other thing to note is that #17311 was not marked as |
What does this PR try to resolve?
Fixes #17311.
Without
-p,cargo cleanremoved the whole target directory, so--targetwas acceptedand then ignored:
cargo clean --doc --target(fixed in #17310) andcargo clean -p --targetboth respect--targetalready, so this makes the remaining case behave the same way, matching what the--targetdocumentation says: "Clean for the specified target architecture."How to test and review this PR?
The directories to remove are now computed as
<target-dir>[/<triple>][/<profile-dir>], the same wayLayoutnests them, since theprofile directory lives inside the target one and so can no longer be appended up front.
Without
--targetthe same directories as before are removed. In particular the scoping isdriven by the command-line
--targetalone, so abuild.targetin the config does not turncargo cleaninto a per-target clean.With two targets and two profiles present in the target directory:
tests/testsuite/clean.rsaddsclean_target, which checks that onlytarget/<triple>isremoved (and with
--release --targetonly itsreleasedirectory), while the host outputsurvives. The existing tests cover
--profilewithout--targetand a plaincargo clean.Verified with:
🤖 LLM disclosure: This PR - the code change, the tests and this description - was produced by
an LLM agent on the author's behalf, then built and tested as described above. Flagging it per
the LLM usage policy so reviewers can
decide whether to take it on. Happy to answer questions, or to close it, if that is preferred.