From 39d36b40a74d244358e44737b011a31b09925118 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 1 Nov 2023 00:35:54 +0100 Subject: [PATCH] fmt Signed-off-by: Oliver Tale-Yazdi --- src/autofix.rs | 12 ++++++++---- src/cmd/debug.rs | 2 +- src/cmd/run.rs | 2 +- src/cmd/transpose.rs | 15 ++++++++------- tests/tests.rs | 16 ++++++++++++---- 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/autofix.rs b/src/autofix.rs index 0e1cfd2..871a013 100644 --- a/src/autofix.rs +++ b/src/autofix.rs @@ -447,7 +447,11 @@ impl AutoFixer { Ok(()) } - pub fn lift_dependency(&mut self, dname: &str, default_feats: Option) -> Result<(), String> { + pub fn lift_dependency( + &mut self, + dname: &str, + default_feats: Option, + ) -> Result<(), String> { let doc: &mut Document = self.doc.as_mut().unwrap(); for kind in &["dependencies", "dev-dependencies", "build-dependencies"] { @@ -471,13 +475,13 @@ impl AutoFixer { if let Some(as_str) = dep.as_str() { cargo_metadata::semver::VersionReq::parse(as_str).expect("Is semver"); let mut table = InlineTable::new(); - table.remove("default-features");// We also remove it to get the order right. + table.remove("default-features"); // We also remove it to get the order right. table.insert("workspace", Value::Boolean(Formatted::new(true))); if let Some(default_feats) = default_feats { table.insert("default-features", Value::Boolean(Formatted::new(default_feats))); } - + table.set_dotted(false); *dep = Item::Value(Value::InlineTable(table)); @@ -486,7 +490,7 @@ impl AutoFixer { return Err("'git' or 'path' dependency are currently not supported".into()) } as_table.remove("version"); - as_table.remove("default-features");// We also remove it to get the order right. + as_table.remove("default-features"); // We also remove it to get the order right. as_table.insert("workspace", Value::Boolean(Formatted::new(true))); if let Some(default_feats) = default_feats { diff --git a/src/cmd/debug.rs b/src/cmd/debug.rs index da62701..641c11c 100644 --- a/src/cmd/debug.rs +++ b/src/cmd/debug.rs @@ -26,7 +26,7 @@ impl DebugCmd { g.warn_unstable(); let meta = self.cargo_args.load_metadata().expect("Loads metadata"); let dag = build_feature_dag(&meta, &meta.packages); - + if !self.no_root { println!("Root: {}", meta.workspace_root.to_string()); } diff --git a/src/cmd/run.rs b/src/cmd/run.rs index 33ba422..6a1937a 100644 --- a/src/cmd/run.rs +++ b/src/cmd/run.rs @@ -38,7 +38,7 @@ impl RunCmd { if let Some(help) = config.fmt_help() { println!("\n{}", help); } - + std::process::exit(1); } } diff --git a/src/cmd/transpose.rs b/src/cmd/transpose.rs index 995f32e..0139be8 100644 --- a/src/cmd/transpose.rs +++ b/src/cmd/transpose.rs @@ -6,7 +6,7 @@ use crate::{autofix::*, grammar::*, log}; use cargo_metadata::{Dependency as Dep, Package}; use itertools::Itertools; -use semver::{Version, VersionReq, Op}; +use semver::{Op, Version, VersionReq}; use std::{ collections::{BTreeMap as Map, HashMap}, fs::canonicalize, @@ -99,7 +99,9 @@ impl LiftToWorkspaceCmd { let str_width = versions.iter().map(|v| v.to_string().len()).max().unwrap(); let mut err = String::new(); // iter by descending frequence - for (version, pkgs) in by_version.iter().sorted_by_key(|(v, pkgs)| (pkgs.len(), v.to_string())).rev() { + for (version, pkgs) in + by_version.iter().sorted_by_key(|(v, pkgs)| (pkgs.len(), v.to_string())).rev() + { let ddd = if pkgs.len() > 3 { ", …" } else { "" }; let s = plural_or(pkgs.len(), " "); // TODO plural s @@ -163,8 +165,7 @@ impl LiftToWorkspaceCmd { // Now create fixer for the root package let root_manifest_path = meta.workspace_root.join("Cargo.toml"); - let mut fixer = - AutoFixer::from_manifest(&root_manifest_path.into_std_path_buf()).unwrap(); + let mut fixer = AutoFixer::from_manifest(&root_manifest_path.into_std_path_buf()).unwrap(); let dep = by_version.values().next().unwrap().first().unwrap().1.clone(); fixer.add_workspace_dep(&dep, false).unwrap(); fixer.save().unwrap(); @@ -177,14 +178,14 @@ fn try_find_latest<'a, I: Iterator>(reqs: I) -> Result 0 { cmd.arg("--offline"); } @@ -94,7 +99,7 @@ fn integration() { colour::yellow!("OVERWRITE"); colour::white!(" "); cerr_overwrites.insert(i, String::from_utf8_lossy(&res.stderr).to_string()); - + failed += 1; }, (false, _) => { @@ -102,7 +107,7 @@ fn integration() { colour::yellow!("OVERWRITE"); colour::white!(" "); cout_overwrites.insert(i, String::from_utf8_lossy(&res.stdout).to_string()); - + failed += 1; }, } @@ -140,7 +145,10 @@ fn integration() { } if std::env::var("OVERWRITE").is_ok() { - if cout_overwrites.is_empty() && cerr_overwrites.is_empty() && diff_overwrites.is_empty() { + if cout_overwrites.is_empty() && + cerr_overwrites.is_empty() && + diff_overwrites.is_empty() + { continue }