Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign updead code (+ unused assignment, etc) warnings in macros do more harm than good #24580
Comments
steveklabnik
added
A-macros
A-lint
labels
Apr 20, 2015
This comment has been minimized.
This comment has been minimized.
|
I would like this. http://doc.rust-lang.org/bitflags/bitflags/macro.bitflags!.html is really annoying without it. |
This comment has been minimized.
This comment has been minimized.
|
In the mean time I'm using the following workaround:
It's not generic - you'll need to customize it for your struct - but at least it's something. |
This comment has been minimized.
This comment has been minimized.
|
Still repros. |
brson
added
I-wishlist
P-low
labels
Mar 9, 2017
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix Are you still passionate about this? |
This comment has been minimized.
This comment has been minimized.
SirVer
commented
Mar 31, 2017
•
|
I would still want this if possible. I have this macro:
This is for testing variable lengths packets (lists of strings) in a custom protocol. Usage is as follows:
I am rather pleased that macro and assert code are easy to read and understand, but for the last instance of the macro expansion I always get Maybe there is a way to avoid it, but I did not find it yet - I added a semantically non-sensical |
pnkfelix commentedApr 18, 2015
(imported from improperly closed bug #17427)
Consider the following code:
playpen
The
unused_assignmentslint fires from the expansion of the second occurrence ofm!(). But if you follow the advice of the lint and remove the assignment, you discover that the assignment was in fact significant, because when you remove the assignment, the side effect from the first occurrence ofm!()is lost, and so the call togdivides by zero.There are a number of different ways to handle this.