getset icon indicating copy to clipboard operation
getset copied to clipboard

Confusing error when `#[getset(get_copy = "pub")]` is specified but not `derive(CopyGetters)`

Open Boscop opened this issue 5 years ago • 3 comments

When #[getset(get_copy = "pub")] is specified but CopyGetters is not derived (only Getters), the proc-macro doesn't give an error, instead rustc gives the error that foo.bar() is not a method but a field.

Solution: The proc-macro could give an error. But I'd prefer another solution: Remove CopyGetters altogether, only have Getters, such that get_copy works when Getters is derived. This makes much more sense IMO. Or is there a reason to require the user to derive CopyGetters / any disadvantages when get_copy is also allowed with Getters? To me it seems to be more verbose / requiring more typing than necessary, and I often forget to derive CopyGetters.

Boscop avatar Jun 20 '20 00:06 Boscop

Aw shucks. :(

I think your suggestion is very reasonable.

Hoverbear avatar Jul 07 '20 17:07 Hoverbear

(A similar issue occurs when I have #[getset(get = "pub", get_mut = "pub")] on a field, but forget to derive MutGetters (when I only have Getters), then there is also no error by the proc-macro, only at the call location rustc complains that the foo_mut() method doesn't exist.)

Boscop avatar Jul 14 '20 02:07 Boscop

Why not make a step further and derive only a single target, say GetSet?

hermes85pl avatar Sep 03 '21 15:09 hermes85pl