Switch to store Instance directly within VtblEntry, fix TraitVPtr representation.

This commit is contained in:
Charles Lew 2021-07-18 17:23:37 +08:00
parent ab171c5279
commit 634638782b
7 changed files with 98 additions and 116 deletions

View file

@ -1,6 +1,4 @@
// build-fail
//~^ error Vtable
//~^^ error Vtable
#![feature(rustc_attrs)]
#[rustc_dump_vtable]
@ -15,11 +13,13 @@ trait B: A {
#[rustc_dump_vtable]
trait C: A {
//~^ error Vtable
fn foo_c(&self) {}
}
#[rustc_dump_vtable]
trait D: B + C {
//~^ error Vtable
fn foo_d(&self) {}
}

View file

@ -1,56 +1,35 @@
error: Vtable Entries: [
error: Vtable entries for `<S as D>`: [
MetadataDropInPlace,
MetadataSize,
MetadataAlign,
Method(
DefId(0:4 ~ vtable_diamond[4564]::A::foo_a),
[
S,
],
),
Method(
DefId(0:6 ~ vtable_diamond[4564]::B::foo_b),
[
S,
],
),
Method(
DefId(0:8 ~ vtable_diamond[4564]::C::foo_c),
[
S,
],
),
TraitVPtr(
Binder(
C,
[],
),
),
Method(
DefId(0:10 ~ vtable_diamond[4564]::D::foo_d),
[
S,
],
),
Method(<S as A>::foo_a),
Method(<S as B>::foo_b),
Method(<S as C>::foo_c),
TraitVPtr(<S as C>),
Method(<S as D>::foo_d),
]
--> $DIR/vtable-diamond.rs:21:1
|
LL | / trait D: B + C {
LL | |
LL | | fn foo_d(&self) {}
LL | | }
| |_^
error: Vtable Entries: [
error: Vtable entries for `<S as C>`: [
MetadataDropInPlace,
MetadataSize,
MetadataAlign,
Method(
DefId(0:4 ~ vtable_diamond[4564]::A::foo_a),
[
S,
],
),
Method(
DefId(0:8 ~ vtable_diamond[4564]::C::foo_c),
[
S,
],
),
Method(<S as A>::foo_a),
Method(<S as C>::foo_c),
]
--> $DIR/vtable-diamond.rs:15:1
|
LL | / trait C: A {
LL | |
LL | | fn foo_c(&self) {}
LL | | }
| |_^
error: aborting due to 2 previous errors

View file

@ -1,6 +1,4 @@
// build-fail
//~^ error Vtable
//~^^ error Vtable
#![feature(rustc_attrs)]
#[rustc_dump_vtable]
@ -10,11 +8,13 @@ trait A {
#[rustc_dump_vtable]
trait B {
//~^ error Vtable
fn foo_b(&self) {}
}
#[rustc_dump_vtable]
trait C: A + B {
//~^ error Vtable
fn foo_c(&self) {}
}

View file

@ -1,44 +1,33 @@
error: Vtable Entries: [
error: Vtable entries for `<S as C>`: [
MetadataDropInPlace,
MetadataSize,
MetadataAlign,
Method(
DefId(0:4 ~ vtable_multiple[5246]::A::foo_a),
[
S,
],
),
Method(
DefId(0:6 ~ vtable_multiple[5246]::B::foo_b),
[
S,
],
),
TraitVPtr(
Binder(
B,
[],
),
),
Method(
DefId(0:8 ~ vtable_multiple[5246]::C::foo_c),
[
S,
],
),
Method(<S as A>::foo_a),
Method(<S as B>::foo_b),
TraitVPtr(<S as B>),
Method(<S as C>::foo_c),
]
--> $DIR/vtable-multiple.rs:16:1
|
LL | / trait C: A + B {
LL | |
LL | | fn foo_c(&self) {}
LL | | }
| |_^
error: Vtable Entries: [
error: Vtable entries for `<S as B>`: [
MetadataDropInPlace,
MetadataSize,
MetadataAlign,
Method(
DefId(0:6 ~ vtable_multiple[5246]::B::foo_b),
[
S,
],
),
Method(<S as B>::foo_b),
]
--> $DIR/vtable-multiple.rs:10:1
|
LL | / trait B {
LL | |
LL | | fn foo_b(&self) {}
LL | | }
| |_^
error: aborting due to 2 previous errors