-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
glib-macros: Mark property getters as #[must_use] #1192
Conversation
In this piece of code, the cast I added the span to the entire generated code without knowing about the possible consequences with clippy... I agree that I don't agree on adding |
What's the point of using a getter without using the value? |
A custom getter could trigger a side effect and you may not need the actual value. Apart from that edge case, in the general case rust getters don't have a
In our case whether we use the returned value or not, nothing changes, so adding |
Alright, that makes sense. I just assumed that I guess a proper fix would then be about keeping the function declaration largely mixed site and only use the attribute span for the type cast. |
Ok, I've read more about Considering that, most of the times, the user calls a getter to actually get and use the returned value and not to produce a side effect, I assume adding |
This PR should fix #1186
I'm still not convinced that
quote_spanned
is correctly used (because there are obviously a lot of tokens which have nothing to do with the span of the attribute), but I don't know the reasoning behind the code, so adding#[must_use]
to the codegen is the easiest fix and actually a useful addition even if you don't useclippy::must_use_candidate
.