diff --git a/move-compiler/src/cfgir/translate.rs b/move-compiler/src/cfgir/translate.rs index 05924855f7..80ff4c9898 100644 --- a/move-compiler/src/cfgir/translate.rs +++ b/move-compiler/src/cfgir/translate.rs @@ -754,8 +754,14 @@ fn visit_function( acquires, body, } = fdef; - let G::FunctionBody_::Defined { locals, start, blocks, block_info } = &body.value else { - return + let G::FunctionBody_::Defined { + locals, + start, + blocks, + block_info, + } = &body.value + else { + return; }; context.env.add_warning_filter_scope(warning_filter.clone()); let (cfg, infinite_loop_starts) = ImmForwardCFG::new(*start, blocks, block_info.iter()); diff --git a/move-compiler/src/expansion/primitive_definers.rs b/move-compiler/src/expansion/primitive_definers.rs index 2378817b39..d5eed3097f 100644 --- a/move-compiler/src/expansion/primitive_definers.rs +++ b/move-compiler/src/expansion/primitive_definers.rs @@ -60,14 +60,16 @@ fn check_prim_definer( .get_(&AttributeName_::Known(KnownAttribute::DefinesPrimitive( DefinesPrimitive, ))); - let Some(sp!(attr_loc, attr_)) = defines_prim_attr else { return }; - let Attribute_::Parameterized(_, params) = attr_ else { + let Some(sp!(attr_loc, attr_)) = defines_prim_attr else { + return; + }; + let Attribute_::Parameterized(_, params) = attr_ else { let msg = format!( "Expected a primitive type parameterization, e.g. '{}()'", DefinesPrimitive::DEFINES_PRIM ); env.add_diag(diag!(Attributes::InvalidUsage, (*attr_loc, msg))); - return + return; }; if params.len() != 1 { let msg = format!( @@ -84,7 +86,7 @@ fn check_prim_definer( DefinesPrimitive::DEFINES_PRIM ); env.add_diag(diag!(Attributes::InvalidUsage, (*param_loc, msg))); - return + return; }; let Some(prim) = BuiltinTypeName_::resolve(name.value.as_str()) else { let msg = format!( @@ -93,7 +95,7 @@ fn check_prim_definer( name, ); env.add_diag(diag!(Attributes::InvalidUsage, (name.loc, msg))); - return + return; }; if let Some(prev) = definers.get(&prim) { diff --git a/move-compiler/src/expansion/translate.rs b/move-compiler/src/expansion/translate.rs index 61cafd0fdc..db8e633ab4 100644 --- a/move-compiler/src/expansion/translate.rs +++ b/move-compiler/src/expansion/translate.rs @@ -504,7 +504,6 @@ fn module_( .add_diag(diag!(Declarations::InvalidName, (name.loc(), msg))); } - let name = name; let name_loc = name.0.loc; let current_module = sp(name_loc, ModuleIdent_::new(*context.cur_address(), name)); diff --git a/move-compiler/src/hlir/translate.rs b/move-compiler/src/hlir/translate.rs index d0ba7d4384..a77c8fc7e5 100644 --- a/move-compiler/src/hlir/translate.rs +++ b/move-compiler/src/hlir/translate.rs @@ -1510,7 +1510,7 @@ fn struct_name(sp!(_, t): &H::Type) -> Option { H::SingleType_::Base(bt) => bt, H::SingleType_::Ref(_, bt) => bt, }; - let H::BaseType_::Apply(_, tname ,_ ) = &bt.value else { + let H::BaseType_::Apply(_, tname, _) = &bt.value else { return None; }; if let H::TypeName_::ModuleType(_, struct_name) = tname.value { diff --git a/move-compiler/src/naming/resolve_use_funs.rs b/move-compiler/src/naming/resolve_use_funs.rs index 82a0f15387..cbf8dbecb9 100644 --- a/move-compiler/src/naming/resolve_use_funs.rs +++ b/move-compiler/src/naming/resolve_use_funs.rs @@ -195,13 +195,12 @@ fn use_funs(context: &mut Context, uf: &mut N::UseFuns) { function: (target_m, target_f), kind: ekind, } = implicit; - let Some((target_f,tn)) = is_valid_method(context, &target_m, target_f) else { + let Some((target_f, tn)) = is_valid_method(context, &target_m, target_f) else { if matches!(ekind, E::ImplicitUseFunKind::UseAlias { used: false }) { let msg = format!("Unused 'use' of alias '{}'. Consider removing it", method); - context.env.add_diag(diag!( - UnusedItem::Alias, - (method.loc, msg), - )) + context + .env + .add_diag(diag!(UnusedItem::Alias, (method.loc, msg),)) } continue; }; diff --git a/move-compiler/src/naming/translate.rs b/move-compiler/src/naming/translate.rs index 12389e3011..035cbbe330 100644 --- a/move-compiler/src/naming/translate.rs +++ b/move-compiler/src/naming/translate.rs @@ -274,8 +274,7 @@ impl<'env> Context<'env> { match ma_ { EN::Name(n) => self.resolve_unscoped_type(nloc, n), EN::ModuleAccess(m, n) => { - let Some(module_type) = self.resolve_module_type(nloc, &m, &n) - else { + let Some(module_type) = self.resolve_module_type(nloc, &m, &n) else { assert!(self.env.has_errors()); return ResolvedType::Unbound; }; diff --git a/move-compiler/src/parser/merge_spec_modules.rs b/move-compiler/src/parser/merge_spec_modules.rs index abdb0e283b..7aced3103d 100644 --- a/move-compiler/src/parser/merge_spec_modules.rs +++ b/move-compiler/src/parser/merge_spec_modules.rs @@ -154,8 +154,8 @@ fn merge_spec_module( is_spec_module, } = spec_module; assert!(is_spec_module); - m.attributes.extend(attributes.into_iter()); - m.members.extend(members.into_iter()); + m.attributes.extend(attributes); + m.members.extend(members); } } diff --git a/move-compiler/src/parser/syntax.rs b/move-compiler/src/parser/syntax.rs index 0c63ec1861..47e63e21af 100644 --- a/move-compiler/src/parser/syntax.rs +++ b/move-compiler/src/parser/syntax.rs @@ -286,6 +286,7 @@ where // Parse an identifier: // Identifier = +#[allow(clippy::needless_if)] fn parse_identifier(context: &mut Context) -> Result> { if matches!( context.tokens.peek(), diff --git a/move-compiler/src/sui_mode/id_leak.rs b/move-compiler/src/sui_mode/id_leak.rs index 2b6db266f6..fa4947fc73 100644 --- a/move-compiler/src/sui_mode/id_leak.rs +++ b/move-compiler/src/sui_mode/id_leak.rs @@ -89,7 +89,7 @@ impl SimpleAbsIntConstructor for IDLeakVerifier { _init_state: &mut as SimpleAbsInt>::State, ) -> Option> { let Some(module) = &context.module else { - return None + return None; }; let package_name = program.modules.get(module).unwrap().package_name; let config = env.package_config(package_name); diff --git a/move-compiler/src/sui_mode/typing.rs b/move-compiler/src/sui_mode/typing.rs index d9e032a2e3..c5d9b49a47 100644 --- a/move-compiler/src/sui_mode/typing.rs +++ b/move-compiler/src/sui_mode/typing.rs @@ -208,7 +208,9 @@ fn struct_def(context: &mut Context, name: StructName, sdef: &N::StructDefinitio return; }; - let StructFields::Defined(fields) = fields else { return }; + let StructFields::Defined(fields) = fields else { + return; + }; let invalid_first_field = if fields.is_empty() { // no fields Some(name.loc()) @@ -586,10 +588,10 @@ fn entry_signature( fn tx_context_kind(sp!(_, last_param_ty_): &Type) -> TxContextKind { let Type_::Ref(is_mut, inner_ty) = last_param_ty_ else { - return TxContextKind::None + return TxContextKind::None; }; let Type_::Apply(_, sp!(_, inner_name), _) = &inner_ty.value else { - return TxContextKind::None + return TxContextKind::None; }; if inner_name.is(SUI_ADDR_NAME, TX_CONTEXT_MODULE_NAME, TX_CONTEXT_TYPE_NAME) { if *is_mut { diff --git a/move-core/types/src/gas_algebra.rs b/move-core/types/src/gas_algebra.rs index c50a9489c4..bcb62acb86 100644 --- a/move-core/types/src/gas_algebra.rs +++ b/move-core/types/src/gas_algebra.rs @@ -132,6 +132,7 @@ impl From> for u64 { * Clone & Copy * **************************************************************************************************/ +#[allow(clippy::incorrect_clone_impl_on_copy_type)] impl Clone for GasQuantity { fn clone(&self) -> Self { Self::new(self.val) diff --git a/move-ir-compiler/move-ir-to-bytecode/src/context.rs b/move-ir-compiler/move-ir-to-bytecode/src/context.rs index 8afc1aebf0..8aa51badae 100644 --- a/move-ir-compiler/move-ir-to-bytecode/src/context.rs +++ b/move-ir-compiler/move-ir-to-bytecode/src/context.rs @@ -346,7 +346,7 @@ impl<'a> Context<'a> { } fn materialize_map(m: HashMap) -> Vec { - Self::materialize_pool(m.len(), m.into_iter()) + Self::materialize_pool(m.len(), m) } /// Finish compilation, and materialize the pools for file format. diff --git a/move-ir-compiler/move-ir-to-bytecode/syntax/src/syntax.rs b/move-ir-compiler/move-ir-to-bytecode/syntax/src/syntax.rs index 1054ca4048..42bb47ec1d 100644 --- a/move-ir-compiler/move-ir-to-bytecode/syntax/src/syntax.rs +++ b/move-ir-compiler/move-ir-to-bytecode/syntax/src/syntax.rs @@ -1481,7 +1481,7 @@ fn parse_acquire_list( Ok(al) } -//// Spec language parsing //// +/// Spec language parsing /// // parses Name '.' Name and returns pair of strings. fn spec_parse_dot_name( diff --git a/move-model/src/builder/exp_translator.rs b/move-model/src/builder/exp_translator.rs index 8d7a626401..86dbb17d4f 100644 --- a/move-model/src/builder/exp_translator.rs +++ b/move-model/src/builder/exp_translator.rs @@ -1650,7 +1650,7 @@ impl<'env, 'translator, 'module_translator> ExpTranslator<'env, 'translator, 'mo let expected_user_count = param_count - args.len(); if let Some(types) = user_args { let n = types.len(); - args.extend(types.into_iter()); + args.extend(types); if n != expected_user_count { ( args, diff --git a/move-prover/boogie-backend/src/lib.rs b/move-prover/boogie-backend/src/lib.rs index a255739ce4..cd10d7b530 100644 --- a/move-prover/boogie-backend/src/lib.rs +++ b/move-prover/boogie-backend/src/lib.rs @@ -188,7 +188,7 @@ pub fn add_prelude( .vec_inst .iter() .map(|ty| TypeInfo::new(env, options, ty, false)) - .chain(implicit_vec_inst.into_iter()) + .chain(implicit_vec_inst) .collect::>() .into_iter() .collect_vec(); diff --git a/move-prover/bytecode/src/dataflow_domains.rs b/move-prover/bytecode/src/dataflow_domains.rs index f0c48dff45..337c272ac0 100644 --- a/move-prover/bytecode/src/dataflow_domains.rs +++ b/move-prover/bytecode/src/dataflow_domains.rs @@ -282,6 +282,6 @@ impl MapDomain { } }) .collect_vec(); - self.extend(new_values.into_iter()); + self.extend(new_values); } } diff --git a/move-prover/bytecode/src/verification_analysis.rs b/move-prover/bytecode/src/verification_analysis.rs index c67a486c91..57a601334b 100644 --- a/move-prover/bytecode/src/verification_analysis.rs +++ b/move-prover/bytecode/src/verification_analysis.rs @@ -371,7 +371,7 @@ impl VerificationAnalysisProcessor { targets: &mut FunctionTargetsHolder, ) { // TODO(mengxu): re-check the treatment of fixedpoint here - let mut info = data + let info = data .annotations .get_or_default_mut::(true); if !info.verified { diff --git a/move-prover/bytecode/src/verification_analysis_v2.rs b/move-prover/bytecode/src/verification_analysis_v2.rs index 33fa359afc..b30980f736 100644 --- a/move-prover/bytecode/src/verification_analysis_v2.rs +++ b/move-prover/bytecode/src/verification_analysis_v2.rs @@ -738,7 +738,7 @@ fn mark_verified( // The user can override with `pragma verify = false`, so respect this. let options = ProverOptions::get(fun_env.module_env.env); if !actual_env.is_explicitly_not_verified(&options.verify_scope) { - let mut info = targets + let info = targets .get_data_mut(&actual_env.get_qualified_id(), &variant) .expect("function data available") .annotations diff --git a/move-prover/interpreter/src/concrete/evaluator.rs b/move-prover/interpreter/src/concrete/evaluator.rs index 5af3a63632..bee5a27643 100644 --- a/move-prover/interpreter/src/concrete/evaluator.rs +++ b/move-prover/interpreter/src/concrete/evaluator.rs @@ -738,7 +738,7 @@ impl<'env> Evaluator<'env> { let choose_val_range_vec = choose_val_range.unwrap(); let mut v_results: Vec<_> = choose_val_range_vec .into_iter() - .zip(loop_results.into_iter()) + .zip(loop_results) .filter_map(|(val, r)| if r.into_bool() { Some(val) } else { None }) .collect(); @@ -754,7 +754,7 @@ impl<'env> Evaluator<'env> { let choose_val_range_vec = choose_val_range.unwrap(); let mut v_results: Vec<_> = choose_val_range_vec .into_iter() - .zip(loop_results.into_iter()) + .zip(loop_results) .filter_map(|(val, r)| if r.into_bool() { Some(val) } else { None }) .collect(); @@ -912,7 +912,7 @@ impl<'env> Evaluator<'env> { let typed_args = decl .params .iter() - .zip(arg_vals.into_iter()) + .zip(arg_vals) .map(|((_, arg_ty), arg_val)| { let converted = convert_model_base_type(env, arg_ty, &ty_args); TypedValue::fuse_base(converted, arg_val) diff --git a/move-vm/runtime/src/interpreter.rs b/move-vm/runtime/src/interpreter.rs index dc556173d5..b4d5bc8051 100644 --- a/move-vm/runtime/src/interpreter.rs +++ b/move-vm/runtime/src/interpreter.rs @@ -2437,7 +2437,8 @@ impl Frame { .loader() .vm_config() .runtime_limits_config - .max_value_nest_depth else { + .max_value_nest_depth + else { return Ok(1); }; Self::check_depth_of_type_impl(resolver, ty, 0, max_depth) diff --git a/move-vm/types/src/loaded_data/runtime_types.rs b/move-vm/types/src/loaded_data/runtime_types.rs index 7a694cf2d0..4cd185c7b4 100644 --- a/move-vm/types/src/loaded_data/runtime_types.rs +++ b/move-vm/types/src/loaded_data/runtime_types.rs @@ -84,7 +84,10 @@ impl DepthFormula { } for (t_i, c_i) in terms { let Some(mut u_form) = map.remove(t_i) else { - return Err(PartialVMError::new(StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR).with_message(format!("{t_i:?} missing mapping"))) + return Err( + PartialVMError::new(StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR) + .with_message(format!("{t_i:?} missing mapping")), + ); }; u_form.add(*c_i); formulas.push(u_form) diff --git a/tools/move-bytecode-viewer/src/tui/text_builder.rs b/tools/move-bytecode-viewer/src/tui/text_builder.rs index d6feeacfa4..03943066f6 100644 --- a/tools/move-bytecode-viewer/src/tui/text_builder.rs +++ b/tools/move-bytecode-viewer/src/tui/text_builder.rs @@ -56,7 +56,7 @@ impl<'a> TextBuilder<'a> { .push(Span::styled(line_continuation.to_string(), style)); }); iter.next().into_iter().for_each(|remainder| { - self.chunks.extend(chunk(remainder.to_string()).into_iter()); + self.chunks.extend(chunk(remainder.to_string())); }); } else { self.chunks.extend(chunk(text)) diff --git a/tools/move-cli/src/base/test.rs b/tools/move-cli/src/base/test.rs index d717de2059..8130e94bff 100644 --- a/tools/move-cli/src/base/test.rs +++ b/tools/move-cli/src/base/test.rs @@ -27,7 +27,7 @@ use std::{ #[cfg(target_family = "windows")] use std::os::windows::process::ExitStatusExt; // if unix -#[cfg(any(target_family = "unix"))] +#[cfg(target_family = "unix")] use std::os::unix::prelude::ExitStatusExt; // if not windows nor unix #[cfg(not(any(target_family = "windows", target_family = "unix")))] diff --git a/tools/move-cli/src/sandbox/utils/mod.rs b/tools/move-cli/src/sandbox/utils/mod.rs index 7cfd995611..40c73d4551 100644 --- a/tools/move-cli/src/sandbox/utils/mod.rs +++ b/tools/move-cli/src/sandbox/utils/mod.rs @@ -1,7 +1,7 @@ // Copyright (c) The Diem Core Contributors // Copyright (c) The Move Contributors // SPDX-License-Identifier: Apache-2.0 - +#[allow(hidden_glob_reexports)] use crate::sandbox::utils::on_disk_state_view::OnDiskStateView; use anyhow::{bail, Result}; use colored::Colorize; diff --git a/tools/move-disassembler/src/disassembler.rs b/tools/move-disassembler/src/disassembler.rs index 2f96d4fb88..8b32ca58a1 100644 --- a/tools/move-disassembler/src/disassembler.rs +++ b/tools/move-disassembler/src/disassembler.rs @@ -454,7 +454,7 @@ impl<'a> Disassembler<'a> { .into_iter() .enumerate() .map(|(local_idx, local)| format!("L{}:\t{}", local_idx, local)) - .chain(bytecode.into_iter()) + .chain(bytecode) .collect(); format!(" {{\n{}\n}}", body_iter.join("\n")) } diff --git a/tools/move-package/src/compilation/model_builder.rs b/tools/move-package/src/compilation/model_builder.rs index 6050ad2788..0c9588ccc0 100644 --- a/tools/move-package/src/compilation/model_builder.rs +++ b/tools/move-package/src/compilation/model_builder.rs @@ -74,7 +74,7 @@ impl ModelBuilder { )?; let (all_targets, all_deps) = if self.model_config.all_files_as_targets { let mut targets = vec![target]; - targets.extend(deps.into_iter()); + targets.extend(deps); (targets, vec![]) } else { (vec![target], deps) diff --git a/tools/move-package/src/resolution/dependency_graph.rs b/tools/move-package/src/resolution/dependency_graph.rs index db72681caf..2a6e2badd8 100644 --- a/tools/move-package/src/resolution/dependency_graph.rs +++ b/tools/move-package/src/resolution/dependency_graph.rs @@ -619,9 +619,8 @@ impl DependencyGraph { continue; }; // graph g has a package with name pkg_name - let Some(( existing_graph, existing_pkg, existing_is_external)) = - existing_pkg_info else - { + let Some((existing_graph, existing_pkg, existing_is_external)) = existing_pkg_info + else { // first time this package was encountered existing_pkg_info = Some((&graph_info.g, pkg, graph_info.is_external)); continue; @@ -1234,7 +1233,7 @@ impl DependencyGraph { .filter(|scc| scc.len() != 1 || self.package_graph.contains_edge(scc[0], scc[0])); let Some(scc) = cyclic_components.next() else { - return Ok(()) + return Ok(()); }; // Duplicate start of the node at end for display @@ -1395,7 +1394,7 @@ impl<'a> fmt::Display for SubstTOML<'a> { let mut substs = self.0.iter(); let Some((addr, subst)) = substs.next() else { - return f.write_str("{}") + return f.write_str("{}"); }; f.write_str("{ ")?; diff --git a/tools/move-package/tests/test_dependency_graph.rs b/tools/move-package/tests/test_dependency_graph.rs index 4508e4285d..f17f4ed772 100644 --- a/tools/move-package/tests/test_dependency_graph.rs +++ b/tools/move-package/tests/test_dependency_graph.rs @@ -129,7 +129,7 @@ fn lock_file_missing_dependency() { pkg, Symbol::from("Root"), &mut File::open(&commit).expect("Opening empty lock file"), - None + None, ) else { panic!("Expected reading dependencies to fail."); }; @@ -330,7 +330,7 @@ fn merge_detached() { dep_graphs, &DependencyKind::default(), &BTreeMap::new(), - &BTreeMap::new() + &BTreeMap::new(), ) else { panic!("Inner's root is not part of outer's graph, so this should fail"); }; @@ -365,7 +365,7 @@ fn merge_after_calculating_always_deps() { dep_graphs, &DependencyKind::default(), &BTreeMap::new(), - &BTreeMap::new() + &BTreeMap::new(), ) else { panic!("Outer's always deps have already been calculated so this should fail"); }; @@ -515,7 +515,7 @@ fn merge_overlapping_different_deps() { dep_graphs, &DependencyKind::default(), dependencies, - &BTreeMap::new() + &BTreeMap::new(), ) else { panic!("Outer and inner mention package A which has different dependencies in both."); }; diff --git a/tools/move-package/tests/test_runner.rs b/tools/move-package/tests/test_runner.rs index 3a361dc6da..db3c30f511 100644 --- a/tools/move-package/tests/test_runner.rs +++ b/tools/move-package/tests/test_runner.rs @@ -110,7 +110,10 @@ impl Test<'_> { fn output(&self) -> anyhow::Result { let Some(ext) = self.expected.extension().and_then(OsStr::to_str) else { - bail!("Unexpected snapshot file extension: {:?}", self.expected.extension()); + bail!( + "Unexpected snapshot file extension: {:?}", + self.expected.extension() + ); }; let out_path = self.output_dir.path().to_path_buf(); diff --git a/tools/move-resource-viewer/src/lib.rs b/tools/move-resource-viewer/src/lib.rs index 75039344c6..dd312469ea 100644 --- a/tools/move-resource-viewer/src/lib.rs +++ b/tools/move-resource-viewer/src/lib.rs @@ -171,7 +171,7 @@ impl<'a, T: MoveResolver + ?Sized> MoveValueAnnotator<'a, T> { .cache .get_field_names(&ty)? .into_iter() - .zip(runtime.into_iter()) + .zip(runtime) .collect(), MoveStruct::WithFields(fields) | MoveStruct::WithTypes { fields, .. } => fields, }) @@ -204,10 +204,7 @@ impl<'a, T: MoveResolver + ?Sized> MoveValueAnnotator<'a, T> { Ok(AnnotatedMoveStruct { abilities: ty.abilities.0, type_: struct_tag, - value: field_names - .into_iter() - .zip(annotated_fields.into_iter()) - .collect(), + value: field_names.into_iter().zip(annotated_fields).collect(), }) } diff --git a/tools/move-unit-test/src/lib.rs b/tools/move-unit-test/src/lib.rs index a308104081..2b3bfbb622 100644 --- a/tools/move-unit-test/src/lib.rs +++ b/tools/move-unit-test/src/lib.rs @@ -198,8 +198,8 @@ impl UnitTestingConfig { } = self.compile_to_test_plan(deps.clone(), vec![])?; let mut test_plan = self.compile_to_test_plan(self.source_files.clone(), deps)?; - test_plan.module_info.extend(module_info.into_iter()); - test_plan.files.extend(files.into_iter()); + test_plan.module_info.extend(module_info); + test_plan.files.extend(files); Some(test_plan) }