Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Boscop opened this issue Jun 20, 2020 · 3 comments · May be fixed by #83
Open

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

Boscop opened this issue Jun 20, 2020 · 3 comments · May be fixed by #83
Labels

Comments

@Boscop
Copy link
Collaborator

Boscop commented Jun 20, 2020

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.

@Hoverbear
Copy link
Collaborator

Aw shucks. :(

I think your suggestion is very reasonable.

@Hoverbear Hoverbear added the bug label Jul 7, 2020
@Boscop
Copy link
Collaborator Author

Boscop commented Jul 14, 2020

(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.)

@hermes85pl
Copy link

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

hochej added a commit to hochej/getset that referenced this issue Feb 6, 2022
commit adds the following modifications:
- fixes bug (jbaublitz#67) and implements #[derive(GetSet)]
- allows overwriting of global getters with get_copy/get_option
- implements get_option/set_option as proposed in issue 78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants