You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor ProjectionTy to store def-id of associated item + substs #42171
In preparation for ATC, we should refactor ProjectionTy to store the DefId of the trait associated item along with a set of substs for that item. (Currently, it stores a trait-ref (trait def-id + substs) and item name.) Currently, these substs will always be the same as the substs for the trait, but once ATC lands they will include additional items.
cc @tschottdorf, who has started in on this
cc @eddyb, who has a vague interest in this :)
Quick question - for storing substs, would a ProjectionTy start out with a copy of the substs of the corresponding TraitRef at creation time, or is it sharing the substs with it in general?
@eddyb Niko mentioned above that for now, the substs in the TraitRef and those in ProjectionTy will be identical, so making a copy isn't strictly necessary. He also mentioned that they're bound to diverge with ATC, so it seems reasonable not to tie the two together.
Maybe he wasn't clear on the fact that TraitRef in ProjectionTy would be replaced, so the end result only has DefId for the associated type and Substs for it (which currently would be the same that you would find in the TraitRef).
Sorry, didn't phrase that well - I'm aware that trait_ref will be dropped, what I'm really asking is: is the intended behavior instead of storing the trait_ref, it will store a copy of the substs that are in the trait_ref at the time the ProjectionTy is constructed. Your last sentence answers it though, so my question has been addressed. Thanks @eddyb!
Activity
tbg commentedon May 27, 2017
Quick question - for storing
substs, would aProjectionTystart out with a copy of the substs of the correspondingTraitRefat creation time, or is it sharing the substs with it in general?eddyb commentedon May 27, 2017
@tschottdorf How would the two options differ? What do you mean by "sharing"?
tbg commentedon May 27, 2017
@eddyb Niko mentioned above that for now, the
substsin theTraitRefand those inProjectionTywill be identical, so making a copy isn't strictly necessary. He also mentioned that they're bound to diverge with ATC, so it seems reasonable not to tie the two together.eddyb commentedon May 27, 2017
Maybe he wasn't clear on the fact that
TraitRefinProjectionTywould be replaced, so the end result only hasDefIdfor the associated type andSubstsfor it (which currently would be the same that you would find in theTraitRef).tbg commentedon May 28, 2017
Sorry, didn't phrase that well - I'm aware that
trait_refwill be dropped, what I'm really asking is: is the intended behavior instead of storing thetrait_ref, it will store a copy of thesubststhat are in thetrait_refat the time theProjectionTyis constructed. Your last sentence answers it though, so my question has been addressed. Thanks @eddyb!Rollup merge of rust-lang#42297 - tschottdorf:proj-ty, r=nikomatsakis
11 remaining items
Downgrade ProjectionTy's TraitRef to its substs
Downgrade ProjectionTy's TraitRef to its substs
Downgrade ProjectionTy's TraitRef to its substs
Auto merge of #42388 - tschottdorf:projty-substs, r=nikomatsakis