systemd / zram-generator

Systemd unit generator for zram devices
MIT License
575 stars 48 forks source link

fixup: reported improvements by Clippy #171

Closed pheiduck closed 1 year ago

pheiduck commented 1 year ago

Added in: 1.65.0 uninlined_format_args What it does? Detect when a variable is not inlined in a format string, and suggests to inline it. Why is this bad? Non-inlined code is slightly more difficult to read and understand, as it requires arguments to be matched against the format string. The inlined syntax, where allowed, is simpler.

Examples:

format!("{}", var);
format!("{v:?}", v = var);
format!("{0} {0}", var);
format!("{0:1$}", var, width);
format!("{:.*}", prec, var);

Use instead:

format!("{var}");
format!("{var:?}");
format!("{var} {var}");
format!("{var:width$}");
format!("{var:.prec$}");

If allow-mixed-uninlined-format-args is set to false in clippy.toml, the following code will also trigger the lint: format!("{} {}", var, 1+2); Use instead: format!("{var} {}", 1+2);

nabijaczleweli commented 1 year ago

calling it an "error" is FUD, it's a stylistic choice, and it necessarily drastically cuts off MSRV (in this case: past bullseye cargo/rustc)

pheiduck commented 1 year ago

calling it an "error" is FUD, it's a stylistic choice, and it necessarily drastically cuts off MSRV (in this case: past bullseye cargo/rustc)

Agree, it introduce build regressions as well so, we will see how this endup in future releases of rust.

pheiduck commented 1 year ago

I would leave this open to work on.

pheiduck commented 1 year ago

@nabijaczleweli @keszybz you can review it again.

pheiduck commented 1 year ago

Fixes are no longer necessary I will close this PR. https://github.com/systemd/zram-generator/commit/af6fffe43a24b335abef3fd0f9b0bffdee4ef4c0 fixes some of them or of newer Rust Versions