Skip to content

method selection considers nested deref steps without applying the constrains from computing them #20

@lcnr

Description

@lcnr
#![feature(arbitrary_self_types)]
struct Foo<T>(T);
struct Bar;

impl std::ops::Deref for Foo<u32> {
    type Target = Bar;
    fn deref(&self) -> &Self::Target {
        &Bar
    }
}
impl Foo<i32> {
    fn call_me(self) {
        println!("Foo");
    }
    
    fn call_me_receiver(&self) {
        println!("Foo");
    }
}
impl Bar {
    fn call_me(self) {
        println!("Bar");
    }
    
    fn call_me_receiver(self: Foo<u32>) {
        println!("Bar");
    }
}

fn main() {
    let x = Foo(Default::default());
    x.call_me(); // Foo
    
    let x = Foo(Default::default());
    x.call_me_receiver(); // Bar
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions