Closed as not planned
Description
I expected that given the following method, both methods won't be included in the vtable (note that this trait is object safe, self
"implies" where Self: Sized
for object safety check)
trait Tr {
fn method_that_takes_self(self);
fn method_that_takes_self2(self) where Self: Sized {}
}
But, in reality, with 1.73.0-nightly (2023-07-23 8771282d4e7a5c4569e4)
, method_that_takes_self
is included in the vtable, even though you can't call it:
vtable entries for `<String as Tr>`: [
MetadataDropInPlace,
MetadataSize,
MetadataAlign,
Method(<String as Tr>::method_that_takes_self - shim(vtable)),
]
This is especially sub-optimal in the presence of trait upcasting, since this makes otherwise empty (wrt to trait objects) traits non-empty, adding need for more vptrs.