chore: clippy lints
This commit is contained in:
parent
9301d38b77
commit
5e46fef0d7
17 changed files with 72 additions and 64 deletions
|
|
@ -7,6 +7,7 @@ pub struct Edit {
|
|||
pub inserted_text: Vec<u8>,
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn invert_edit(input: &[u8], edit: &Edit) -> Edit {
|
||||
let position = edit.position;
|
||||
let removed_content = &input[position..(position + edit.deleted_length)];
|
||||
|
|
|
|||
|
|
@ -65,20 +65,6 @@ pub fn fuzz_language_corpus(
|
|||
grammar_dir: &Path,
|
||||
options: &mut FuzzOptions,
|
||||
) {
|
||||
let subdir = options.subdir.take().unwrap_or_default();
|
||||
|
||||
let corpus_dir = grammar_dir.join(subdir).join("test").join("corpus");
|
||||
|
||||
if !corpus_dir.exists() || !corpus_dir.is_dir() {
|
||||
eprintln!("No corpus directory found, ensure that you have a `test/corpus` directory in your grammar directory with at least one test file.");
|
||||
return;
|
||||
}
|
||||
|
||||
if std::fs::read_dir(&corpus_dir).unwrap().count() == 0 {
|
||||
eprintln!("No corpus files found in `test/corpus`, ensure that you have at least one test file in your corpus directory.");
|
||||
return;
|
||||
}
|
||||
|
||||
fn retain(entry: &mut TestEntry, language_name: &str) -> bool {
|
||||
match entry {
|
||||
TestEntry::Example { attributes, .. } => {
|
||||
|
|
@ -97,6 +83,20 @@ pub fn fuzz_language_corpus(
|
|||
}
|
||||
}
|
||||
|
||||
let subdir = options.subdir.take().unwrap_or_default();
|
||||
|
||||
let corpus_dir = grammar_dir.join(subdir).join("test").join("corpus");
|
||||
|
||||
if !corpus_dir.exists() || !corpus_dir.is_dir() {
|
||||
eprintln!("No corpus directory found, ensure that you have a `test/corpus` directory in your grammar directory with at least one test file.");
|
||||
return;
|
||||
}
|
||||
|
||||
if std::fs::read_dir(&corpus_dir).unwrap().count() == 0 {
|
||||
eprintln!("No corpus files found in `test/corpus`, ensure that you have at least one test file in your corpus directory.");
|
||||
return;
|
||||
}
|
||||
|
||||
let mut main_tests = parse_tests(&corpus_dir).unwrap();
|
||||
match main_tests {
|
||||
TestEntry::Group {
|
||||
|
|
@ -104,7 +104,7 @@ pub fn fuzz_language_corpus(
|
|||
} => {
|
||||
children.retain_mut(|child| retain(child, language_name));
|
||||
}
|
||||
_ => unreachable!(),
|
||||
TestEntry::Example { .. } => unreachable!(),
|
||||
}
|
||||
let tests = flatten_tests(main_tests, options.filter.as_ref());
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ const OPERATORS: &[char] = &[
|
|||
pub struct Rand(StdRng);
|
||||
|
||||
impl Rand {
|
||||
#[must_use]
|
||||
pub fn new(seed: usize) -> Self {
|
||||
Self(StdRng::seed_from_u64(seed as u64))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ pub struct ScopeSequence(Vec<ScopeStack>);
|
|||
type ScopeStack = Vec<&'static str>;
|
||||
|
||||
impl ScopeSequence {
|
||||
#[must_use]
|
||||
pub fn new(tree: &Tree) -> Self {
|
||||
let mut result = Self(Vec::new());
|
||||
let mut scope_stack = Vec::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue