{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreieckagip7jnqrqoniojvvoxlijipux7uwqc3mjqibu7ewrnxnbbhi",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mgufvbyew2f2"
},
"path": "/t/idea-trait-methods-with-un-overridable-implementations/23906?page=2#post_25",
"publishedAt": "2026-03-12T06:00:48.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"github.com/rust-lang/rust",
"`final` methods should work the same as without it (if it works without it)",
"mu001999",
"play"
],
"textContent": "github.com/rust-lang/rust\n\n#### `final` methods should work the same as without it (if it works without it)\n\nopened 09:31AM - 10 Mar 26 UTC\n\n mu001999 \n\nI-unsound C-bug T-types A-dyn-trait F-final_associated_functions\n\nTracking: https://github.com/rust-lang/rust/issues/131179 Found when trying to …use `final` to impl `Error::type_id` in https://github.com/rust-lang/rust/pull/153598, this code (play) doesn't work as expected: ```rust #![feature(final_associated_functions)] trait Tr where Self: 'static, { final fn foo(&self) -> std::any::TypeId { std::any::TypeId::of::<Self>() } } struct Foo; impl Tr for Foo {} struct Bar; impl Tr for Bar {} fn foo(t: &dyn Tr) -> std::any::TypeId { t.foo() } fn main() { assert_ne!(foo(&Foo), foo(&Bar)); } ``` I expected to see this happen: run successfully Instead, this happened: assertion failed. And without `final`, this will run as expected. ### Meta ``` Build using the Nightly version: 1.96.0-nightly (2026-03-09 2d76d9bc76f27b03b489) ```",
"title": "Idea: trait methods with un-overridable implementations"
}