Make component removal best-effort and order-independent#4797
Make component removal best-effort and order-independent#4797Inconnu08 wants to merge 1 commit intorust-lang:mainfrom
Conversation
21add7c to
9bcc180
Compare
6c5bb6e to
aefad2b
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
4f37dba to
7f5f683
Compare
7f5f683 to
eeb7b06
Compare
|
Hmmm my apologies, but I think I might need some extra time for a final look at this before merging 🙏 |
There was a problem hiding this comment.
I'm feel okay about it globally but I have a few concerns:
-
I would like to confirm with @FranciscoTGouveia whether the original intention of #4794 is to aggregate certain errors (which is what I believe) rather than just showing the first error but with the bail-out delayed. IMHO the behavior as implemented in this patch will be very confusing to the user if multiple errors do happen. In this case I suggest that we either aggregate
UnknownComponent*separately and early bail out for the rest, or actually aggregate all errors (which might be more difficult in terms of display). -
The current distinction of
UnknownComponentandUnknownComponentsdoesn't seem super necessary since it doesn't prevent the API user from creating the latter with only oneVecmember. -
The tuples in
UnknownComponentsmight be better expressed via a separate struct, but that's a minor implementation detail.
|
Thanks, that makes sense. My intent with the current implementation was to:
One of the motivations for introducing That said, I agree the mixed behavior could be confusing if multiple different error types occur. I’m happy to adjust the approach once the intended UX for #4794 is confirmed with @FranciscoTGouveia whether that means aggregating only Also, point on UnknownComponent vs UnknownComponents: I introduced the second mainly to avoid regressing the existing single-component behavior, but I’m open to simplifying that if we settle on a cleaner model. And agreed on the tuple, a small struct would likely make that clearer if we keep the grouped variant. |
|
The original intention of 4794 was indeed to install all possible components and report back every invalid one. For example, running On another note, I briefly tested the patch and believe it would be worth adding a test case covering the example above, as this is the current output: |
@FranciscoTGouveia Thanks for your reply! Given that, my suggestions would be:
@Inconnu08 What do you think? |
|
(Assigned @FranciscoTGouveia for review upon his request.) |
| "toolchain '{desc}' does not contain component '{component}'{}", | ||
| suggest_message(suggestion), |
There was a problem hiding this comment.
What if we insert a newline before calling suggest_message?
Otherwise, we could easily exceed 80 chars :/
| )); | ||
| assert!(!cx.config.rustupdir.has(path.parent().unwrap())); | ||
| } | ||
| } |
There was a problem hiding this comment.
There should also be a third case in which a valid component appears between invalid ones, ensuring that errors are correctly reported for both invalid components.
Previously,
rustup component removeparsed and removed components in a single pass,which meant the command stopped on the first error after potentially removing earlier
valid components. As a result, behavior depended on argument order.
This change makes component removal best-effort by:
This makes the behavior consistent regardless of whether an invalid component appears
before or after valid ones as discussed here: #4794 .
Also adds a regression test covering both orderings.
Closes #4794