Skip to content

Implement RFC 3678: Final trait methods#151783

Open
mu001999 wants to merge 7 commits intorust-lang:mainfrom
mu001999-contrib:impl/final-method
Open

Implement RFC 3678: Final trait methods#151783
mu001999 wants to merge 7 commits intorust-lang:mainfrom
mu001999-contrib:impl/final-method

Conversation

@mu001999
Copy link
Contributor

@mu001999 mu001999 commented Jan 28, 2026

Tracking: #131179

This PR is based on #130802, with some minor changes and conflict resolution.

Futhermore, this PR excludes final methods from the vtable of a dyn Trait.

And some excerpt from the original PR description:

Implements the surface part of rust-lang/rfcs#3678.

I'm using the word "method" in the title, but in the diagnostics and the feature gate I used "associated function", since that's more accurate.

cc @joshtriplett

@rustbot
Copy link
Collaborator

rustbot commented Jan 28, 2026

Some changes occurred in compiler/rustc_builtin_macros/src/autodiff.rs

cc @ZuseZ4

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. labels Jan 28, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 28, 2026

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@fmease
Copy link
Member

fmease commented Jan 28, 2026

Could you mark errs as a coauthor in all 6 commits, I think that's only fair. Thanks! :)

Namely: Co-authored-by: Michael Goulet <michael@errs.io>

@mu001999
Copy link
Contributor Author

@fmease Done. Thanks for the reminder! :)

@joshtriplett
Copy link
Member

What it doesn't implement are any optimizations that can be done on final trait methods, such as excluding them from the vtable of a dyn Trait.

Does this implement the requirement that final methods don't prevent a trait from being dyn-compatible?

@mu001999

This comment was marked as outdated.

@mu001999 mu001999 marked this pull request as draft January 30, 2026 12:48
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 30, 2026
@mu001999 mu001999 marked this pull request as ready for review January 30, 2026 14:31
@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 Jan 30, 2026
@mu001999
Copy link
Contributor Author

mu001999 commented Jan 30, 2026

Does this implement the requirement that final methods don't prevent a trait from being dyn-compatible?

Implemented now :). Also, updated the PR description.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

mu001999 and others added 3 commits February 5, 2026 23:46
Co-authored-by: Michael Goulet <michael@errs.io>
Co-authored-by: Michael Goulet <michael@errs.io>
Co-authored-by: Michael Goulet <michael@errs.io>
mu001999 and others added 3 commits February 5, 2026 23:49
Co-authored-by: Michael Goulet <michael@errs.io>
Co-authored-by: Michael Goulet <michael@errs.io>
Co-authored-by: Michael Goulet <michael@errs.io>
@rustbot
Copy link
Collaborator

rustbot commented Feb 5, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY                                   TAG       IMAGE ID       CREATED       SIZE
ghcr.io/dependabot/dependabot-updater-core   latest    bcec0b4e062b   10 days ago   783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:b662be51f7b8ef7e2c8464428f14e49cb79c36aa9afb7ecb9221dfe0f507050c
deleted: sha256:bcec0b4e062b5ffe11cc1c2729558c0cd96621c0271ab5e97ff3a56e0c25045a
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
tests/ui/drain_collect.fixed ... ok
tests/ui/duplicate_underscore_argument.rs ... ok
tests/ui/drop_non_drop.rs ... ok
tests/ui/duplicated_attributes.rs ... ok
tests/ui/duration_suboptimal_units_days_weeks.rs ... ok
tests/ui/duration_suboptimal_units.rs ... ok
tests/ui/double_parens.fixed ... ok
tests/ui/duration_subsec.rs ... ok
tests/ui/duration_suboptimal_units_days_weeks.fixed ... ok
tests/ui/duration_suboptimal_units.fixed ... ok
tests/ui/duration_subsec.fixed ... ok
tests/ui/eager_transmute.rs ... ok
tests/ui/elidable_lifetime_names.rs ... ok
tests/ui/else_if_without_else.rs ... ok
tests/ui/empty_docs.rs ... ok
---
..............................................     (146/146)

======== tests/rustdoc-gui/search-filter.goml ========

[ERROR] line 48: Error: The CSS selector "#search-tabs .count.loading" still exists: for command `wait-for-false: "#search-tabs .count.loading"`
    at <file:///checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc-gui/doc/test_docs/index.html?search=test>

======== tests/rustdoc-gui/search-result-display.goml ========

[WARNING] line 39: Delta is 0 for "x", maybe try to use `compare-elements-position` instead?

@mu001999
Copy link
Contributor Author

mu001999 commented Feb 6, 2026

Spurious failure

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

Labels

A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants