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

🛠️ refactor away the inferred_obligations from the trait selector #48672

Closed
nikomatsakis opened this issue Mar 2, 2018 · 2 comments
Closed
Labels
A-trait-system Area: Trait system WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804

Comments

@nikomatsakis
Copy link
Contributor

The SelectionContext currently has this vector, inferred_obligations:

inferred_obligations: SnapshotVec<InferredObligationsSnapshotVecDelegate<'tcx>>,

It is used to accumulate obligations during matching operations and so forth that takes in a select, for example here:

self.inferred_obligations.extend(obligations);

These are then stored in the vector and later added to the candidate currently under construction:

let inferred_obligations = (*self.inferred_obligations).into_iter().cloned();
candidate.nested_obligations_mut().extend(inferred_obligations);

It's a kinda confusing setup, since the flow of information is hidden, and it's not really needed. This commit factors it away, but it does so in the context of a long branch, and can't really be directly cherry-picked:

nikomatsakis@627a2b4

Still, the general strategy should be visible. Instead of using the inferred_obligations vector, we basically just thread obligations around explicitly.

@nikomatsakis nikomatsakis added A-trait-system Area: Trait system WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804 labels Mar 2, 2018
@nikomatsakis
Copy link
Contributor Author

nikomatsakis commented Mar 2, 2018

cc @rust-lang/wg-traits -- this would be a good refactoring to get to know how select.rs works. This chapter of the rustc-guide should help a bit too to get oriented.

@aravind-pg
Copy link
Contributor

I'll try my hand at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804
Projects
None yet
Development

No branches or pull requests

2 participants