bluss/maplit

this crate triggers "unused result" lint

madadam opened this issue · 5 comments

Hi there,

The macros in this crate trigger the "unused result" lint, because you ignore the return value of insert (example here: https://github.com/bluss/maplit/blob/master/src/lib.rs#L122). The fix is simple, you should assign the result to _:

let _ = _map.insert($key, $value);
bluss commented

Ok I'm torn, it seems simple enough, but it's a non-default lint. I don't want to make more changes for clippy or other non-default linters. Thanks, feel free to report bugs in maplit.

I understand, but the change would not affect users that have only the default lints enabled (you are throwing away the result anyway), but would make your crate a bit more useful for people who use stricter lints. If you don't want to bother with this, I can send you a pull request. Would you be interested?

feel free to report bugs in maplit.

I'm confused. Isn't it what I just did?

bluss commented

I don't think this is a defect in maplit. Ok, it's maybe annoying, but I think these lints are annoying too, they are not finding real problems (and there's a reason it's not enabled by default). Previous PRs to fix clippy lints didn't really work out, so I'm not fond of the idea of adjusting to lints with lots of false positives.

Ok, it's maybe annoying

Not just annoying, it's preventing usage in real code base

they are not finding real problems

They have done it in more than one instance in production grade codes. If you have a function that previously returned () and invoked it as foo(); that would be fine. Later if it was refactored to returning a result or something, then the lint would force you to revisit all places you used foo();. Of-course you can still get around it by having done let _ = foo(); the very first time. At that point it's ok as the code is saying it intentionally doesn't care - which is what this code should also be saying.

Also this is nothing to do with clippy.

bluss commented

I'm confused. Isn't it what I just did?

I emphasized that I welcome issue reports, even if I was declining this particular one.

@ustulation Ok, I'd like to hand over maintainership of this crate if someone wants to steer it towards a better future.