chore: clippy fix needless_borrow

This commit is contained in:
quake 2022-07-20 21:16:35 +09:00
parent 87af0db074
commit 299777f1c9
11 changed files with 25 additions and 25 deletions

View File

@ -150,7 +150,7 @@ impl Parse for Module {
name: ident.to_string(),
typ: ty.clone(),
expr: expr.as_ref().clone(),
cfg_attrs: crate::attrs::collect_cfg_attr(&attrs),
cfg_attrs: crate::attrs::collect_cfg_attr(attrs),
}),
_ => {}
}
@ -167,7 +167,7 @@ impl Parse for Module {
}) => custom_types.push(ExportedType {
name: ident.to_string(),
typ: ty.clone(),
cfg_attrs: crate::attrs::collect_cfg_attr(&attrs),
cfg_attrs: crate::attrs::collect_cfg_attr(attrs),
}),
_ => {}
}

View File

@ -45,8 +45,8 @@ pub fn generate_body(
..
} in consts
{
let const_literal = syn::LitStr::new(&const_name, Span::call_site());
let const_ref = syn::Ident::new(&const_name, Span::call_site());
let const_literal = syn::LitStr::new(const_name, Span::call_site());
let const_ref = syn::Ident::new(const_name, Span::call_site());
let cfg_attrs: Vec<_> = cfg_attrs
.iter()
@ -69,7 +69,7 @@ pub fn generate_body(
..
} in custom_types
{
let const_literal = syn::LitStr::new(&name, Span::call_site());
let const_literal = syn::LitStr::new(name, Span::call_site());
let cfg_attrs: Vec<_> = cfg_attrs
.iter()
@ -86,7 +86,7 @@ pub fn generate_body(
}
for item_mod in sub_modules {
item_mod.update_scope(&parent_scope);
item_mod.update_scope(parent_scope);
if item_mod.skipped() {
continue;
}
@ -117,7 +117,7 @@ pub fn generate_body(
let mut gen_fn_tokens = Vec::new();
for function in fns {
function.update_scope(&parent_scope);
function.update_scope(parent_scope);
if function.skipped() {
continue;
}

View File

@ -149,7 +149,7 @@ impl Expression<'_> {
impl AsRef<Expr> for Expression<'_> {
#[inline(always)]
fn as_ref(&self) -> &Expr {
&self.0
self.0
}
}
@ -158,7 +158,7 @@ impl Deref for Expression<'_> {
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
self.0
}
}
@ -178,7 +178,7 @@ impl Engine {
///
/// Not available under `no_custom_syntax`.
///
/// * `symbols` holds a slice of strings that define the custom syntax.
/// * `symbols` holds a slice of strings that define the custom syntax.
/// * `scope_may_be_changed` specifies variables _may_ be added/removed by this custom syntax.
/// * `func` is the implementation function.
///

View File

@ -335,7 +335,7 @@ impl Engine {
}
#[cfg(not(feature = "unchecked"))]
self.check_data_size(&r, _pos)?;
self.check_data_size(r, _pos)?;
}
_ => (),
}

View File

@ -190,7 +190,7 @@ impl<'a, 's, 'ps, 'g, 'pg, 'c, 'pc, 't, 'pt> EvalContext<'a, 's, 'ps, 'g, 'pg, '
caches,
self.lib,
self.this_ptr,
&statements,
statements,
rewind_scope,
self.level,
),

View File

