Skip to content
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

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

Closed
bblum opened this issue Aug 16, 2013 · 5 comments
Closed

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

bblum opened this issue Aug 16, 2013 · 5 comments
Labels
A-metadata Area: Crate metadata A-traits Area: Trait system C-cleanup Category: PRs that clean code up or issues documenting cleanup.

Comments

@bblum
Copy link
Contributor

bblum commented Aug 16, 2013

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.

@emberian
Copy link
Member

emberian commented Jan 1, 2014

I spent a few minutes looking at this and got lost somewhere in the depths of metadata. This is still relevant, but isn't that easy, unless you're already familiar with metadata.

Not a priority, though.

@nrc
Copy link
Member

nrc commented Apr 3, 2014

A note, that this will also allow us to cleanup the way we handle the unsized/sized bound/generalisation marker in encode/decode too.

@nikomatsakis
Copy link
Contributor

I'm fixing this in one of my branches.

@jroesch
Copy link
Member

jroesch commented Oct 31, 2014

This seems related to the clean up Niko started on the where clause branch for #5527. I've been working around all this code the past few days. cc me.

@arielb1
Copy link
Contributor

arielb1 commented Sep 13, 2015

This is not an issue in new rustc - all supertraits are stored in the "super_predicates" field.

@arielb1 arielb1 closed this as completed Sep 13, 2015
flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 24, 2022
Fix typo in bug report

repoduce -> reproduce

---

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-metadata Area: Crate metadata A-traits Area: Trait system C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Projects
None yet
Development

No branches or pull requests

6 participants