Skip to content

Add a !type annotation to a vtable for every supertrait that is a prefix of the vtable - #165475

Open
folkertdev wants to merge 5 commits into
rust-lang:mainfrom
folkertdev:vfe-upcast
Open

folkertdev wants to merge 5 commits into
rust-lang:mainfrom
folkertdev:vfe-upcast

Conversation

@folkertdev

@folkertdev folkertdev commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

tracking issue: #68262

This fixes a miscompilation where a vtable was incorrectly eliminated because it was only used by a supertrait.

In https://godbolt.org/z/8TE1WMvac, call_super could be applied to both A and B, but it incorrectly just always calls the B method. The vtable for A has been eliminated.

The fix here only works for the first supertrait in the list, or later ones if they have no methods. So in trait Foo: A + B, there is still a bug when B actually has methods (and its vtable is not a prefix of Foos vtable).

In that case the vtable for B does not get any !type annotations, which provides incomplete information to VFE and it may therefore miscompile. That needs some further refactoring, which is blocked on #164808.

Best reviewed commit-by-commit.

In `with_self_ty` the def_id that is used is just `self.def_id`, so this is always the same DefId
For now it gets at most one trait, the next step is to (recursively) provide supertraits too
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 4, 2026
@folkertdev
folkertdev force-pushed the vfe-upcast branch 2 times, most recently from 25055da to 7663f53 Compare November 5, 2026 12:37
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@folkertdev folkertdev Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On current nightly the drop does not run

https://godbolt.org/z/qs4v4Wbqf

View changes since the review

@folkertdev

Copy link
Copy Markdown
Contributor Author

r? WaffleLapkin

@rustbot

rustbot commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

WaffleLapkin is not on the review rotation at the moment.
They may take a while to respond.

@folkertdev
folkertdev marked this pull request as ready for review November 5, 2026 23:34
@rustbot

rustbot commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_llvm/src/debuginfo

cc @Walnut356

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 5, 2026
@rust-bors

rust-bors Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #165844) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants