Home:ALL Converter>How can I only show warnings if there are no errors?

How can I only show warnings if there are no errors?

Ask Time:2018-11-18T04:27:50         Author:Mark

Json Formatter

Often during development, I have a bunch of unused imports and variables. I like to fix those after I have correctly working code. The warnings these generate cause me to scroll though the cargo build output to find errors among all the warnings.

Is that possible to only show the warnings if compilation succeeds?

I don't want to ignore the warnings entirely, since I do want to solve them before committing the code.

Author:Mark,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/53355265/how-can-i-only-show-warnings-if-there-are-no-errors
rodrigo :

You can suppress warnings in your compilation using the -Awarnings flags. If you use Cargo, you can add it with:\n\ncargo rustc -- -Awarnings\n\n\nThat will compile your crate with warnings disabled, so only errors will show up. When you get a successful compilation, you can switch back to:\n\ncargo build\n\n\nAnd your crate will compile again (because the flags have changed, the target is no longer up to date) and you will get the detailed warnings.\n\nYou can try automating them by running:\n\ncargo rustc -- -Awarnings && cargo build\n\n\nThis has the drawback of compiling the crate twice if there are no errors and that can take some extra time.\n\nIf you want to compile all the dependencies without the warnings, you can run instead:\n\nRUSTFLAGS=-Awarnings cargo build\n\n\nBut then, the double compilation issue is quite more relevant.\n\n\n\nAs as side note, I think that some IDEs (VSCode?) are able to do that: sort the compiler messages and filter out the ones you are not interested in. ",
2018-11-18T13:39:10
yy