Skip to content

Implement RFC 3678: Final trait methods#130802

Closed
compiler-errors wants to merge 6 commits intorust-lang:masterfrom
compiler-errors:final
Closed

Implement RFC 3678: Final trait methods#130802
compiler-errors wants to merge 6 commits intorust-lang:masterfrom
compiler-errors:final

Conversation

@compiler-errors
Copy link
Contributor

@compiler-errors compiler-errors commented Sep 24, 2024

Implements the surface part of RFC 3678. Gonna keep this open as a draft until the RFC finishes FCP.

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. This also doesn't implement final for other trait items.

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.

r? @ghost

Tracking:

@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-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. labels Sep 24, 2024
@rust-log-analyzer

This comment has been minimized.

@scottmcm
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.

Note that doing so could also be a pessimization -- see conversation in rust-lang/rfcs#3678 (comment) -- so I think that's absolutely the right choice for now, and might even be the right choice going forward too.

@joshtriplett
Copy link
Member

@compiler-errors You are absolutely incredible; I did not expect someone to pick this up for implementation so quickly. Thank you! ❤️

@compiler-errors
Copy link
Contributor Author

This will need to be reworked almost totally since it seems that @joshtriplett is going to rewrite his RFC.

@joshtriplett
Copy link
Member

@compiler-errors I don't anticipate making an utter rewrite here, just changing final to #[inherent] and keeping the functionality exactly the same. (@traviscross would like to make an additional more ambitious change, but I'd like to start with just that.)

Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 17, 2026
…, r=fee1-dead

Implement RFC 3678: Final trait methods

Tracking: rust-lang#131179

This PR is based on rust-lang#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
rust-timer added a commit that referenced this pull request Feb 17, 2026
Rollup merge of #151783 - mu001999-contrib:impl/final-method, r=fee1-dead

Implement RFC 3678: Final trait methods

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
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Feb 18, 2026
…dead

Implement RFC 3678: Final trait methods

Tracking: rust-lang/rust#131179

This PR is based on rust-lang/rust#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
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Feb 19, 2026
…dead

Implement RFC 3678: Final trait methods

Tracking: rust-lang/rust#131179

This PR is based on rust-lang/rust#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
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-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments