Skip to content

Commit

Permalink
chore: upgrade rust to 1.73.0 (#14167)
Browse files Browse the repository at this point in the history
## Description 

Main motivation is to pick up some new changes such as
rust-lang/rust#115659
Most changes here are autogenerated by the new formatter
NFC

## Test Plan 

Existing

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
oxade authored Oct 12, 2023
1 parent 843bb2d commit 449e444
Show file tree
Hide file tree
Showing 31 changed files with 68 additions and 56 deletions.
10 changes: 8 additions & 2 deletions move-compiler/src/cfgir/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
12 changes: 7 additions & 5 deletions move-compiler/src/expansion/primitive_definers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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. '{}(<type>)'",
DefinesPrimitive::DEFINES_PRIM
);
env.add_diag(diag!(Attributes::InvalidUsage, (*attr_loc, msg)));
return
return;
};
if params.len() != 1 {
let msg = format!(
Expand All @@ -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!(
Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion move-compiler/src/expansion/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion move-compiler/src/hlir/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,7 @@ fn struct_name(sp!(_, t): &H::Type) -> Option<StructName> {
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 {
Expand Down
9 changes: 4 additions & 5 deletions move-compiler/src/naming/resolve_use_funs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
3 changes: 1 addition & 2 deletions move-compiler/src/naming/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions move-compiler/src/parser/merge_spec_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
1 change: 1 addition & 0 deletions move-compiler/src/parser/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ where

// Parse an identifier:
// Identifier = <IdentifierValue>
#[allow(clippy::needless_if)]
fn parse_identifier(context: &mut Context) -> Result<Name, Box<Diagnostic>> {
if matches!(
context.tokens.peek(),
Expand Down
2 changes: 1 addition & 1 deletion move-compiler/src/sui_mode/id_leak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl SimpleAbsIntConstructor for IDLeakVerifier {
_init_state: &mut <Self::AI<'a> as SimpleAbsInt>::State,
) -> Option<Self::AI<'a>> {
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);
Expand Down
8 changes: 5 additions & 3 deletions move-compiler/src/sui_mode/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions move-core/types/src/gas_algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl<U> From<GasQuantity<U>> for u64 {
* Clone & Copy
*
**************************************************************************************************/
#[allow(clippy::incorrect_clone_impl_on_copy_type)]
impl<U> Clone for GasQuantity<U> {
fn clone(&self) -> Self {
Self::new(self.val)
Expand Down
2 changes: 1 addition & 1 deletion move-ir-compiler/move-ir-to-bytecode/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl<'a> Context<'a> {
}

fn materialize_map<T: Clone>(m: HashMap<T, TableIndex>) -> Vec<T> {
Self::materialize_pool(m.len(), m.into_iter())
Self::materialize_pool(m.len(), m)
}

/// Finish compilation, and materialize the pools for file format.
Expand Down
2 changes: 1 addition & 1 deletion move-ir-compiler/move-ir-to-bytecode/syntax/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion move-model/src/builder/exp_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion move-prover/boogie-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<BTreeSet<_>>()
.into_iter()
.collect_vec();
Expand Down
2 changes: 1 addition & 1 deletion move-prover/bytecode/src/dataflow_domains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,6 @@ impl<K: Ord + Clone, V: AbstractDomain + Clone + PartialEq> MapDomain<K, V> {
}
})
.collect_vec();
self.extend(new_values.into_iter());
self.extend(new_values);
}
}
2 changes: 1 addition & 1 deletion move-prover/bytecode/src/verification_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<VerificationInfo>(true);
if !info.verified {
Expand Down
2 changes: 1 addition & 1 deletion move-prover/bytecode/src/verification_analysis_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions move-prover/interpreter/src/concrete/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion move-vm/runtime/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion move-vm/types/src/loaded_data/runtime_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tools/move-bytecode-viewer/src/tui/text_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion tools/move-cli/src/base/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")))]
Expand Down
2 changes: 1 addition & 1 deletion tools/move-cli/src/sandbox/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tools/move-disassembler/src/disassembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down
2 changes: 1 addition & 1 deletion tools/move-package/src/compilation/model_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions tools/move-package/src/resolution/dependency_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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("{ ")?;
Expand Down
8 changes: 4 additions & 4 deletions tools/move-package/tests/test_dependency_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
};
Expand Down Expand Up @@ -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");
};
Expand Down Expand Up @@ -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");
};
Expand Down Expand Up @@ -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.");
};
Expand Down
5 changes: 4 additions & 1 deletion tools/move-package/tests/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ impl Test<'_> {

fn output(&self) -> anyhow::Result<String> {
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();
Expand Down
Loading

0 comments on commit 449e444

Please sign in to comment.