]> git.lizzy.rs Git - rust.git/commit
Auto merge of #23026 - nikomatsakis:issue-20220-supertrait, r=nikomatsakis
authorbors <bors@rust-lang.org>
Thu, 5 Mar 2015 17:52:21 +0000 (17:52 +0000)
committerbors <bors@rust-lang.org>
Thu, 5 Mar 2015 17:52:21 +0000 (17:52 +0000)
commitf0c74f85f363a8081b31f9ab696463717ce312d5
tree3d76755c2e0635aaf67fbf0da824d05bb1db9499
parent68740b405404a3f885e388c8d31722797d519c30
parent9b332ff2c71480bc9350bb9dd43e0af00d04e1a1
Auto merge of #23026 - nikomatsakis:issue-20220-supertrait, r=nikomatsakis

The main gist of this PR is commit 1077efb which removes the list of supertraits from the `TraitDef` and pulls them into a separate table, which is accessed via `lookup_super_predicates`. This is analogous to `lookup_predicates`, which gets the complete where clause. This allows us to create the `TraitDef`, which contains the list generics and so forth, without fully knowing the list of supertraits. This in turn allows the *supertrait listing* to contain references to associated types like `<Self as Foo>::Item`, which were previously impossible because conversion required having the `TraitDef` for `Foo`.

We do not yet support `Self::Item` in a supertrait listing. This doesn't work because to convert that, it attempts to expand out the full set of supertraits, which are in the process of being created. This could potentially be worked out by having the expansion of supertraits proceed in a lazy fashion, but we'd have to define shadowing rules for associated types which we don't currently have.

Along the way (in 9de9ec5) I also removed the restriction against duplicate bounds and generalized the code so that it can handle having the same supertrait multiple times with different arguments, e.g. `Foo : Bar<i32> + Bar<u32>`. This restriction was serving no particular purpose, since the same trait could be extended multiple times indirectly, and in the era of multidispatch it is actively harmful.

This is technically a [breaking-change] because it affects the definition of a super-trait. Anything in a where clause that looks like `where Self : Foo` is now considered a supertrait. Because cycles are disallowed in supertraits, that could lead to some errors. This has not been observed in any existing code.

r? @nrc
src/librustc/metadata/decoder.rs
src/librustc/session/mod.rs