Skip to content

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

@nikomatsakis

Description

@nikomatsakis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions