Allow fewer lints (#1340)

This commit is contained in:
Casey Rodarmor 2022-09-11 02:25:38 -07:00 committed by GitHub
parent 7b7efcabc2
commit c115b3f317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 31 deletions

View File

@ -1,7 +1,7 @@
use {
pulldown_cmark::{CowStr, Event, HeadingLevel, Options, Parser, Tag},
pulldown_cmark_to_cmark::cmark,
std::{collections::BTreeMap, error::Error, fs, ops::Deref},
std::{collections::BTreeMap, error::Error, fmt::Write, fs, ops::Deref},
};
type Result<T = ()> = std::result::Result<T, Box<dyn Error>>;
@ -174,12 +174,13 @@ fn main() -> Result {
HeadingLevel::H5 => 4,
HeadingLevel::H6 => 5,
};
summary.push_str(&format!(
"{}- [{}](chapter_{}.md)\n",
writeln!(
summary,
"{}- [{}](chapter_{}.md)",
" ".repeat(indent * 4),
chapter.title(),
chapter.number()
));
)?;
}
fs::write(format!("{}/SUMMARY.md", src), summary).unwrap();

View File

@ -1,7 +1,7 @@
use super::*;
pub(crate) trait ColorDisplay {
fn color_display<'a>(&'a self, color: Color) -> Wrapper<'a>
fn color_display(&self, color: Color) -> Wrapper
where
Self: Sized,
{

View File

@ -605,7 +605,7 @@ impl Config {
}
}
pub(crate) fn run<'src>(self, loader: &'src Loader) -> Result<(), Error<'src>> {
pub(crate) fn run(self, loader: &Loader) -> Result<(), Error> {
if let Err(error) = InterruptHandler::install(self.verbosity) {
warn!("Failed to set CTRL-C handler: {}", error);
}

View File

@ -1,11 +1,8 @@
#![deny(clippy::all, clippy::pedantic)]
#![allow(
clippy::doc_markdown,
clippy::empty_enum,
clippy::enum_glob_use,
clippy::if_not_else,
clippy::missing_errors_doc,
clippy::needless_lifetimes,
clippy::needless_pass_by_value,
clippy::non_ascii_literal,
clippy::shadow_unrelated,

View File

@ -179,14 +179,14 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
"Presumed next token would have kind {}, but found {}",
Identifier, next.kind
))?)
} else if keyword != next.lexeme() {
} else if keyword == next.lexeme() {
Ok(())
} else {
Err(self.internal_error(format!(
"Presumed next token would have lexeme \"{}\", but found \"{}\"",
keyword,
next.lexeme(),
))?)
} else {
Ok(())
}
}
@ -194,27 +194,27 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
fn presume(&mut self, kind: TokenKind) -> CompileResult<'src, Token<'src>> {
let next = self.advance()?;
if next.kind != kind {
if next.kind == kind {
Ok(next)
} else {
Err(self.internal_error(format!(
"Presumed next token would have kind {:?}, but found {:?}",
kind, next.kind
))?)
} else {
Ok(next)
}
}
/// Return an internal error if the next token is not one of kinds `kinds`.
fn presume_any(&mut self, kinds: &[TokenKind]) -> CompileResult<'src, Token<'src>> {
let next = self.advance()?;
if !kinds.contains(&next.kind) {
if kinds.contains(&next.kind) {
Ok(next)
} else {
Err(self.internal_error(format!(
"Presumed next token would be {}, but found {}",
List::or(kinds),
next.kind
))?)
} else {
Ok(next)
}
}
@ -357,16 +357,16 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
}
}
if self.next != self.tokens.len() {
Err(self.internal_error(format!(
"Parse completed with {} unparsed tokens",
self.tokens.len() - self.next,
))?)
} else {
if self.next == self.tokens.len() {
Ok(Ast {
warnings: Vec::new(),
items,
})
} else {
Err(self.internal_error(format!(
"Parse completed with {} unparsed tokens",
self.tokens.len() - self.next,
))?)
}
}

View File

@ -26,7 +26,7 @@ use super::*;
///
/// For modes that do take other arguments, the search argument is simply
/// prepended to rest.
#[cfg_attr(test, derive(PartialEq, Debug))]
#[cfg_attr(test, derive(PartialEq, Eq, Debug))]
pub struct Positional {
/// Overrides from values of the form `[a-zA-Z_][a-zA-Z0-9_-]*=.*`
pub overrides: Vec<(String, String)>,

View File

@ -356,7 +356,9 @@ impl Subcommand {
let formatted = ast.to_string();
if config.check {
return if formatted != src {
return if formatted == src {
Ok(())
} else {
use similar::{ChangeTag, TextDiff};
let diff = TextDiff::configure()
@ -376,8 +378,6 @@ impl Subcommand {
}
Err(Error::FormatCheckFoundDiff)
} else {
Ok(())
};
}
@ -421,11 +421,11 @@ impl Subcommand {
continue;
}
if !recipe_aliases.contains_key(alias.target.name.lexeme()) {
recipe_aliases.insert(alias.target.name.lexeme(), vec![alias.name.lexeme()]);
} else {
if recipe_aliases.contains_key(alias.target.name.lexeme()) {
let aliases = recipe_aliases.get_mut(alias.target.name.lexeme()).unwrap();
aliases.push(alias.name.lexeme());
} else {
recipe_aliases.insert(alias.target.name.lexeme(), vec![alias.name.lexeme()]);
}
}