Clean up clippy.

This commit is contained in:
Stephen Chung
2022-07-27 16:04:24 +08:00
parent 21f822020f
commit 39dee556c4
36 changed files with 271 additions and 369 deletions

View File

@@ -270,11 +270,10 @@ impl Engine {
// Make it a custom keyword/symbol if it is disabled or reserved
if (!self.disabled_symbols.is_empty() && self.disabled_symbols.contains(s))
|| token.map_or(false, |v| v.is_reserved())
&& self.custom_keywords.is_empty()
|| !self.custom_keywords.contains_key(s)
{
if self.custom_keywords.is_empty() || !self.custom_keywords.contains_key(s)
{
self.custom_keywords.insert(s.into(), None);
}
self.custom_keywords.insert(s.into(), None);
}
s.into()
}

View File

@@ -28,7 +28,6 @@ impl Engine {
/// # }
/// ```
#[inline(always)]
#[must_use]
pub fn definitions(&self) -> Definitions {
Definitions {
engine: self,
@@ -54,7 +53,6 @@ impl Engine {
/// # }
/// ```
#[inline(always)]
#[must_use]
pub fn definitions_with_scope<'e>(&'e self, scope: &'e Scope<'e>) -> Definitions<'e> {
Definitions {
engine: self,
@@ -112,7 +110,6 @@ impl<'e> Definitions<'e> {
///
/// The returned iterator yields all definition files as (filename, content) pairs.
#[inline]
#[must_use]
pub fn iter_files(&self) -> impl Iterator<Item = (String, String)> + '_ {
IntoIterator::into_iter([
(
@@ -182,7 +179,6 @@ impl<'e> Definitions<'e> {
///
/// Always starts with `module <module name>;`.
#[cfg(not(feature = "no_module"))]
#[must_use]
pub fn modules(&self) -> impl Iterator<Item = (String, String)> + '_ {
let mut m = self
.engine

View File

@@ -9,24 +9,24 @@ bitflags! {
/// Bit-flags containing all language options for the [`Engine`].
pub struct LangOptions: u8 {
/// Is `if`-expression allowed?
const IF_EXPR = 0b_00000001;
const IF_EXPR = 0b_0000_0001;
/// Is `switch` expression allowed?
const SWITCH_EXPR = 0b_00000010;
const SWITCH_EXPR = 0b_0000_0010;
/// Is statement-expression allowed?
const STMT_EXPR = 0b_00000100;
const STMT_EXPR = 0b_0000_0100;
/// Is anonymous function allowed?
#[cfg(not(feature = "no_function"))]
const ANON_FN = 0b_00001000;
const ANON_FN = 0b_0000_1000;
/// Is looping allowed?
const LOOPING = 0b_00010000;
const LOOPING = 0b_0001_0000;
/// Is variables shadowing allowed?
const SHADOW = 0b_00100000;
const SHADOW = 0b_0010_0000;
/// Strict variables mode?
const STRICT_VAR = 0b_01000000;
const STRICT_VAR = 0b_0100_0000;
/// Raise error if an object map property does not exist?
/// Returns `()` if `false`.
#[cfg(not(feature = "no_object"))]
const FAIL_ON_INVALID_MAP_PROPERTY = 0b_10000000;
const FAIL_ON_INVALID_MAP_PROPERTY = 0b_1000_0000;
}
}

View File

@@ -144,9 +144,9 @@ impl Engine {
#[inline]
#[must_use]
pub(crate) fn format_type_name<'a>(&'a self, name: &'a str) -> std::borrow::Cow<'a, str> {
if name.starts_with("&mut ") {
let x = &name[5..];
if let Some(x) = name.strip_prefix("&mut ") {
let r = self.format_type_name(x);
return if x != r {
format!("&mut {}", r).into()
} else {
@@ -167,9 +167,9 @@ impl Engine {
return None;
})
.unwrap_or_else(|| match name {
"INT" => return type_name::<crate::INT>(),
"INT" => type_name::<crate::INT>(),
#[cfg(not(feature = "no_float"))]
"FLOAT" => return type_name::<crate::FLOAT>(),
"FLOAT" => type_name::<crate::FLOAT>(),
_ => map_std_type_name(name, false),
})
.into()