Skip to content

support "specialized" impls #219

Open

Description

This is a step towards full support for specialization (#9). This particular step sidesteps some of the trickier bits of specialization (in particular, it sidesteps the parts related to regions and soundness). The goal is this:

  • If we know that impl A specializes impl B, adjust the logic to take that into account.

I'll try to post more detailed mentoring instructions, but here are some high-level notes:

Specialization does not effect whether or not a trait is implemented. Therefore, the "lowering" for an impl ought to be unaffected -- overlapping impls simply mean more than one way to prove the same set of types, and the solver ought to be able to handle that.

The "normalization rules", however, are effected. If you have an impl with a default item:

impl Iterator for Foo<T> {
  default type Item = u32;
}

then we cannot normalize <Foo<T> as Iterator>::Item to u32 unless we know that there is no "more specific" impl that applies.

Moreover, at least in rustc at the moment, we sometimes wish to assume that a more specialized impl could be added in the future. In rustc, we currently distinguish between "reveal mode", at which point we are allowed to normalize a default type, and "normal mode", when we are not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

C-chalk-solveIssues related to the chalk-solve cratedesignNeeds design workneeds triageNeeds to be discussedrustc integrationRelated to or required for rustc integration

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions