You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor vtable encoding and optimize it for the case of multiple marker traits
This PR does two things
- Refactor `prepare_vtable_segments` (this was motivated by the other change, `prepare_vtable_segments` was quite hard to understand and while trying to edit it I've refactored it)
- Mostly remove `loop`s labeled `break`s/`continue`s whenever there is a simpler solution
- Also use `?`
- Make vtable format a bit more efficient wrt to marker traits
- See the tests for an example
Fixesrust-lang/rust#113840
cc `@crlf0710`
----
Review wise it's probably best to review each commit individually, as then it's more clear why the refactoring is correct.
I can split the last two commits (which change behavior) into a separate PR if it makes reviewing easier
While working on #112355 I think I found a bug. Given this program:
rustc outputs the following vtable layout:
Which is surprising, because
TraitVPtr(<() as Sync>)
is unnecessary —Send
does not have any methods, soSync
vtable can be inlined...I think we should be smarter here:
rust/compiler/rustc_trait_selection/src/traits/vtable.rs
Lines 143 to 144 in cb882fa
(for the record, I'm pretty sure this happens in practice, I've found this with
log::Log
)Originally posted by @WaffleLapkin in #65991 (comment)
The text was updated successfully, but these errors were encountered: