Satisfy more clippy.

This commit is contained in:
Stephen Chung
2022-11-23 16:14:11 +08:00
parent 9f5b68549a
commit 3e7408511e
20 changed files with 150 additions and 146 deletions

View File

@@ -1012,7 +1012,20 @@ impl PartialEq for ASTNode<'_> {
impl Eq for ASTNode<'_> {}
impl ASTNode<'_> {
/// Is this [`ASTNode`] a [`Stmt`]?
#[inline(always)]
#[must_use]
pub const fn is_stmt(&self) -> bool {
matches!(self, Self::Stmt(..))
}
/// Is this [`ASTNode`] an [`Expr`]?
#[inline(always)]
#[must_use]
pub const fn is_expr(&self) -> bool {
matches!(self, Self::Expr(..))
}
/// Get the [`Position`] of this [`ASTNode`].
#[inline]
#[must_use]
pub fn position(&self) -> Position {
match self {

View File

@@ -6,7 +6,7 @@ use std::prelude::v1::*;
/// A type representing the access mode of a function.
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(feature = "metadata", derive(serde::Serialize))]
#[cfg_attr(feature = "metadata", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "metadata", serde(rename_all = "camelCase"))]
#[non_exhaustive]
pub enum FnAccess {

View File

@@ -926,10 +926,7 @@ impl Stmt {
#[inline]
#[must_use]
pub const fn is_control_flow_break(&self) -> bool {
match self {
Self::Return(..) | Self::BreakLoop(..) => true,
_ => false,
}
matches!(self, Self::Return(..) | Self::BreakLoop(..))
}
/// Recursively walk this statement.
/// Return `false` from the callback to terminate the walk.