Convert *specific* warnings to errors?


#1

I’m working on a library that does a bunch of I/O stuff, and I’d like to be able to convert the warning: unused result which must be used, #[warn(unused_must_use)] on by default to an error, since (a) it’s very, very easy to forget about it, (b) the majority of the methods return a Result of some form or another, and © when testing methods that write to an I/O device, I’m making an assertion about the contents of the receiver, not the result of the method (see point (a)).

I don’t want to force all warnings to errors, since I’m implementing an existing protocol, and use scripts to generate a lot of code, most of which isn’t used yet. It would drive me up the wall having to either mark all the generated code as allow(unused), or actually use it all right now.

I would much rather have the build fail if I haven’t used a must_use result, as it’s just easier to keep up.


#2

You can write #![deny(unused_must_use)] at the top of your crate.