Closed
Description
extracted from #131813
trait Super {
fn super_method(&self) {}
}
trait WithoutAuto: Super {}
trait WithAutoAfter: Super + Send {}
trait WithAutoBefore: Send + Super {}
impl Super for () {}
impl WithoutAuto for () {}
impl WithAutoAfter for () {}
impl WithAutoBefore for () {}
pub fn main() {
drop::<&dyn WithoutAuto>(&());
drop::<&dyn WithAutoAfter>(&());
drop::<&dyn WithAutoBefore>(&());
}
results in the following assembly:
example::main::h981403045b91afa3:
push rax
mov edi, 1
lea rsi, [rip + .L__unnamed_1]
call qword ptr [rip + core::mem::drop::hc9ab6a5c0d43ca28@GOTPCREL]
mov edi, 1
lea rsi, [rip + .L__unnamed_2]
call qword ptr [rip + core::mem::drop::ha5195050a20993aa@GOTPCREL]
mov edi, 1
lea rsi, [rip + .L__unnamed_1]
call qword ptr [rip + core::mem::drop::h1632a30342c576a4@GOTPCREL]
pop rax
ret
.L__unnamed_1:
.asciz "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000"
.quad example::Super::super_method::h936b862074aa3dae
.L__unnamed_3:
.asciz "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000"
.L__unnamed_2:
.asciz "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000"
.quad example::Super::super_method::h936b862074aa3dae
.quad .L__unnamed_3
https://rust.godbolt.org/z/Yef9xdjfP
This looks like the vtable for WithAutoAfter
- but not for WithAutoBefore
- includes a slot for Send
. Given that Send
is an auto-trait this seems very unexpected to me
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
WaffleLapkin commentedon Oct 17, 2024
I think this is a dupe of #114942. We should never emit a vptr for traits without own vtable entries.