Skip to content

Commit

Permalink
chore: clean compiler warnings
Browse files Browse the repository at this point in the history
And some clippy warnings as well...
  • Loading branch information
Rqnsom committed Jan 15, 2024
1 parent 9ec76b5 commit 4a048ee
Show file tree
Hide file tree
Showing 20 changed files with 27 additions and 29 deletions.
4 changes: 2 additions & 2 deletions language/evm/move-to-yul/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ pub fn run_to_yul<W: WriteColor>(error_writer: &mut W, mut options: Options) ->
if let Some(i) = options.output.rfind('.') {
options.abi_output = format!("{}.abi.json", &options.output[..i]);
}
fs::write(options.output, &content)?;
fs::write(options.abi_output, &abi_content)?;
fs::write(options.output, content)?;
fs::write(options.abi_output, abi_content)?;
}
Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions language/move-analyzer/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ impl UseDef {

references
.entry(def_loc)
.or_insert_with(BTreeSet::new)
.or_default()
.insert(use_loc);
Self {
col_start: use_start.character,
Expand Down Expand Up @@ -560,7 +560,7 @@ impl UseDefMap {
}

fn insert(&mut self, key: u32, val: UseDef) {
self.0.entry(key).or_insert_with(BTreeSet::new).insert(val);
self.0.entry(key).or_default().insert(val);
}

fn get(&self, key: u32) -> Option<BTreeSet<UseDef>> {
Expand Down Expand Up @@ -595,7 +595,7 @@ impl Symbols {
for (k, v) in other.references {
self.references
.entry(k)
.or_insert_with(BTreeSet::new)
.or_default()
.extend(v);
}
self.file_use_defs.extend(other.file_use_defs);
Expand Down
2 changes: 1 addition & 1 deletion language/move-borrow-graph/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<Loc: Copy, Lbl: Clone + Ord> BorrowGraph<Loc, Lbl> {
None => full_borrows.insert(borrower, edge.loc),
Some(f) => field_borrows
.entry(f.clone())
.or_insert_with(BTreeMap::new)
.or_default()
.insert(borrower, edge.loc),
};
}
Expand Down
2 changes: 1 addition & 1 deletion language/move-borrow-graph/src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl<Loc: Copy, Lbl: Clone + Ord> Eq for BorrowEdge<Loc, Lbl> {}

impl<Loc: Copy, Lbl: Clone + Ord> PartialOrd for BorrowEdge<Loc, Lbl> {
fn partial_cmp(&self, other: &BorrowEdge<Loc, Lbl>) -> Option<Ordering> {
BorrowEdgeNoLoc::new(self).partial_cmp(&BorrowEdgeNoLoc::new(other))
Some(self.cmp(other))
}
}

Expand Down
1 change: 0 additions & 1 deletion language/move-compiler/src/expansion/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,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 language/move-compiler/src/parser/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub enum Tok {
}

impl fmt::Display for Tok {
fn fmt<'f>(&self, formatter: &mut fmt::Formatter<'f>) -> Result<(), fmt::Error> {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
use Tok::*;
let s = match *self {
EOF => "[end-of-file]",
Expand Down
2 changes: 1 addition & 1 deletion language/move-compiler/src/shared/unique_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl<T: TName> Eq for UniqueSet<T> {}

impl<T: TName> PartialOrd for UniqueSet<T> {
fn partial_cmp(&self, other: &UniqueSet<T>) -> Option<Ordering> {
(self.0).0.keys().partial_cmp((other.0).0.keys())
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion language/move-compiler/src/typing/recursive_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Context {
}
self.struct_neighbors
.entry(self.current_struct.unwrap())
.or_insert_with(BTreeMap::new)
.or_default()
.insert(*sname, loc);
}

Expand Down
4 changes: 2 additions & 2 deletions language/move-core/types/src/gas_algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl<U> From<GasQuantity<U>> for u64 {
**************************************************************************************************/
impl<U> Clone for GasQuantity<U> {
fn clone(&self) -> Self {
Self::new(self.val)
*self
}
}

Expand Down Expand Up @@ -169,7 +169,7 @@ impl<U> Eq for GasQuantity<U> {}

impl<U> PartialOrd for GasQuantity<U> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp_impl(other))
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion language/move-model/src/builder/exp_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<'env, 'translator, 'module_translator> ExpTranslator<'env, 'translator, 'mo
node_counter_start,
accessed_locals: BTreeSet::new(),
outer_context_scopes: 0,
/// Following flags used to translate pure Move functions.
// Following flags are used to translate pure Move functions.
translating_fun_as_spec_fun: false,
errors_generated: RefCell::new(false),
called_spec_funs: BTreeSet::new(),
Expand Down
2 changes: 1 addition & 1 deletion language/move-prover/boogie-backend/src/boogie_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ fn create_domain_map(
let mut default_domain = None;

let mut insert_map = |elems: &Vec<ModelValue>, val: &ModelValue| -> Option<()> {
map.entry(elems[0].clone()).or_insert_with(BTreeMap::new);
map.entry(elems[0].clone()).or_default();
map.get_mut(&elems[0])
.unwrap()
.insert(elems[1].extract_number()?, extract_bool(val)?);
Expand Down
2 changes: 1 addition & 1 deletion language/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
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 language/move-prover/interpreter/src/concrete/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ impl GlobalState {
self.touched_addresses.insert(addr);
self.accounts
.entry(addr)
.or_insert_with(AccountState::default)
.or_default()
.put_resource(&key, object.val)
.map(|val| TypedValue {
ty: Type::mk_struct(key),
Expand All @@ -1202,7 +1202,7 @@ impl GlobalState {
let res = self
.events
.entry(guid)
.or_insert_with(BTreeMap::new)
.or_default()
.insert(seq, msg);
if cfg!(debug_assertions) {
assert!(res.is_none());
Expand Down Expand Up @@ -1308,7 +1308,7 @@ impl EvalState {
self.saved_memory
.entry(label)
.and_modify(|per_label_map| per_label_map.clear())
.or_insert_with(BTreeMap::new)
.or_default()
.insert(partial_inst.ident, per_struct_map);
}

Expand Down
6 changes: 3 additions & 3 deletions language/move-stdlib/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ fn main() {
// Generate documentation
{
time_it("Generating stdlib documentation", || {
std::fs::remove_dir_all(&move_stdlib::doc::move_stdlib_docs_full_path()).unwrap_or(());
std::fs::remove_dir_all(move_stdlib::doc::move_stdlib_docs_full_path()).unwrap_or(());
//std::fs::create_dir_all(&move_stdlib::move_stdlib_docs_full_path()).unwrap();
move_stdlib::doc::build_stdlib_doc(&move_stdlib::doc::move_stdlib_docs_full_path());
});

time_it("Generating nursery documentation", || {
std::fs::remove_dir_all(&move_stdlib::doc::move_nursery_docs_full_path()).unwrap_or(());
std::fs::remove_dir_all(move_stdlib::doc::move_nursery_docs_full_path()).unwrap_or(());
move_stdlib::doc::build_nursery_doc(&move_stdlib::doc::move_nursery_docs_full_path());
});

time_it("Generating error explanations", || {
std::fs::remove_file(&move_stdlib::doc::move_stdlib_errmap_full_path()).unwrap_or(());
std::fs::remove_file(move_stdlib::doc::move_stdlib_errmap_full_path()).unwrap_or(());
move_stdlib::doc::build_error_code_map(
&move_stdlib::doc::move_stdlib_errmap_full_path(),
);
Expand Down
2 changes: 1 addition & 1 deletion language/move-stdlib/src/natives/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ mod testing {
// If this is a vector<u8> we print it in hex (as most users would expect us to)
if is_non_empty_vector_u8(&vec) {
let bytes = MoveValue::vec_to_vec_u8(vec).map_err(to_vec_u8_type_err)?;
write!(out, "0x{}", hex::encode(&bytes))
write!(out, "0x{}", hex::encode(bytes))
.map_err(fmt_error_to_partial_vm_error)?;
} else {
let is_complex_inner_type =
Expand Down
4 changes: 2 additions & 2 deletions language/tools/move-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ pub fn run_cli(
natives,
cost_table,
error_descriptions,
&move_args,
move_args,
&storage_dir,
),
Command::Experimental { storage_dir, cmd } => cmd.handle_command(&move_args, &storage_dir),
Command::Experimental { storage_dir, cmd } => cmd.handle_command(move_args, &storage_dir),
}
}

Expand Down
1 change: 0 additions & 1 deletion language/tools/move-cli/src/sandbox/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Copyright (c) The Move Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::sandbox::utils::on_disk_state_view::OnDiskStateView;
use anyhow::{bail, Result};
use colored::Colorize;
use difference::{Changeset, Difference};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl OnDiskStateView {
event_type,
event_data,
));
Ok(fs::write(path, &bcs::to_bytes(&event_log)?)?)
Ok(fs::write(path, bcs::to_bytes(&event_log)?)?)
}

/// Save `module` on disk under the path `module.address()`/`module.name()`
Expand Down
2 changes: 1 addition & 1 deletion language/tools/move-unit-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl UnitTestingConfig {

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.files.extend(files);
Some(test_plan)
}

Expand Down

0 comments on commit 4a048ee

Please sign in to comment.