Shut up clippy.
This commit is contained in:
@@ -167,7 +167,7 @@ impl AST {
|
||||
/// Get a reference to the source.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub(crate) fn source_raw(&self) -> &Identifier {
|
||||
pub(crate) const fn source_raw(&self) -> &Identifier {
|
||||
&self.source
|
||||
}
|
||||
/// Set the source.
|
||||
@@ -261,7 +261,7 @@ impl AST {
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub(crate) fn shared_lib(&self) -> &crate::Shared<crate::Module> {
|
||||
pub(crate) const fn shared_lib(&self) -> &crate::Shared<crate::Module> {
|
||||
&self.lib
|
||||
}
|
||||
/// _(internals)_ Get the internal shared [`Module`][crate::Module] containing all script-defined functions.
|
||||
@@ -272,7 +272,7 @@ impl AST {
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn shared_lib(&self) -> &crate::Shared<crate::Module> {
|
||||
pub const fn shared_lib(&self) -> &crate::Shared<crate::Module> {
|
||||
&self.lib
|
||||
}
|
||||
/// Get the embedded [module resolver][crate::ModuleResolver].
|
||||
@@ -280,7 +280,7 @@ impl AST {
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub(crate) fn resolver(
|
||||
pub(crate) const fn resolver(
|
||||
&self,
|
||||
) -> Option<&crate::Shared<crate::module::resolvers::StaticModuleResolver>> {
|
||||
self.resolver.as_ref()
|
||||
@@ -293,7 +293,7 @@ impl AST {
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn resolver(
|
||||
pub const fn resolver(
|
||||
&self,
|
||||
) -> Option<&crate::Shared<crate::module::resolvers::StaticModuleResolver>> {
|
||||
self.resolver.as_ref()
|
||||
@@ -910,7 +910,7 @@ impl<A: AsRef<AST>> Add<A> for &AST {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Into<AST>> AddAssign<A> for AST {
|
||||
impl<A: Into<Self>> AddAssign<A> for AST {
|
||||
#[inline(always)]
|
||||
fn add_assign(&mut self, rhs: A) {
|
||||
self.combine(rhs.into());
|
||||
|
@@ -338,17 +338,7 @@ impl<F: Float> FloatWrapper<F> {
|
||||
/// Create a new [`FloatWrapper`].
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn new(value: F) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
impl FloatWrapper<crate::FLOAT> {
|
||||
/// Create a new [`FloatWrapper`].
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn new_const(value: crate::FLOAT) -> Self {
|
||||
pub const fn new(value: F) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
@@ -600,7 +590,7 @@ impl Expr {
|
||||
Self::FnCall(ref x, ..)
|
||||
if !x.is_qualified() && x.args.len() == 1 && x.name == KEYWORD_FN_PTR =>
|
||||
{
|
||||
if let Expr::StringConstant(ref s, ..) = x.args[0] {
|
||||
if let Self::StringConstant(ref s, ..) = x.args[0] {
|
||||
FnPtr::new(s).ok()?.into()
|
||||
} else {
|
||||
return None;
|
||||
@@ -612,8 +602,8 @@ impl Expr {
|
||||
match x.name.as_str() {
|
||||
// x..y
|
||||
OP_EXCLUSIVE_RANGE => {
|
||||
if let Expr::IntegerConstant(ref start, ..) = x.args[0] {
|
||||
if let Expr::IntegerConstant(ref end, ..) = x.args[1] {
|
||||
if let Self::IntegerConstant(ref start, ..) = x.args[0] {
|
||||
if let Self::IntegerConstant(ref end, ..) = x.args[1] {
|
||||
(*start..*end).into()
|
||||
} else {
|
||||
return None;
|
||||
@@ -624,8 +614,8 @@ impl Expr {
|
||||
}
|
||||
// x..=y
|
||||
OP_INCLUSIVE_RANGE => {
|
||||
if let Expr::IntegerConstant(ref start, ..) = x.args[0] {
|
||||
if let Expr::IntegerConstant(ref end, ..) = x.args[1] {
|
||||
if let Self::IntegerConstant(ref start, ..) = x.args[0] {
|
||||
if let Self::IntegerConstant(ref end, ..) = x.args[1] {
|
||||
(*start..=*end).into()
|
||||
} else {
|
||||
return None;
|
||||
@@ -940,9 +930,9 @@ impl Expr {
|
||||
}
|
||||
Self::Index(x, ..)
|
||||
| Self::Dot(x, ..)
|
||||
| Expr::And(x, ..)
|
||||
| Expr::Or(x, ..)
|
||||
| Expr::Coalesce(x, ..) => {
|
||||
| Self::And(x, ..)
|
||||
| Self::Or(x, ..)
|
||||
| Self::Coalesce(x, ..) => {
|
||||
if !x.lhs.walk(path, on_node) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ impl FnAccess {
|
||||
/// Is this function private?
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn is_private(self) -> bool {
|
||||
pub const fn is_private(self) -> bool {
|
||||
match self {
|
||||
Self::Private => true,
|
||||
Self::Public => false,
|
||||
@@ -29,7 +29,7 @@ impl FnAccess {
|
||||
/// Is this function public?
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn is_public(self) -> bool {
|
||||
pub const fn is_public(self) -> bool {
|
||||
match self {
|
||||
Self::Private => false,
|
||||
Self::Public => true,
|
||||
|
@@ -60,7 +60,7 @@ impl OpAssignment {
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
pub fn new_op_assignment(name: &str, pos: Position) -> Self {
|
||||
Self::new_op_assignment_from_token(Token::lookup_from_syntax(name).expect("operator"), pos)
|
||||
Self::new_op_assignment_from_token(&Token::lookup_from_syntax(name).expect("operator"), pos)
|
||||
}
|
||||
/// Create a new [`OpAssignment`] from a [`Token`].
|
||||
///
|
||||
@@ -68,7 +68,7 @@ impl OpAssignment {
|
||||
///
|
||||
/// Panics if the token is not an op-assignment operator.
|
||||
#[must_use]
|
||||
pub fn new_op_assignment_from_token(op: Token, pos: Position) -> Self {
|
||||
pub fn new_op_assignment_from_token(op: &Token, pos: Position) -> Self {
|
||||
let op_raw = op
|
||||
.get_base_op_from_assignment()
|
||||
.expect("op-assignment operator")
|
||||
@@ -90,7 +90,7 @@ impl OpAssignment {
|
||||
#[inline(always)]
|
||||
pub fn new_op_assignment_from_base(name: &str, pos: Position) -> Self {
|
||||
Self::new_op_assignment_from_base_token(
|
||||
Token::lookup_from_syntax(name).expect("operator"),
|
||||
&Token::lookup_from_syntax(name).expect("operator"),
|
||||
pos,
|
||||
)
|
||||
}
|
||||
@@ -101,8 +101,8 @@ impl OpAssignment {
|
||||
/// Panics if the token is cannot be converted into an op-assignment operator.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn new_op_assignment_from_base_token(op: Token, pos: Position) -> Self {
|
||||
Self::new_op_assignment_from_token(op.convert_to_op_assignment().expect("operator"), pos)
|
||||
pub fn new_op_assignment_from_base_token(op: &Token, pos: Position) -> Self {
|
||||
Self::new_op_assignment_from_token(&op.convert_to_op_assignment().expect("operator"), pos)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,13 +157,13 @@ impl ConditionalExpr {
|
||||
/// Is the condition always `true`?
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn is_always_true(&self) -> bool {
|
||||
pub const fn is_always_true(&self) -> bool {
|
||||
matches!(self.condition, Expr::BoolConstant(true, ..))
|
||||
}
|
||||
/// Is the condition always `false`?
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn is_always_false(&self) -> bool {
|
||||
pub const fn is_always_false(&self) -> bool {
|
||||
matches!(self.condition, Expr::BoolConstant(false, ..))
|
||||
}
|
||||
}
|
||||
@@ -228,12 +228,12 @@ impl RangeCase {
|
||||
/// Size of the range.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn len(&self) -> usize {
|
||||
pub fn len(&self) -> INT {
|
||||
match self {
|
||||
Self::ExclusiveInt(r, ..) if r.is_empty() => 0,
|
||||
Self::ExclusiveInt(r, ..) => (r.end - r.start) as usize,
|
||||
Self::ExclusiveInt(r, ..) => r.end - r.start,
|
||||
Self::InclusiveInt(r, ..) if r.is_empty() => 0,
|
||||
Self::InclusiveInt(r, ..) => (*r.end() - *r.start()) as usize,
|
||||
Self::InclusiveInt(r, ..) => *r.end() - *r.start() + 1,
|
||||
}
|
||||
}
|
||||
/// Is the specified number within this range?
|
||||
@@ -248,7 +248,7 @@ impl RangeCase {
|
||||
/// Is the specified range inclusive?
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn is_inclusive(&self) -> bool {
|
||||
pub const fn is_inclusive(&self) -> bool {
|
||||
match self {
|
||||
Self::ExclusiveInt(..) => false,
|
||||
Self::InclusiveInt(..) => true,
|
||||
@@ -257,7 +257,7 @@ impl RangeCase {
|
||||
/// Get the index to the [`ConditionalExpr`].
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn index(&self) -> usize {
|
||||
pub const fn index(&self) -> usize {
|
||||
match self {
|
||||
Self::ExclusiveInt(.., n) | Self::InclusiveInt(.., n) => *n,
|
||||
}
|
||||
@@ -611,14 +611,14 @@ impl From<StmtBlock> for Stmt {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: IntoIterator<Item = Stmt>> From<(T, Position, Position)> for Stmt {
|
||||
impl<T: IntoIterator<Item = Self>> From<(T, Position, Position)> for Stmt {
|
||||
#[inline(always)]
|
||||
fn from(value: (T, Position, Position)) -> Self {
|
||||
StmtBlock::new(value.0, value.1, value.2).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: IntoIterator<Item = Stmt>> From<(T, Span)> for Stmt {
|
||||
impl<T: IntoIterator<Item = Self>> From<(T, Span)> for Stmt {
|
||||
#[inline(always)]
|
||||
fn from(value: (T, Span)) -> Self {
|
||||
StmtBlock::new_with_span(value.0, value.1).into()
|
||||
@@ -765,7 +765,7 @@ impl Stmt {
|
||||
Self::Noop(..) => true,
|
||||
Self::Expr(expr) => expr.is_pure(),
|
||||
Self::If(x, ..) => {
|
||||
x.0.is_pure() && x.1.iter().all(Stmt::is_pure) && x.2.iter().all(Stmt::is_pure)
|
||||
x.0.is_pure() && x.1.iter().all(Self::is_pure) && x.2.iter().all(Self::is_pure)
|
||||
}
|
||||
Self::Switch(x, ..) => {
|
||||
let (expr, sw) = &**x;
|
||||
@@ -786,7 +786,7 @@ impl Stmt {
|
||||
Self::While(x, ..) if matches!(x.0, Expr::BoolConstant(false, ..)) => true,
|
||||
Self::Do(x, options, ..) if matches!(x.0, Expr::BoolConstant(..)) => match x.0 {
|
||||
Expr::BoolConstant(cond, ..) if cond == options.contains(ASTFlags::NEGATED) => {
|
||||
x.1.iter().all(Stmt::is_pure)
|
||||
x.1.iter().all(Self::is_pure)
|
||||
}
|
||||
_ => false,
|
||||
},
|
||||
@@ -796,13 +796,13 @@ impl Stmt {
|
||||
|
||||
// For loops can be pure because if the iterable is pure, it is finite,
|
||||
// so infinite loops can never occur.
|
||||
Self::For(x, ..) => x.2.is_pure() && x.3.iter().all(Stmt::is_pure),
|
||||
Self::For(x, ..) => x.2.is_pure() && x.3.iter().all(Self::is_pure),
|
||||
|
||||
Self::Var(..) | Self::Assignment(..) | Self::FnCall(..) => false,
|
||||
Self::Block(block, ..) => block.iter().all(Stmt::is_pure),
|
||||
Self::Block(block, ..) => block.iter().all(Self::is_pure),
|
||||
Self::BreakLoop(..) | Self::Return(..) => false,
|
||||
Self::TryCatch(x, ..) => {
|
||||
x.try_block.iter().all(Stmt::is_pure) && x.catch_block.iter().all(Stmt::is_pure)
|
||||
x.try_block.iter().all(Self::is_pure) && x.catch_block.iter().all(Self::is_pure)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
@@ -828,7 +828,7 @@ impl Stmt {
|
||||
Self::Var(..) => true,
|
||||
|
||||
Self::Expr(e) => match &**e {
|
||||
Expr::Stmt(s) => s.iter().all(Stmt::is_block_dependent),
|
||||
Expr::Stmt(s) => s.iter().all(Self::is_block_dependent),
|
||||
Expr::FnCall(x, ..) => !x.is_qualified() && x.name == KEYWORD_EVAL,
|
||||
_ => false,
|
||||
},
|
||||
@@ -854,7 +854,7 @@ impl Stmt {
|
||||
Self::Var(x, ..) => x.1.is_pure(),
|
||||
|
||||
Self::Expr(e) => match &**e {
|
||||
Expr::Stmt(s) => s.iter().all(Stmt::is_internally_pure),
|
||||
Expr::Stmt(s) => s.iter().all(Self::is_internally_pure),
|
||||
_ => self.is_pure(),
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user