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

Conflict tracking #5037

Merged
merged 3 commits into from Feb 14, 2018
Merged

Conflict tracking #5037

merged 3 commits into from Feb 14, 2018

Conversation

Eh2406
Copy link
Contributor

@Eh2406 Eh2406 commented Feb 13, 2018

This is an alternative implementation of #4834. This is slower but hopefully more flexible and clearer. The idea is to keep a list of PackageId's that have caused us to skip a Candidate. Then we can use the list when we are backtracking if any items in our list have not been activated then we will have new Candidate's to try so we should stop backtracking. Or to say that another way; We can continue backtracking as long as all the items in our list is still activated.

Next this new framework was used to make the error messages more focused. We only need to list the versions that conflict, as opposed to all previously activated versions.

Why is this more flexible?

  1. It is not limited to conflicts within the same package. If RemainingCandidates.next skips something because of a links attribute, that is easy to record, just add the PackageId to the set conflicting_prev_active.
  2. Arbitrary things can add conflicts to the backtracking. If we fail to activate because some dependency needs a feature that does not exist, that is easy to record, just add the PackageId to the set conflicting_activations.
  3. All things that could cause use to fail will be in the error messages, as the error messages loop over the set.
  4. With a simple extension, replacing the HashSet with a HashMap<_, Reason>, we can customize the error messages to show the nature of the conflict.

@alexcrichton, @aidanhs, Does the logic look right? Does this seem clearer to you?

@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

This looks good to me, thanks @Eh2406!

I'd want to get the thoughts from @aidanhs as well but otherwise I think this is good to go.

@@ -681,11 +695,13 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>,
parent: Summary::clone(&parent),
dep: Dependency::clone(&dep),
features: Rc::clone(&features),
conflicting_activations: conflicting_activations.clone(),
Copy link
Member

@aidanhs aidanhs Feb 14, 2018

Choose a reason for hiding this comment

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

I'm 90% sure this is always empty - the only place we add to conflicting_activations is when we've run out of candidates, in which case we're about to backtrack...which means conflicting_activations immediately gets overwritten with an empty set again.

This makes sense, because when backtracking you only care about the conflicts for the current dep rather than for the whole resolve history. It also simplifies the code significantly because we don't need to keep it in backtrack frames.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, conflicting_activations is at this time mostly unused. It is used to move conflicting to find_candidate and then use to shuttle the info to activation_error. The intent is to allow anything to add to the conflicting_activations at any point in the proses. (specifically for #5000). It would be reasonable to remove it in this PR and add it back in in that PR iif it turns out to be useful there.

Copy link
Member

Choose a reason for hiding this comment

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

@Eh2406 that sounds like a good strategy to me!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

If we need it later we can always add it back in.
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Collaborator

bors commented Feb 14, 2018

📌 Commit 8899093 has been approved by alexcrichton

@bors
Copy link
Collaborator

bors commented Feb 14, 2018

⌛ Testing commit 8899093 with merge 489f570...

bors added a commit that referenced this pull request Feb 14, 2018
Conflict tracking

This is an alternative implementation of #4834. This is slower but hopefully more flexible and clearer. The idea is to keep a list of `PackageId`'s that have caused us to skip a `Candidate`. Then we can use the list when we are backtracking if any items in our list have not been activated then we will have new `Candidate`'s to try so we should stop backtracking. Or to say that another way; We can continue backtracking as long as all the items in our list is still activated.

Next this new framework was used to make the error messages more focused. We only need to list the versions that conflict, as opposed to all previously activated versions.

Why is this more flexible?
1. It is not limited to conflicts within the same package. If `RemainingCandidates.next` skips something  because of a links attribute, that is easy to record, just add the `PackageId` to the set `conflicting_prev_active`.
2. Arbitrary things can add conflicts to the backtracking. If we fail to activate because some dependency needs a feature that does not exist, that is easy to record, just add the `PackageId` to the set `conflicting_activations`.
3. All things that could cause use to fail will be in the error messages, as the error messages loop over the set.
4. With a simple extension, replacing the `HashSet` with a `HashMap<_, Reason>`, we can customize the error messages to show the nature of the conflict.

@alexcrichton, @aidanhs, Does the logic look right? Does this seem clearer to you?
@bors
Copy link
Collaborator

bors commented Feb 14, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 489f570 to master...

@bors bors merged commit 8899093 into rust-lang:master Feb 14, 2018
@Eh2406 Eh2406 deleted the conflict_tracking branch February 14, 2018 18:32
@ehuss ehuss added this to the 1.26.0 milestone Feb 6, 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.

None yet

6 participants