-
Notifications
You must be signed in to change notification settings - Fork 181
intern "substitutions" #316
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
intern "substitutions" #316
Conversation
In order to support interning, we're going to want to be passing in the interner, so `collect()` is not going to work long term.
It is constructed from an iterator over results
chalk-ir/src/debug.rs
Outdated
| ) | ||
| }) | ||
| TF::debug_projection(self, fmt) | ||
| .unwrap_or_else(|| write!(fmt, "({:?}){:?}", self.associated_ty_id, &self.substitution)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be &self.substitution.with_angle()
chalk-ir/src/family.rs
Outdated
| fn intern_goal(data: GoalData<Self>) -> Self::InternedGoal; | ||
|
|
||
| /// Lookup the `GoalData` that was interned to create a `InternedGoal`. | ||
| /// Lookup the `LifetimeData` that was interned to create a `InternedLifetime`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These docs don't reflect the function...
| /// index. Naturally, the kind of the variable must agree with | ||
| /// the kind of the value. | ||
| pub parameters: Vec<Parameter<TF>>, | ||
| parameters: TF::InternedSubstitution, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, why not just replace Substitution with an associated type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern is what we use for all the "interned things". Having the newtype'd wrapper allows us to implement traits like Fold and add methods. You can't quite make Fold work without the newtype'd wrapper. The other advantage is consistency: you always write Foo<TF>, never TF::Foo, in regular code.
jackh726
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
We used to directly embed
Vec<Parameter<TF>>. This branch changes those references toSubstitution<TF>which (internally) relies on anTF::InternedSubstitution. This should enable rustc to use interned slices.