From 66a63ce7cff00ae63e953ae3006d8288b8d1c926 Mon Sep 17 00:00:00 2001 From: Lorenzo Manacorda Date: Thu, 23 Mar 2023 11:51:36 +0100 Subject: [PATCH] Fix clippy warnings --- src/commonmark.rs | 4 ++-- src/main.rs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/commonmark.rs b/src/commonmark.rs index a192ea0..00458c6 100644 --- a/src/commonmark.rs +++ b/src/commonmark.rs @@ -16,7 +16,7 @@ //! This module implements CommonMark output for a struct //! representing a single entry in the manual. -use std::io::Write; + use failure::Error; /// Represent a single function argument name and its (optional) @@ -91,7 +91,7 @@ impl ManualEntry { /// Write a single CommonMark entry for a documented Nix function. pub fn write_section(self) -> Result<(), Error> { let title = format!("lib.{}.{}", self.category, self.name); - let ident = format!("lib.{}.{}", self.category, self.name.replace("'", "-prime")); + let ident = format!("lib.{}.{}", self.category, self.name.replace('\'', "-prime")); println!("## `{}` {{#function-library-{}}}\n", title, ident); diff --git a/src/main.rs b/src/main.rs index c255282..0c0f04b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ //! * extract line number & add it to generated output //! * figure out how to specify examples (& leading whitespace?!) -#[macro_use] extern crate structopt; +extern crate structopt; extern crate failure; extern crate rnix; @@ -32,7 +32,7 @@ use rnix::parser::{Arena, ASTNode, ASTKind, Data}; use rnix::tokenizer::Meta; use rnix::tokenizer::Trivia; use std::fs; -use std::io; + use std::path::PathBuf; use structopt::StructOpt; @@ -83,7 +83,7 @@ fn retrieve_doc_comment(allow_single_line: bool, meta: &Meta) -> Option } } - return None; + None } /// Transforms an AST node into a `DocItem` if it has a leading @@ -100,7 +100,7 @@ fn retrieve_doc_item(node: &ASTNode) -> Option { }) } - return None; + None } /// *Really* dumb, mutable, hacky doc comment "parser". @@ -138,7 +138,7 @@ fn parse_doc_comment(raw: &str) -> DocComment { } } - let f = |s: String| if s.is_empty() { None } else { Some(s.into()) }; + let f = |s: String| if s.is_empty() { None } else { Some(s) }; DocComment { doc: doc.trim().into(), @@ -148,7 +148,7 @@ fn parse_doc_comment(raw: &str) -> DocComment { } /// Traverse a pattern argument, collecting its argument names. -fn collect_pattern_args<'a>(arena: &Arena<'a>, +fn collect_pattern_args(arena: &Arena, entry: &ASTNode, args: &mut Vec) -> Option<()> { if let Data::Ident(meta, name) = &arena[entry.node.child?].data { @@ -178,7 +178,7 @@ fn collect_pattern_args<'a>(arena: &Arena<'a>, /// immediate child that is the identifier of its argument. The "body" /// of the lambda is two steps to the right from that identifier, if /// it is a lambda the function is curried and we can recurse. -fn collect_lambda_args<'a>(arena: &Arena<'a>, +fn collect_lambda_args(arena: &Arena, lambda_node: &ASTNode, args: &mut Vec) -> Option<()> { let ident_node = &arena[lambda_node.node.child?]; @@ -227,7 +227,7 @@ fn collect_lambda_args<'a>(arena: &Arena<'a>, /// 2. The attached doc comment on the entry. /// 3. The argument names of any curried functions (pattern functions /// not yet supported). -fn collect_entry_information<'a>(arena: &Arena<'a>, entry_node: &ASTNode) -> Option { +fn collect_entry_information(arena: &Arena, entry_node: &ASTNode) -> Option { // The "root" of any attribute set entry is this `SetEntry` node. // It has an `Attribute` child, which in turn has the identifier // (on which the documentation comment is stored) as its child.