Skip to content

Commit

Permalink
Chore: Make Clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
xFrednet committed Aug 29, 2023
1 parent 85cd7fa commit bacf61d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
14 changes: 7 additions & 7 deletions cargo-marker/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,27 @@ mod tests {

#[test]
fn test_marker_cli() {
let cli = MarkerCli::parse_from(&["cargo-marker", "check"]);
let cli = MarkerCli::parse_from(["cargo-marker", "check"]);
assert!(matches!(cli.command, Some(CliCommand::Check(_))));

let cli = MarkerCli::parse_from(&["cargo-marker"]);
assert!(matches!(cli.command, None));
let cli = MarkerCli::parse_from(["cargo-marker"]);
assert!(cli.command.is_none());
assert!(cli.check_args.cargo_args.is_empty());

let cli = MarkerCli::parse_from(&["cargo-marker", "--", "ducks", "penguins"]);
assert!(matches!(cli.command, None));
let cli = MarkerCli::parse_from(["cargo-marker", "--", "ducks", "penguins"]);
assert!(cli.command.is_none());
assert!(cli.check_args.cargo_args.len() == 2);
assert!(cli.check_args.cargo_args[0] == "ducks");
assert!(cli.check_args.cargo_args[1] == "penguins");

let cli = MarkerCli::parse_from(&["cargo-marker", "check", "--", "ducks", "penguins"]);
let cli = MarkerCli::parse_from(["cargo-marker", "check", "--", "ducks", "penguins"]);
assert!(cli.check_args.cargo_args.is_empty());
if let Some(CliCommand::Check(check_args)) = cli.command {
assert!(check_args.cargo_args.len() == 2);
assert!(check_args.cargo_args[0] == "ducks");
assert!(check_args.cargo_args[1] == "penguins");
} else {
assert!(false, "the `check` subcommand was not detected");
panic!("the `check` subcommand was not detected");
}
}
}
2 changes: 1 addition & 1 deletion marker_uilints/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ pub fn check_item<'ast>(cx: &'ast AstContext<'ast>, item: ItemKind<'ast>) {
format!("testing `contains_return` -> {res}"),
ident.span(),
|_| {},
)
);
}
}
9 changes: 5 additions & 4 deletions marker_utils/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use marker_api::{
/// The target scope, is checked when the respective `traverse_*` function is called
/// For example, [`traverse_body`] will visit a given body [`Body`], but will not enter
/// nested bodies, unless [`AllBodies`](VisitorScope::AllBodies) is defined.
#[non_exhaustive]
#[derive(Debug, Copy, Clone, Default)]
pub enum VisitorScope {
/// All bodies are visited, this includes bodies from nested items and closures.
Expand Down Expand Up @@ -100,8 +101,6 @@ pub fn traverse_item<'ast, B>(
visitor: &mut dyn Visitor<B>,
kind: ItemKind<'ast>,
) -> ControlFlow<B> {
visitor.visit_item(cx, kind)?;

/// A small wrapper around [`traverse_body`] that checks the defined scope
/// and validity of the [`BodyId`]
fn traverse_body_id<'ast, B>(
Expand All @@ -122,6 +121,8 @@ pub fn traverse_item<'ast, B>(
ControlFlow::Continue(())
}

visitor.visit_item(cx, kind)?;

match kind {
ItemKind::Mod(module) => {
for mod_item in module.items() {
Expand Down Expand Up @@ -151,7 +152,7 @@ pub fn traverse_item<'ast, B>(
for variant in item.variants() {
visitor.visit_variant(cx, variant)?;
if let Some(const_expr) = variant.discriminant() {
traverse_expr(cx, visitor, const_expr.expr())?
traverse_expr(cx, visitor, const_expr.expr())?;
}
}
},
Expand Down Expand Up @@ -434,7 +435,7 @@ pub fn for_each_expr<'ast, B, F: for<'a> FnMut(ExprKind<'a>) -> ControlFlow<B>>(
let mut visitor = ExprVisitor { f };

match node.traverse(cx, &mut visitor) {
ControlFlow::Continue(_) => None,
ControlFlow::Continue(()) => None,
ControlFlow::Break(b) => Some(b),
}
}

0 comments on commit bacf61d

Please sign in to comment.