Skip to content

[wg-traits] pass around interned refs to goals and not goals #50580

Closed
@nikomatsakis

Description

@nikomatsakis

Currently we have a setup where we have an enum Goal:

#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum Goal<'tcx> {
Implies(Clauses<'tcx>, &'tcx Goal<'tcx>),
And(&'tcx Goal<'tcx>, &'tcx Goal<'tcx>),
Not(&'tcx Goal<'tcx>),
DomainGoal(DomainGoal<'tcx>),
Quantified(QuantifierKind, ty::Binder<&'tcx Goal<'tcx>>),
CannotProve,
}

This enum contains interned goals (&'tcx Goal<'tcx>). We also have slices of goals:

pub type Goals<'tcx> = &'tcx Slice<Goal<'tcx>>;

This works ok as long as we pass around Goal<'tcx> enum values. But I suspect we might rather pass around pointers to interned goals, rather like Ty<'tcx> is a reference. This would also allow us to do cheap equality testing, hashing and so forth if we cared to.

Therefore, we probably ought to:

  1. Rename the enum Goal to GoalKind
  2. Add a type alias Goal<'tcx> = &'tcx GoalKind<'tcx>
  3. And thus change Goals<'tcx> to a slice of interned refs.

Metadata

Metadata

Assignees

Labels

C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-traitsWorking group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions