bluss/maplit

Unused results

povilasb opened this issue · 3 comments

When we use unused_results lint check, rustc detects some issues in macros provided by maplit.

Just a fraction of those errors are:

➜  maplit git:(master) ✗ cargo test
   Compiling maplit v1.0.0 (file:///home/povilas/maidsafe/maplit)
warning: unused result
   --> src/lib.rs:55:17
    |
55  |                   _map.insert($key, $value);
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
...
256 |       let names = hashmap!{
    |  _________________-
257 | |         1 => "one",
258 | |         2 => "two",
259 | |     };
    | |_____- in this macro invocation
    |
note: lint level defined here
   --> src/lib.rs:1:23
    |
1   | #![warn(missing_docs, unused_results)]
    |                       ^^^^^^^^^^^^^^

warning: unused result
   --> src/lib.rs:55:17
    |
55  |                   _map.insert($key, $value);
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
...
256 |       let names = hashmap!{
    |  _________________-
257 | |         1 => "one",
258 | |         2 => "two",
259 | |     };
    | |_____- in this macro invocation

So for the sake of quality, I suggest denying unused_results in this crate: https://github.com/bluss/maplit/blob/master/src/lib.rs#L1

bluss commented

It's not a default lint and has tons of flse positives so I don't want to enble it.

@bluss This is a macro crate though. You don't necessarily need to enable it on the crate, but not having the let _ = ... in the macro code means that users of this crate can't use the lint either.

bluss commented

@canndrew Yes, I see that. Non-default lints definitely have low priority though. I've merged it.