-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
rust: Use f-string formatting syntax #984
Conversation
You okay with this ugly An alternative is to apply the changes demanded by Clippy and update the minimum required version from 1.56 to 1.58. Since a) the current stable is 1.67, b) RustThemis does not really have that many users that should not be intrusive in practice. EDIT: You know... Let's do it then. Fewer lints – less awful code. Who am I trying to satisfy with Rust 1.56 compatibility? |
Or "variable capture" as it's called around here. Since of Rust 1.67, our God-Emperor Clippy started demanding this form of formatting. error: variables can be used directly in the `format!` string --> src/wrappers/themis/rust/libthemis-sys/build.rs:49:13 | 49 | eprintln!("{}", error); | ^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args = note: `-D clippy::uninlined-format-args` implied by `-D warnings` help: change this to | 49 - eprintln!("{}", error); 49 + eprintln!("{error}"); | Given that we're running WITH_FATAL_WARNINGS, we must either cave in, or suppress the lint. Suppressing it on Rust 1.56 requires suppressing another lint about unknown lint being suppressed. So, given that we're unlikely to have users which require Rust 1.56 specifically, I think it's okay to cave in, update MSRV to 1.58, and update all affect format strings so that Clippy stays happy.
72b7b80
to
830f740
Compare
just to clarify, after that change all code written 1-2 years ago with rust <1.58 version wouldn't be compiled with the current version of themis? |
Correct. This will cause syntax errors with Rust 1.56 and earlier, breaking the builds. I think this is acceptable as long as we do not backport this change to 0.14.x. Applications that depend like this [dependencies]
themis = "0.14" will still work. When they upgrade to |
Okay, understood. Is it a common approach to update rust compiler version on every release or how often usually it happens in rust projects? I looked on firefox and they upgrade compiler's version after 2+ releases (usually after 2 new versions) and currently uses 1.65 for stable builds. Now 1.67 is the latest version. But FF is a product, not library. So I looked at several popular rust libraries and what I found:
In our docs we have been published 1.31 version or later. I think we should choose a policy for ourselves how old rust compiler we want to support... |
This becomes less of a problem with Rust 1.67.1, but only temporarily. In 1.67.1 they have downgraded this lint to "pendatic" (ignored by default, unless explicitly enabled). However, this is only a temporary measure, until support for auto-fixing code to avoid this lint is there. They are still going to have it warn-by-default in the future, so this PR is still valid. |
A common support policy that I've seen in Rust libraries:
|
Do we really need to bump the version now? Can we temporarily suppress such warnings for some time? until we decide to bump the version for some serious reason instead of syntax sugar? |
I see no reason why we shouldn't use 1.58 as minimum instead of 1.56. The Rust compiler is always updating, the more versions we're behind, the more technical debt we have. I'd bump to 1.58 min + update product docs to mention the min version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to the previous orator. I'm not a fan of using the variable capture syntax everywhere (until it starts to support expressions; before that, mixing variable and expression looks awkward, IMHO), but everything for happy clippy!
|
🤦 |
Looks like the recently required 1.2 requires Rust 1.60 and that's too young for us. Stay on the older version to keep 1.58 compatibility. This is not strictly required, since a dev-dependency of utility, but I'd rather run the whole test suite than mix and match depending on Rust version.
Now that we require Rust 1.56+, we can finally put this in Cargo.toml and do not get a warning which would be treated as an error.
Aight. So I've pinned that one dev-dependency that didn't work with 1.58, now it's all green again ☀️
|
Or "variable capture" as it's called around here. Since of Rust 1.67, our God-Emperor Clippy started demanding this form of formatting.
Given that we're running WITH_FATAL_WARNINGS, we must either cave in, or suppress the lint. Suppressing it on Rust 1.56 requires suppressing another lint about unknown lint being suppressed.
So, given that we're unlikely to have users which require Rust 1.56 specifically, I think it's okay to cave in, update MSRV to 1.58, and update all affect format strings so that Clippy stays happy.
Checklist