@ -161,7 +161,7 @@ impl Engine {
) {
Ok(_) => {
#[cfg(not(feature = "unchecked"))]
self.check_data_size(&args[0], root.1)?;
self.check_data_size(args[0], root.1)?;
}
Err(err) if matches!(*err, ERR::ErrorFunctionNotFound(ref f, ..) if f.starts_with(op_assign)) =>
{
@ -586,7 +586,7 @@ impl Engine {
}
let condition = self
.eval_expr(scope, global, caches, lib, this_ptr, &expr, level)
.eval_expr(scope, global, caches, lib, this_ptr, expr, level)
.and_then(|v| {
v.as_bool().map_err(|typ| {
self.make_type_mismatch_err::<bool>(typ, expr.position())
@ -952,7 +952,7 @@ impl Engine {
}
let path_result = self
.eval_expr(scope, global, caches, lib, this_ptr, &expr, level)
.eval_expr(scope, global, caches, lib, this_ptr, expr, level)
.and_then(|v| {
let typ = v.type_name();
v.try_cast::<crate::ImmutableString>().ok_or_else(|| {

View File

@ -281,7 +281,7 @@ impl Engine {
return args.and_then(|args| {
if !is_op_assignment {
get_builtin_binary_op_fn(fn_name, &args[0], &args[1]).map(|f| {
get_builtin_binary_op_fn(fn_name, args[0], args[1]).map(|f| {
FnResolutionCacheEntry {
func: CallableFunction::from_method(
Box::new(f) as Box<FnAny>
@ -454,7 +454,7 @@ impl Engine {
// Check the data size of any `&mut` object, which may be changed.
#[cfg(not(feature = "unchecked"))]
if is_ref_mut && args.len() > 0 {
self.check_data_size(&args[0], pos)?;
self.check_data_size(args[0], pos)?;
}
// See if the function match print/debug (which requires special processing)
@ -464,7 +464,7 @@ impl Engine {
let t = self.map_type_name(type_name::<ImmutableString>()).into();
ERR::ErrorMismatchOutputType(t, typ.into(), pos)
})?;
((&*self.print)(&text).into(), false)
((*self.print)(&text).into(), false)
}
KEYWORD_DEBUG => {
let text = result.into_immutable_string().map_err(|typ| {
@ -476,7 +476,7 @@ impl Engine {
} else {
Some(global.source.as_str())
};
((&*self.debug)(&text, source, pos).into(), false)
((*self.debug)(&text, source, pos).into(), false)
}
_ => (result, is_method),
});

View File

@ -90,7 +90,7 @@ pub struct FuncInfo {
impl FuncInfo {
/// Format a return type to be display-friendly.
///
/// `()` is cleared.
/// `()` is cleared.
/// [`RhaiResult`][crate::RhaiResult] and [`RhaiResultOf<T>`] are expanded.
#[cfg(feature = "metadata")]
pub fn format_type(typ: &str, is_return_type: bool) -> std::borrow::Cow<str> {
@ -1860,7 +1860,7 @@ impl Module {
let orig_constants = std::mem::take(&mut global.constants);
// Run the script
let result = engine.eval_ast_with_scope_raw(&mut scope, global, &ast, 0);
let result = engine.eval_ast_with_scope_raw(&mut scope, global, ast, 0);
// Create new module
let mut module = Module::new();

View File

@ -151,7 +151,7 @@ impl<'a> OptimizerState<'a> {
&mut self.caches,
lib,
fn_name,
calc_fn_hash(&fn_name, arg_values.len()),
calc_fn_hash(fn_name, arg_values.len()),
&mut arg_values.iter_mut().collect::<StaticVec<_>>(),
false,
false,
@ -1416,7 +1416,7 @@ pub fn optimize_into_ast(
OptimizationLevel::Simple | OptimizationLevel::Full => optimize_top_level(
statements,
engine,
&scope,
scope,
#[cfg(not(feature = "no_function"))]
&[&lib],
optimization_level,

View File

@ -218,7 +218,7 @@ impl<'d, T: Any + Clone> Deref for DynamicReadLock<'d, T> {
#[inline]
fn deref(&self) -> &Self::Target {
match self.0 {
DynamicReadLockInner::Reference(ref reference) => *reference,
DynamicReadLockInner::Reference(reference) => reference,
#[cfg(not(feature = "no_closure"))]
DynamicReadLockInner::Guard(ref guard) => guard.downcast_ref().expect(CHECKED),
}

View File

@ -181,7 +181,7 @@ impl FnPtr {
let mut arg_values = crate::StaticVec::new_const();
args.parse(&mut arg_values);
let result = self.call_raw(&context, None, arg_values)?;
let result = self.call_raw(context, None, arg_values)?;
let typ = context.engine().map_type_name(result.type_name());