reflect icon indicating copy to clipboard operation
reflect copied to clipboard

Implement auto-ref

Open dtolnay opened this issue 7 years ago • 0 comments

If a library method is declared to take self by reference or mut reference and the user's macro invokes the method with a receiver that is not a reference, it would be good to mirror rustc's rules around automatically taking a reference to the receiver.

library! {
    extern crate krate {
        type Struct;

        impl Struct {
            fn method(&self);
        }
    }
}

let receiver = /* ... by value */;
RUNTIME::krate::Struct::method.INVOKE(receiver.reference()); // should not require reference()

dtolnay avatar May 27 '18 07:05 dtolnay