-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed as not planned
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.F-trait_upcasting`#![feature(trait_upcasting)]``#![feature(trait_upcasting)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.
scottmcm, MatrixDev, davidhalter, yvt, kellerkindt and 2 more
Metadata
Metadata
Assignees
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.F-trait_upcasting`#![feature(trait_upcasting)]``#![feature(trait_upcasting)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.