Skip to content

Commit

Permalink
shadow: Fix nightly linter warning for uninlined format arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
sameo committed Dec 14, 2022
1 parent b92ed1c commit 6cabb37
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ mod tests {
.unwrap();
assert!(regex.is_match(&time));

println!("local now:{}", time); // 2022-07-14 00:40:05 +08:00
println!("local now:{time}"); // 2022-07-14 00:40:05 +08:00
assert_eq!(time.len(), 26);
}

Expand Down
4 changes: 2 additions & 2 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ mod dep_source_replace {
if tree.trim().is_empty() {
tree.push_str(&val);
} else {
tree = format!("{}\n{}", tree, val);
tree = format!("{tree}\n{val}");
}
}
tree
Expand Down Expand Up @@ -272,7 +272,7 @@ pub fn new_system_env(std_env: &BTreeMap<String, String>) -> BTreeMap<ShadowCons
);

if let Err(e) = env.init(std_env) {
println!("{}", e);
println!("{e}");
}
env.map
}
Expand Down
2 changes: 1 addition & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ pub fn new_git(
);

if let Err(e) = git.init(path, std_env) {
println!("{}", e);
println!("{e}");
}

git.map
Expand Down
31 changes: 15 additions & 16 deletions src/lib.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl Shadow {
F: FnOnce(&File) -> SdResult<()>,
{
let desc = r#"/// Below code generated by project custom from by build.rs"#;
writeln!(&self.f, "\n{}\n", desc)?;
writeln!(&self.f, "\n{desc}\n")?;
f(&self.f)?;
Ok(())
}
Expand Down Expand Up @@ -303,7 +303,7 @@ impl Shadow {
let out = {
let path = Path::new(out_path.as_str());
if !out_path.ends_with('/') {
path.join(format!("{}/{}", out_path, SHADOW_RS))
path.join(format!("{out_path}/{SHADOW_RS}"))
} else {
path.join(SHADOW_RS)
}
Expand Down Expand Up @@ -348,7 +348,7 @@ impl Shadow {

pub fn cargo_rerun_if_env_changed(&self) {
for k in self.std_env.keys() {
println!("cargo:rerun-if-env-changed={}", k);
println!("cargo:rerun-if-env-changed={k}");
}
}

Expand All @@ -360,7 +360,7 @@ impl Shadow {

fn gen_const(&mut self) -> SdResult<()> {
for (k, v) in self.map.clone() {
println!("cargo:rerun-if-env-changed={}", k);
println!("cargo:rerun-if-env-changed={k}");
self.write_const(k, v)?;
}
Ok(())
Expand All @@ -374,7 +374,7 @@ impl Shadow {
// Create time by:{}"#,
DateTime::now().human_format()
);
writeln!(&self.f, "{}\n\n", desc)?;
writeln!(&self.f, "{desc}\n\n")?;
Ok(())
}

Expand Down Expand Up @@ -405,8 +405,8 @@ impl Shadow {
),
};

writeln!(&self.f, "{}", desc)?;
writeln!(&self.f, "{}\n", define)?;
writeln!(&self.f, "{desc}")?;
writeln!(&self.f, "{define}\n")?;
Ok(())
}

Expand All @@ -433,9 +433,9 @@ impl Shadow {
}
}
};
writeln!(&self.f, "{}\n", ver_fn)?;
writeln!(&self.f, "{}\n", clap_ver_fn)?;
writeln!(&self.f, "{}\n", clap_long_ver_fn)?;
writeln!(&self.f, "{ver_fn}\n")?;
writeln!(&self.f, "{clap_ver_fn}\n")?;
writeln!(&self.f, "{clap_long_ver_fn}\n")?;

Ok(vec![BUILD_CONST_VERSION, BUILD_CONST_CLAP_LONG_VERSION])
}
Expand All @@ -459,11 +459,10 @@ impl Shadow {
"/// print build in method\n\
#[allow(dead_code)]\n\
pub fn print_build_in() {\
{{}}\
}\n",
print_val,
{{print_val}}\
}\n",
);
writeln!(&self.f, "{}", everything_define)?;
writeln!(&self.f, "{everything_define}")?;

Ok(())
}
Expand All @@ -480,14 +479,14 @@ mod tests {
let shadow = fs::read_to_string("./shadow.rs")?;
assert!(!shadow.is_empty());
assert!(shadow.lines().count() > 0);
println!("{}", shadow);
println!("{shadow}");
Ok(())
}

#[test]
fn test_env() {
for (k, v) in std::env::vars() {
println!("K:{},V:{}", k, v);
println!("K:{k},V:{v}");
}
}
}

0 comments on commit 6cabb37

Please sign in to comment.