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

[BUG] property macro #[must_use] since 0.18.2 #1186

Closed
AaronErhardt opened this issue Sep 15, 2023 · 0 comments · Fixed by #1192
Closed

[BUG] property macro #[must_use] since 0.18.2 #1186

AaronErhardt opened this issue Sep 15, 2023 · 0 comments · Fixed by #1192
Labels
bug Something isn't working glib-macros

Comments

@AaronErhardt
Copy link
Contributor

Bug description

After a cargo update which bumped glib-macros to 0.18.2, I've got several of clippy warnings in Relm4:

warning: this method could have a `#[must_use]` attribute
   --> relm4/src/binding/bindings.rs:59:17
    |
59  |                 #[property(get, set)]
    |                 ^ help: add the attribute: `#[must_use] #`
...
101 | binding!(StringBinding, "StringBinding", String, imp_strin...
    | ------------------------------------------------------------ in this macro invocation
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate
    = note: this warning originates in the macro `binding` (in Nightly builds, run with -Z macro-backtrace for more info)

It seems like the macro is using quote_spanned since #1149, which makes clippy think that the user forget to add a #[must_use] if you enabled the clippy::must_use_candidate lint for your project. quote_spanned might help to improve the error reporting, but it can also trigger unexpected clippy lints.

To solve this, either #[must_use] should be added to the generated methods or the spans have to be adjusted carefully to make it clear for clippy that those tokens were produced by a macro.

Steps to reproduce

  1. Use the property macro
  2. Enable the clippy::must_use_candidate lint
  3. Rust cargo clippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working glib-macros
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants