Skip to content

trait item metadata encoding for supertraits is messy and ugly #8559

Closed
@bblum

Description

@bblum

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 of ty::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 in metadata/decoder.rs).

A consequence of this is that in typeck/collect.rs, I had to make sure even the builtin supertraits were inserted into the tcx.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 the item_trait case in encoder.rs, iterating over the tcx.supertraits map's value instead of iterating over what the AST thinks the supertraits are.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-metadataArea: Crate metadataA-trait-systemArea: Trait systemC-cleanupCategory: PRs that clean code up or issues documenting cleanup.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions