-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Open
Open
Copy link
Labels
A-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutC-bugCategory: This is a bug.Category: This is a bug.F-final_associated_functions`#![feature(final_associated_functions)]``#![feature(final_associated_functions)]`I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
Tracking: #131179
Found when trying to use final to impl Error::type_id in #153598, this code (play) doesn't work as expected:
#![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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutC-bugCategory: This is a bug.Category: This is a bug.F-final_associated_functions`#![feature(final_associated_functions)]``#![feature(final_associated_functions)]`I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.