Keep dyn-compatible final methods in the vtable#153696
Keep dyn-compatible final methods in the vtable#153696mu001999 wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
rustbot has assigned @dingxiangfei2009. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
I don't think this is sound. If the |
|
RFC has the statement says:
And with allowing #![feature(final_associated_functions)]
trait Trait {
fn foo(&self);
final fn bar<T>(&self, x: T) -> T {
self.foo(); // Call dyn-compatible methods
x
}
}
struct Foo;
impl Trait for Foo {
fn foo(&self) {
println!("Foo");
}
}
struct Bar;
impl Trait for Bar {
fn foo(&self) {
println!("Bar");
}
}
fn foo(t: &dyn Trait) {
let _ = t.bar(0i32);
}
fn main() {
foo(&Foo);
foo(&Bar);
} |
|
Repeating a comment from IRLO: [The cited issue] is related to #57893; namely, always preferring the user defined method in cases of overlap breaks invocations of [...] If The cited issue shows that this applies to custom downcasting impls, not just |
Fixes #153649
Current implementation will exclude final methods from the trait's vtable, this PR will keep those dyn-compatible ones in the trait's vtable.