trait item metadata encoding for supertraits is messy and ugly #8559
Labels
A-metadata
Area: Crate metadata
A-trait-system
Area: Trait system
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
As part of #8562 I have added the notion that traits have a disjoint set of super traits and super kinds. In the typeck data structures, these are represented separately, with the former in the
tcx.supertraits
map, and the latter as a field ofty::TraitDef
.However, when encoded in the metadata, I just recycled the old code which would encode super-builtin-kinds as though they were regular supertraits (fixme in
metadata/encoder.rs
), and on the other side, repartition them into the two distinct sets when reading cross-crate trait info (fixmes inmetadata/decoder.rs
).A consequence of this is that in
typeck/collect.rs
, I had to make sure even the builtin supertraits were inserted into thetcx.trait_refs
map so they could be encoded using the same old metadata code.It would be better to encode a
TraitDef
's builtin bounds like the separate field that it is. This would also require, in theitem_trait
case inencoder.rs
, iterating over thetcx.supertraits
map's value instead of iterating over what the AST thinks the supertraits are.The text was updated successfully, but these errors were encountered: