Relaxed clippy fixes/nits (#2661)

This PR contains just a few clippy fixes and nits, which are, however,
relaxed by workspace clippy settings here:
https://github.com/paritytech/polkadot-sdk/blob/master/Cargo.toml#L483-L506

---------

Co-authored-by: Dmitry Sinyavin <dmitry.sinyavin@parity.io>
Co-authored-by: ordian <write@reusable.software>
Co-authored-by: command-bot <>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Branislav Kontur
2023-12-18 13:18:30 +01:00
committed by GitHub
parent a250652b3b
commit d941784b39
44 changed files with 76 additions and 106 deletions
@@ -15,7 +15,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::{env, fs, fs::File, io, io::Read, path::PathBuf};
use std::{
env, fs,
fs::File,
io,
io::Read,
path::{Path, PathBuf},
};
/// Make sure the calling `build.rs` script is rerun when `.git/HEAD` or the ref of `.git/HEAD`
/// changed.
@@ -55,7 +61,7 @@ pub fn rerun_if_git_head_changed() {
}
// Code taken from https://github.com/rustyhorde/vergen/blob/8d522db8c8e16e26c0fc9ea8e6b0247cbf5cca84/src/output/envvar.rs
fn get_git_paths(path: &PathBuf) -> Result<Option<Vec<PathBuf>>, io::Error> {
fn get_git_paths(path: &Path) -> Result<Option<Vec<PathBuf>>, io::Error> {
let git_dir_or_file = path.join(".git");
if let Ok(metadata) = fs::metadata(&git_dir_or_file) {
@@ -25,7 +25,7 @@ pub fn generate_cargo_keys() {
// We deliberately set the length here to `11` to ensure that
// the emitted hash is always of the same length; otherwise
// it can (and will!) vary between different build environments.
match Command::new("git").args(&["rev-parse", "--short=11", "HEAD"]).output() {
match Command::new("git").args(["rev-parse", "--short=11", "HEAD"]).output() {
Ok(o) if o.status.success() => {
let sha = String::from_utf8_lossy(&o.stdout).trim().to_owned();
Cow::from(sha)