Skip to content

Commit

Permalink
address lints from nightly (#121)
Browse files Browse the repository at this point in the history
* address lints from nightly

tested with cargo 1.78.0-nightly (f772ec022 2024-03-01)

* clippy with all-targets and all-features

---------

Co-authored-by: Brian Caswell <[email protected]>
  • Loading branch information
demoray and Brian Caswell authored Mar 4, 2024
1 parent 8d7d068 commit 01b54a7
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 20 deletions.
1 change: 1 addition & 0 deletions boreal-cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ fn test_input_cannot_read() {
let child = temp.path().join("child");
let _file = fs::OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.mode(0o000)
.open(&child)
Expand Down
2 changes: 1 addition & 1 deletion boreal-parser/src/expression/boolean_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ mod tests {
use super::*;
use crate::{
expression::{Identifier, MAX_EXPR_RECURSION},
regex::{self, Literal, Regex},
regex::{self, Literal},
test_helpers::{parse, parse_check, parse_err, parse_err_type, test_public_type},
};
use std::ops::Range;
Expand Down
4 changes: 1 addition & 3 deletions boreal-parser/src/expression/for_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,7 @@ fn rule_enum_element(input: Input) -> ParseResult<SetElement> {
#[cfg(test)]
mod tests {
use super::*;
use crate::expression::{
ExpressionKind, Identifier, IdentifierOperation, IdentifierOperationType,
};
use crate::expression::{Identifier, IdentifierOperation, IdentifierOperationType};
use crate::test_helpers::{parse, parse_err, test_public_type};

#[test]
Expand Down
8 changes: 4 additions & 4 deletions boreal-parser/src/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub enum ExpressionKind {
/// Which variables to select.
set: VariableSet,

/// ParsedExpr to evaluate for each variable.
/// `ParsedExpr` to evaluate for each variable.
///
/// The body can contain `$`, `#`, `@` or `!` to refer to the
/// currently selected variable.
Expand Down Expand Up @@ -383,10 +383,10 @@ pub enum ForSelection {
All,
/// None of the variables in the set must match the condition.
None,
/// ParsedExpr that should evaluate to a number, indicating:
/// - if as_percent is false, how many variables in the set must match
/// `ParsedExpr` that should evaluate to a number, indicating:
/// - if `as_percent` is false, how many variables in the set must match
/// the condition.
/// - if as_percent is true, which percentage of variables in the set
/// - if `as_percent` is true, which percentage of variables in the set
/// msut match the condition.
/// the condition.
///
Expand Down
2 changes: 1 addition & 1 deletion boreal-parser/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ fn condition(input: Input) -> ParseResult<Expression> {

#[cfg(test)]
mod tests {
use crate::expression::{Expression, ExpressionKind, ForSelection, VariableSet};
use crate::expression::{ExpressionKind, ForSelection, VariableSet};
use crate::hex_string::{Mask, Token};
use crate::regex::Literal;
use crate::test_helpers::test_public_type;
Expand Down
1 change: 0 additions & 1 deletion boreal-parser/src/string.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Parsing related to strings and identifiers.
use std::borrow::ToOwned;

use nom::{
bytes::complete::take_while,
Expand Down
7 changes: 3 additions & 4 deletions boreal/src/compiler/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,9 +972,9 @@ pub enum ForSelection {
/// None of the variables in the set must match the condition.
None,
/// Expression that should evaluate to a number, indicating:
/// - if as_percent is false, how many variables in the set must match
/// - if `as_percent` is false, how many variables in the set must match
/// the condition.
/// - if as_percent is true, which percentage of variables in the set
/// - if `as_percent` is true, which percentage of variables in the set
/// must match the condition.
/// the condition.
///
Expand Down Expand Up @@ -1307,8 +1307,7 @@ fn compile_identifier_as_iterator(
} else if compiler
.namespace
.rules_indexes
.get(&identifier.name)
.is_some()
.contains_key(&identifier.name)
{
return Err(CompilationError::NonIterableIdentifier {
span: identifier_span.clone(),
Expand Down
2 changes: 1 addition & 1 deletion boreal/src/matcher/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn analyze_hir(hir: &Hir, dot_all: bool) -> HirAnalysis {
}

struct HirAnalyser {
/// Is the dot_all flag set.
/// Is the `dot_all` flag set.
///
/// This is an input of the visitor, and not an output as other fields are.
dot_all: bool,
Expand Down
4 changes: 1 addition & 3 deletions boreal/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ impl Memory<'_> {
// Adjust ending offset relative to the region base and length
let relative_end = std::cmp::min(region.length, end - region.start);

let Some(fetched_region) = fragmented.obj.fetch(&fragmented.params) else {
return None;
};
let fetched_region = fragmented.obj.fetch(&fragmented.params)?;
cb(&fetched_region.mem[relative_start..relative_end]);
has_called_cb = true;

Expand Down
2 changes: 0 additions & 2 deletions boreal/src/scanner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,6 @@ impl std::fmt::Display for DefineSymbolError {

#[cfg(test)]
mod tests {
use std::collections::HashMap;

use crate::module::{EvalContext, ScanContext, StaticValue, Type, Value as ModuleValue};
use crate::test_helpers::{test_type_traits, test_type_traits_non_clonable};
use crate::Compiler;
Expand Down

0 comments on commit 01b54a7

Please sign in to comment.