Cargo --fix-obvious-warnings?

Is there a way to have cargo automatically fix certain warnings?

For example for things of the form:

import foo::Bar; // not used

the above code generates a warning. The fix is to delete the line. Is there a way to give Cargo permission to auto fix certain problems?


second example:

let mut x = ... // does not need to be mut

where the fix is to remove the 'mut'

The goal here is that programmer attention is finite, so if cargo had an option to auto fix obvious warnings, programmer attention can be directedc towards more important things.

1 Like

Try cargo fix. If it doesn't fix your code which should be possible you think, please consider to send PR for it!