Auto merge of #86461 - crlf0710:rich_vtable, r=nikomatsakis

Refactor vtable format for upcoming trait_upcasting feature.

This modifies vtable format:
1. reordering occurrence order of methods coming from different traits
2. include `VPtr`s for supertraits where this vtable cannot be directly reused during trait upcasting.
Also, during codegen, the vtables corresponding to these newly included `VPtr` will be requested and generated.

For the cases where this vtable can directly used, now the super trait vtable has exactly the same content to some prefix of this one.

r? `@bjorn3`
cc `@RalfJung`
cc `@rust-lang/wg-traits`
This commit is contained in:
bors 2021-07-24 10:21:23 +00:00
commit f9b95f92c8
15 changed files with 891 additions and 84 deletions

View file

@ -14,17 +14,17 @@ pub fn anonymize_predicate<'tcx>(
tcx.reuse_or_mk_predicate(pred, new)
}
struct PredicateSet<'tcx> {
pub struct PredicateSet<'tcx> {
tcx: TyCtxt<'tcx>,
set: FxHashSet<ty::Predicate<'tcx>>,
}
impl PredicateSet<'tcx> {
fn new(tcx: TyCtxt<'tcx>) -> Self {
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
Self { tcx, set: Default::default() }
}
fn insert(&mut self, pred: ty::Predicate<'tcx>) -> bool {
pub fn insert(&mut self, pred: ty::Predicate<'tcx>) -> bool {
// We have to be careful here because we want
//
// for<'a> Foo<&'a i32>