Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy lints #123

Merged
merged 4 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix clippy::uninlined_format_args lint
  • Loading branch information
vbrandl committed Jan 28, 2023
commit 604d3913a3468d03da1fae0ea3b0ea70703f5fb2
11 changes: 5 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ fn handle_entries(
)?;
handle_entries(&mut modrs, &path, &outdir)?;
write_if_changed(&outdir.join("mod.rs"), &modrs)?;
writeln!(f, "pub mod {name};\n", name = filename)?;
writeln!(f, "pub mod {filename};\n")?;
}
} else if let Some(filename) = entry.file_name().to_str() {
for suffix in &[".rs.html", ".rs.svg", ".rs.xml"] {
Expand All @@ -368,7 +368,6 @@ fn handle_entries(
mod template_{name};\n\
#[doc(inline)]\n\
pub use self::template_{name}::{name};\n",
name = name,
)?;
}
}
Expand All @@ -391,13 +390,13 @@ fn handle_template(
let mut data = Vec::new();
t.write_rust(&mut data, name)?;
write_if_changed(
&outdir.join(format!("template_{}.rs", name)),
&outdir.join(format!("template_{name}.rs")),
&data,
)?;
Ok(true)
}
Err(error) => {
println!("cargo:warning=Template parse error in {:?}:", path);
println!("cargo:warning=Template parse error in {path:?}:");
show_errors(&mut io::stdout(), &buf, &error, "cargo:warning=");
Ok(false)
}
Expand Down Expand Up @@ -434,14 +433,14 @@ impl Error for RucteError {

impl Display for RucteError {
fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result {
write!(out, "Error: {:?}", self)
write!(out, "Error: {self:?}")
}
}
impl Debug for RucteError {
fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result {
match self {
RucteError::Io(err) => Display::fmt(err, out),
RucteError::Env(var, err) => write!(out, "{:?}: {}", var, err),
RucteError::Env(var, err) => write!(out, "{var:?}: {err}"),
#[cfg(feature = "sass")]
RucteError::Sass(err) => Debug::fmt(err, out),
}
Expand Down
4 changes: 2 additions & 2 deletions src/parseresult.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn show_errors(
}
}
Err::Incomplete(needed) => {
let msg = format!("Incomplete: {:?}", needed);
let msg = format!("Incomplete: {needed:?}");
show_error(out, buf, 0, &msg, prefix);
}
}
Expand All @@ -32,7 +32,7 @@ pub fn show_errors(
fn get_message(err: &VerboseErrorKind) -> Option<String> {
match err {
VerboseErrorKind::Context(msg) => Some((*msg).into()),
VerboseErrorKind::Char(ch) => Some(format!("Expected {:?}", ch)),
VerboseErrorKind::Char(ch) => Some(format!("Expected {ch:?}")),
VerboseErrorKind::Nom(_err) => None,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/staticfiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ impl StaticFile {
let mut input = File::open(&path)?;
let mut buf = Vec::new();
input.read_to_end(&mut buf)?;
let rust_name = format!("{}_{}", name, ext);
let rust_name = format!("{name}_{ext}");
let url_name =
format!("{}-{}.{}", name, checksum_slug(&buf), &ext);
self.add_static(
Expand Down Expand Up @@ -429,7 +429,7 @@ impl StaticFile {
{
let path = &self.path_for(path);
if let Some((name, ext)) = name_and_ext(path) {
let rust_name = format!("{}_{}", name, ext);
let rust_name = format!("{name}_{ext}");
let url_name =
format!("{}-{}.{}", name, checksum_slug(data), &ext);
self.add_static(
Expand Down
2 changes: 1 addition & 1 deletion src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Template {
use super::{Html,ToHtml};\n",
)?;
for l in &self.preamble {
writeln!(out, "{};", l)?;
writeln!(out, "{l};")?;
}
writeln!(
out,
Expand Down
13 changes: 6 additions & 7 deletions src/templateexpression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ impl TemplateExpression {
match *self {
TemplateExpression::Comment => String::new(),
TemplateExpression::Text { ref text } if text.is_ascii() => {
format!("_ructe_out_.write_all(b{:?})?;\n", text)
format!("_ructe_out_.write_all(b{text:?})?;\n")
}
TemplateExpression::Text { ref text } => {
format!("_ructe_out_.write_all({:?}.as_bytes())?;\n", text)
format!("_ructe_out_.write_all({text:?}.as_bytes())?;\n")
}
TemplateExpression::Expression { ref expr } => {
format!("{}.to_html(_ructe_out_)?;\n", expr)
format!("{expr}.to_html(_ructe_out_)?;\n")
}
TemplateExpression::ForLoop {
ref name,
Expand Down Expand Up @@ -129,8 +129,7 @@ impl TemplateExpression {
"{}(_ructe_out_{})?;\n",
name,
args.iter().format_with("", |arg, f| f(&format_args!(
", {}",
arg
", {arg}"
))),
)
}
Expand Down Expand Up @@ -234,7 +233,7 @@ pub fn template_expression(input: &[u8]) -> PResult<TemplateExpression> {
(i, Some(b"(")) => {
map(terminated(expr_inside_parens, tag(")")), |expr| {
TemplateExpression::Expression {
expr: format!("({})", expr),
expr: format!("({expr})"),
}
})(i)
}
Expand Down Expand Up @@ -353,7 +352,7 @@ fn cond_expression(input: &[u8]) -> PResult<String> {
),
),
),
|(lhs, rhs)| format!("let {} = {}", lhs, rhs),
|(lhs, rhs)| format!("let {lhs} = {rhs}"),
)(i),
(_i, Some(_)) => unreachable!(),
(i, None) => map(
Expand Down
2 changes: 1 addition & 1 deletion src/templates/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<T: Display> ToHtml for Html<T> {
impl<T: Display> ToHtml for T {
#[inline]
fn to_html(&self, out: &mut dyn Write) -> io::Result<()> {
write!(ToHtmlEscapingWriter(out), "{}", self)
write!(ToHtmlEscapingWriter(out), "{self}")
}
}

Expand Down