Bevy: Disable "function is never used" lints when function is a system.

Created on 9 Oct 2020  路  6Comments  路  Source: bevyengine/bevy

I get these annoying

warning: function is never used: `log_system`

messages whenever I only use the function as a system. It would be nice if this could be disabled (maybe have a seperate lint that fixes this issue and disable the original lint?)

Most helpful comment

This also goes against my understanding of how these warnings work. Can you please provide example code that reproduces this warning? Unfortunately if we don't have a way to repro, I'm just going to assume that this is user error.

All 6 comments

It's rustc that emits these lints, not bevy, so there isn't much that can be done about on bevy's end. Still, that is odd. When I use a function as a system, rustc considers it used. Could you post code that recreates this? What prints when you do rustc --version?

Technically, rustc lints can be disabled, but I would be wary about disabling ones like these since it might be catching when systems are accidentally not registered. e.g. if you see a warning like

warning: function is never used: `f`
  --> src\main.rs:37:4
   |
37 | fn f() {}
   |    ^
   |
   = note: `#[warn(dead_code)]` on by default

then you can place a #[allow(dead_code)] on top of the function or preface the name with an underscore _f and the warning will go away; however, I wouldn't suggest that, since .add_system(f.system()) correctly removed the warning for me.

I use nightly (rustc 1.48.0-nightly (154f1f544 2020-10-02)) because I don't have the features I want in stable.

For sure. I tried the nightly I had installed, rustc 1.49.0-nightly (3525087ad 2020-10-08), and was unable to reproduce the issue, and I'm not finding any recent regressions for the lint on rustc's repo. If you post the code that creates this warning, I would be happy to help minimize it, then we can narrow down where its coming from / where we should direct the report.

It's also possible that the warnings are stale in your editor. Be sure to try in your terminal cargo check and see if it emits the warnings at those times too. For example, if rust-analyzer hasn't re-run cargo check, it might be showing a stale/out-of-date warning.

I'm using cargo fmt to get these warnings, not rust-analyzer.

This also goes against my understanding of how these warnings work. Can you please provide example code that reproduces this warning? Unfortunately if we don't have a way to repro, I'm just going to assume that this is user error.

Closing since this is either user error or a bug in rust tooling.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aclysma picture aclysma  路  17Comments

kakoeimon picture kakoeimon  路  13Comments

andreasterrius picture andreasterrius  路  27Comments

cart picture cart  路  29Comments

cart picture cart  路  18Comments