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

fix: Don't panic on lack of conflicts #3212

Merged
merged 3 commits into from
Dec 23, 2021
Merged

fix: Don't panic on lack of conflicts #3212

merged 3 commits into from
Dec 23, 2021

Conversation

epage
Copy link
Member

@epage epage commented Dec 23, 2021

After some refactors to pave the way, this re-does the conflict code to disambiguate the groups an argument is a member of from the groups it conflicts with.

Now we only gather real conflicts and then report all of them (might as well since we have them and we went through work to do that for requireds). Behind the scenes, we gather the potential one-way or direct conflicts and cache them. This let's us both reuse the code and reuse the results for then calculating the reverse conflicts (A conflicts with B, therefore B conflicts with A). By finding the reverse like this, we avoid needing to check the order of conflicts (and invert them) when reporting errors, simplifying the code. This isn't too bad because we were able to reuse our iterating over all of the arguments.

Reusable logic/results for conflicts will hopefully make it easier to address #3077

Fixes #3197

@epage epage added the M-unreviewed Meta: Request for post-merge review. label Dec 23, 2021
@epage epage merged commit 5a670ec into clap-rs:master Dec 23, 2021
@epage epage deleted the conflict2 branch December 23, 2021 20:18
@pksunkara pksunkara removed the M-unreviewed Meta: Request for post-merge review. label Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal error when using conflicts_with with ArgGroup
2 participants