Skip to content

Delegate to self fails #6

@fsitok

Description

@fsitok

This example fails:

#[portrait::make()]
pub trait X {
    fn m(&mut self);
}

struct MyStruct {}

impl X for MyStruct {
    fn m(&mut self) {
        println!("ok")
    }
}

#[portrait::fill(portrait::delegate(T; self))]
impl<T> X for Box<T> where T: X {}

The problem is, that here we delegate to self. Doing this is useful - it allows to achieve similar things as the blanket crate does.
However, right now the generated code would do something like:
<T as X>::m(&mut self)
The reference and mutability need to be stripped when self is already of type &mut Self. Likely problem would show up also with other cases.

Pull request comes in a second.

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