Unused parameters naming.

This commit is contained in:
Stephen Chung 2022-04-11 16:29:16 +08:00
parent 1777ee7f6f
commit 63359f3f81
14 changed files with 45 additions and 80 deletions

View File

@ -1,5 +1,5 @@
Rhai - Embedded Scripting for Rust
=================================
==================================
![GitHub last commit](https://img.shields.io/github/last-commit/rhaiscript/rhai?logo=github)
[![Build Status](https://github.com/rhaiscript/rhai/workflows/Build/badge.svg)](https://github.com/rhaiscript/rhai/actions)
@ -66,7 +66,7 @@ Protected against attacks
For those who actually want their own language
---------------------------------------------
----------------------------------------------
* Use as a [DSL](https://rhai.rs/book/engine/dsl.html).
* Disable certain [language features](https://rhai.rs/book/engine/options.html#language-features) such as [looping](https://rhai.rs/book/engine/disable-looping.html).

View File

@ -636,9 +636,7 @@ impl Expr {
/// `non_qualified` is ignored under `no_module`.
#[inline]
#[must_use]
pub(crate) fn is_variable_access(&self, non_qualified: bool) -> bool {
let _non_qualified = non_qualified;
pub(crate) fn is_variable_access(&self, _non_qualified: bool) -> bool {
match self {
#[cfg(not(feature = "no_module"))]
Self::Variable(x, ..) if _non_qualified && !x.1.is_empty() => false,
@ -651,9 +649,7 @@ impl Expr {
/// `non_qualified` is ignored under `no_module`.
#[inline]
#[must_use]
pub(crate) fn get_variable_name(&self, non_qualified: bool) -> Option<&str> {
let _non_qualified = non_qualified;
pub(crate) fn get_variable_name(&self, _non_qualified: bool) -> Option<&str> {
match self {
#[cfg(not(feature = "no_module"))]
Self::Variable(x, ..) if _non_qualified && !x.1.is_empty() => None,

View File

@ -321,7 +321,7 @@ fn debug_callback(
let mut input = String::new();
loop {
print!("rhai-dbg> ");
print!("dbg> ");
stdout().flush().expect("couldn't flush stdout");

View File

@ -295,9 +295,7 @@ impl Engine {
}
/// Check a result to ensure that it is valid.
pub(crate) fn check_return_value(&self, mut result: RhaiResult, pos: Position) -> RhaiResult {
let _pos = pos;
pub(crate) fn check_return_value(&self, mut result: RhaiResult, _pos: Position) -> RhaiResult {
match result {
Ok(ref mut r) => {
// Concentrate all empty strings into one instance to save memory

View File

@ -127,16 +127,14 @@ impl Engine {
this_ptr: &mut Option<&mut Dynamic>,
target: &mut Target,
root: (&str, Position),
parent: &Expr,
_parent: &Expr,
rhs: &Expr,
parent_options: ASTFlags,
_parent_options: ASTFlags,
idx_values: &mut StaticVec<super::ChainArgument>,
chain_type: ChainType,
level: usize,
new_val: Option<((Dynamic, Position), (Option<OpAssignment>, Position))>,
) -> RhaiResultOf<(Dynamic, bool)> {
let _parent = parent;
let _parent_options = parent_options;
let is_ref_mut = target.is_ref();
// Pop the last index value
@ -671,7 +669,7 @@ impl Engine {
this_ptr: &mut Option<&mut Dynamic>,
expr: &Expr,
parent_options: ASTFlags,
parent_chain_type: ChainType,
_parent_chain_type: ChainType,
idx_values: &mut StaticVec<super::ChainArgument>,
size: usize,
level: usize,
@ -679,8 +677,6 @@ impl Engine {
#[cfg(not(feature = "unchecked"))]
self.inc_operations(&mut global.num_operations, expr.position())?;
let _parent_chain_type = parent_chain_type;
match expr {
#[cfg(not(feature = "no_object"))]
Expr::MethodCall(x, ..)
@ -850,18 +846,15 @@ impl Engine {
state: &mut EvalState,
lib: &[&Module],
target: &'t mut Dynamic,
idx: Dynamic,
mut idx: Dynamic,
idx_pos: Position,
add_if_not_found: bool,
_add_if_not_found: bool,
use_indexers: bool,
level: usize,
) -> RhaiResultOf<Target<'t>> {
#[cfg(not(feature = "unchecked"))]
self.inc_operations(&mut global.num_operations, Position::NONE)?;
let mut idx = idx;
let _add_if_not_found = add_if_not_found;
match target {
#[cfg(not(feature = "no_index"))]
Dynamic(Union::Array(arr, ..)) => {

View File

@ -16,9 +16,7 @@ impl Engine {
///
/// Panics if any interior data is shared (should never happen).
#[cfg(not(feature = "unchecked"))]
pub(crate) fn calc_data_sizes(value: &Dynamic, top: bool) -> (usize, usize, usize) {
let _top = top;
pub(crate) fn calc_data_sizes(value: &Dynamic, _top: bool) -> (usize, usize, usize) {
match value.0 {
#[cfg(not(feature = "no_index"))]
Union::Array(ref arr, ..) => {

View File

@ -195,7 +195,7 @@ impl Engine {
#[must_use]
fn resolve_fn<'s>(
&self,
global: &GlobalRuntimeState,
_global: &GlobalRuntimeState,
state: &'s mut EvalState,
lib: &[&Module],
fn_name: &str,
@ -204,8 +204,6 @@ impl Engine {
allow_dynamic: bool,
is_op_assignment: bool,
) -> Option<&'s FnResolutionCacheEntry> {
let _global = global;
if hash_script == 0 {
return None;
}
@ -576,7 +574,7 @@ impl Engine {
/// all others are silently replaced by `()`!
pub(crate) fn exec_fn_call(
&self,
scope: Option<&mut Scope>,
_scope: Option<&mut Scope>,
global: &mut GlobalRuntimeState,
state: &mut EvalState,
lib: &[&Module],
@ -584,7 +582,7 @@ impl Engine {
hashes: FnCallHashes,
args: &mut FnCallArgs,
is_ref_mut: bool,
is_method_call: bool,
_is_method_call: bool,
pos: Position,
level: usize,
) -> RhaiResultOf<(Dynamic, bool)> {
@ -600,9 +598,6 @@ impl Engine {
#[cfg(not(feature = "no_closure"))]
ensure_no_data_race(fn_name, args, is_ref_mut)?;
let _scope = scope;
let _is_method_call = is_method_call;
// These may be redirected from method style calls.
match fn_name {
// Handle type_of()
@ -1418,11 +1413,9 @@ impl Engine {
state: &mut EvalState,
lib: &[&Module],
script: &str,
pos: Position,
_pos: Position,
level: usize,
) -> RhaiResult {
let _pos = pos;
#[cfg(not(feature = "unchecked"))]
self.inc_operations(&mut global.num_operations, _pos)?;

View File

@ -38,13 +38,11 @@ impl Engine {
#[inline(never)]
fn make_error(
name: String,
fn_def: &ScriptFnDef,
_fn_def: &ScriptFnDef,
global: &GlobalRuntimeState,
err: RhaiError,
pos: Position,
) -> RhaiResult {
let _fn_def = fn_def;
#[cfg(not(feature = "no_module"))]
let source = _fn_def
.environ
@ -232,13 +230,11 @@ impl Engine {
#[must_use]
pub(crate) fn has_script_fn(
&self,
global: Option<&GlobalRuntimeState>,
_global: Option<&GlobalRuntimeState>,
state: &mut EvalState,
lib: &[&Module],
hash_script: u64,
) -> bool {
let _global = global;
let cache = state.fn_resolution_cache_mut();
if let Some(result) = cache.get(&hash_script).map(|v| v.is_some()) {

View File

@ -863,7 +863,7 @@ fn optimize_stmt(stmt: &mut Stmt, state: &mut OptimizerState, preserve_result: b
}
/// Optimize an [expression][Expr].
fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, chaining: bool) {
fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, _chaining: bool) {
// These keywords are handled specially
const DONT_EVAL_KEYWORDS: &[&str] = &[
KEYWORD_PRINT, // side effects
@ -871,8 +871,6 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, chaining: bool) {
KEYWORD_EVAL, // arbitrary scripts
];
let _chaining = chaining;
match expr {
// {}
Expr::Stmt(x) if x.is_empty() => { state.set_dirty(); *expr = Expr::Unit(x.position()) }

View File

@ -795,13 +795,13 @@ mod range_functions {
/// Return `true` if the range is inclusive.
#[rhai_fn(get = "is_inclusive", name = "is_inclusive", pure)]
pub fn is_inclusive(range: &mut ExclusiveRange) -> bool {
let _range = range;
let _ = range;
false
}
/// Return `true` if the range is exclusive.
#[rhai_fn(get = "is_exclusive", name = "is_exclusive", pure)]
pub fn is_exclusive(range: &mut ExclusiveRange) -> bool {
let _range = range;
let _ = range;
true
}
/// Return the start of the inclusive range.
@ -817,13 +817,13 @@ mod range_functions {
/// Return `true` if the range is inclusive.
#[rhai_fn(get = "is_inclusive", name = "is_inclusive", pure)]
pub fn is_inclusive_inclusive(range: &mut InclusiveRange) -> bool {
let _range = range;
let _ = range;
true
}
/// Return `true` if the range is exclusive.
#[rhai_fn(get = "is_exclusive", name = "is_exclusive", pure)]
pub fn is_exclusive_inclusive(range: &mut InclusiveRange) -> bool {
let _range = range;
let _ = range;
false
}
}

View File

@ -76,7 +76,7 @@ mod string_functions {
#[rhai_fn(name = "+")]
pub fn add_append_unit(string: ImmutableString, item: ()) -> ImmutableString {
let _item = item;
let _ = item;
string
}
#[rhai_fn(name = "+")]

View File

@ -3504,11 +3504,9 @@ impl Engine {
&self,
input: &mut TokenStream,
state: &mut ParseState,
scope: &Scope,
optimization_level: OptimizationLevel,
_scope: &Scope,
_optimization_level: OptimizationLevel,
) -> ParseResult<AST> {
let _scope = scope;
let _optimization_level = optimization_level;
let mut functions = BTreeMap::new();
let settings = ParseSettings {
@ -3552,7 +3550,7 @@ impl Engine {
statements,
#[cfg(not(feature = "no_function"))]
StaticVec::new_const(),
optimization_level,
_optimization_level,
));
#[cfg(feature = "no_optimize")]
@ -3630,12 +3628,9 @@ impl Engine {
&self,
input: &mut TokenStream,
state: &mut ParseState,
scope: &Scope,
optimization_level: OptimizationLevel,
_scope: &Scope,
_optimization_level: OptimizationLevel,
) -> ParseResult<AST> {
let _scope = scope;
let _optimization_level = optimization_level;
let (statements, _lib) = self.parse_global_level(input, state)?;
#[cfg(not(feature = "no_optimize"))]
@ -3645,7 +3640,7 @@ impl Engine {
statements,
#[cfg(not(feature = "no_function"))]
_lib,
optimization_level,
_optimization_level,
));
#[cfg(feature = "no_optimize")]

View File

@ -417,9 +417,9 @@ impl SerializeSeq for DynamicSerializer {
fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> RhaiResultOf<()> {
#[cfg(not(feature = "no_index"))]
{
let _value = _value.serialize(&mut *self)?;
let value = _value.serialize(&mut *self)?;
let arr = self._value.downcast_mut::<crate::Array>().unwrap();
arr.push(_value);
arr.push(value);
Ok(())
}
#[cfg(feature = "no_index")]
@ -452,9 +452,9 @@ impl SerializeTuple for DynamicSerializer {
fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> RhaiResultOf<()> {
#[cfg(not(feature = "no_index"))]
{
let _value = _value.serialize(&mut *self)?;
let value = _value.serialize(&mut *self)?;
let arr = self._value.downcast_mut::<crate::Array>().unwrap();
arr.push(_value);
arr.push(value);
Ok(())
}
#[cfg(feature = "no_index")]
@ -486,9 +486,9 @@ impl SerializeTupleStruct for DynamicSerializer {
fn serialize_field<T: ?Sized + Serialize>(&mut self, _value: &T) -> RhaiResultOf<()> {
#[cfg(not(feature = "no_index"))]
{
let _value = _value.serialize(&mut *self)?;
let value = _value.serialize(&mut *self)?;
let arr = self._value.downcast_mut::<crate::Array>().unwrap();
arr.push(_value);
arr.push(value);
Ok(())
}
#[cfg(feature = "no_index")]
@ -540,9 +540,9 @@ impl SerializeMap for DynamicSerializer {
.map_err(|typ| {
ERR::ErrorMismatchDataType("string".into(), typ.into(), Position::NONE)
})?;
let _value = _value.serialize(&mut *self)?;
let value = _value.serialize(&mut *self)?;
let map = self._value.downcast_mut::<crate::Map>().unwrap();
map.insert(key.into(), _value);
map.insert(key.into(), value);
Ok(())
}
#[cfg(feature = "no_object")]
@ -561,13 +561,13 @@ impl SerializeMap for DynamicSerializer {
) -> RhaiResultOf<()> {
#[cfg(not(feature = "no_object"))]
{
let _key: Dynamic = _key.serialize(&mut *self)?;
let _key = _key.into_immutable_string().map_err(|typ| {
let key: Dynamic = _key.serialize(&mut *self)?;
let key = key.into_immutable_string().map_err(|typ| {
ERR::ErrorMismatchDataType("string".into(), typ.into(), Position::NONE)
})?;
let _value = _value.serialize(&mut *self)?;
let value = _value.serialize(&mut *self)?;
let map = self._value.downcast_mut::<crate::Map>().unwrap();
map.insert(_key.into(), _value);
map.insert(key.into(), value);
Ok(())
}
#[cfg(feature = "no_object")]
@ -603,9 +603,9 @@ impl SerializeStruct for DynamicSerializer {
) -> RhaiResultOf<()> {
#[cfg(not(feature = "no_object"))]
{
let _value = _value.serialize(&mut *self)?;
let value = _value.serialize(&mut *self)?;
let map = self._value.downcast_mut::<crate::Map>().unwrap();
map.insert(_key.into(), _value);
map.insert(_key.into(), value);
Ok(())
}
#[cfg(feature = "no_object")]

View File

@ -469,9 +469,7 @@ impl Hash for Dynamic {
#[cfg(feature = "sync")]
Union::Shared(ref cell, ..) => (*cell.read().unwrap()).hash(state),
Union::Variant(ref v, ..) => {
let _v = v;
Union::Variant(ref _v, ..) => {
#[cfg(not(feature = "only_i32"))]
#[cfg(not(feature = "only_i64"))]
{