Skip to content

Commit

Permalink
Backport code changes to please clippy to 1.5 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Aug 5, 2024
1 parent 5a4bc0e commit 6c4ca16
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion contracts/burner/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ mod tests {
let res = migrate(deps.as_mut(), mock_env(), msg).unwrap();
// check payout
assert_eq!(1, res.messages.len());
let msg = res.messages.get(0).expect("no message");
let msg = res.messages.first().expect("no message");
assert_eq!(
msg,
&SubMsg::new(BankMsg::Send {
Expand Down
2 changes: 1 addition & 1 deletion contracts/burner/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn migrate_sends_funds() {
let res: Response = migrate(&mut deps, mock_env(), msg).unwrap();
// check payout
assert_eq!(1, res.messages.len());
let msg = res.messages.get(0).expect("no message");
let msg = res.messages.first().expect("no message");
assert_eq!(
msg,
&SubMsg::new(BankMsg::Send {
Expand Down
4 changes: 2 additions & 2 deletions contracts/hackatom/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ mod tests {
};
let res = sudo(deps.as_mut(), mock_env(), sys_msg).unwrap();
assert_eq!(1, res.messages.len());
let msg = res.messages.get(0).expect("no message");
let msg = res.messages.first().expect("no message");
assert_eq!(msg, &SubMsg::new(BankMsg::Send { to_address, amount }));
}

Expand Down Expand Up @@ -466,7 +466,7 @@ mod tests {
)
.unwrap();
assert_eq!(execute_res.messages.len(), 1);
let msg = execute_res.messages.get(0).expect("no message");
let msg = execute_res.messages.first().expect("no message");
assert_eq!(
msg,
&SubMsg::new(BankMsg::Send {
Expand Down
4 changes: 2 additions & 2 deletions contracts/hackatom/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fn sudo_can_steal_tokens() {
};
let res: Response = sudo(&mut deps, mock_env(), sys_msg).unwrap();
assert_eq!(1, res.messages.len());
let msg = res.messages.get(0).expect("no message");
let msg = res.messages.first().expect("no message");
assert_eq!(msg, &SubMsg::new(BankMsg::Send { to_address, amount }));
}

Expand Down Expand Up @@ -237,7 +237,7 @@ fn execute_release_works() {
let execute_res: Response =
execute(&mut deps, mock_env(), execute_info, ExecuteMsg::Release {}).unwrap();
assert_eq!(execute_res.messages.len(), 1);
let msg = execute_res.messages.get(0).expect("no message");
let msg = execute_res.messages.first().expect("no message");
assert_eq!(
msg,
&SubMsg::new(BankMsg::Send {
Expand Down
5 changes: 3 additions & 2 deletions contracts/staking/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,14 @@ pub fn _bond_all_tokens(

// we deduct pending claims from our account balance before reinvesting.
// if there is not enough funds, we just return a no-op
match update_item(deps.storage, KEY_TOTAL_SUPPLY, |mut supply: Supply| {
let updated = update_item(deps.storage, KEY_TOTAL_SUPPLY, |mut supply: Supply| {
balance.amount = balance.amount.checked_sub(supply.claims)?;
// this just triggers the "no op" case if we don't have min_withdrawal left to reinvest
balance.amount.checked_sub(invest.min_withdrawal)?;
supply.bonded += balance.amount;
Ok(supply)
}) {
});
match updated {
Ok(_) => {}
// if it is below the minimum, we do a no-op (do not revert other state from withdrawal)
Err(StdError::Overflow { .. }) => return Ok(Response::default()),
Expand Down
4 changes: 2 additions & 2 deletions packages/std/src/errors/std_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,8 @@ mod tests {

#[test]
fn from_std_str_utf8error_works() {
let broken = b"Hello \xF0\x90\x80World";
let error: StdError = str::from_utf8(broken).unwrap_err().into();
let broken = Vec::from(b"Hello \xF0\x90\x80World" as &[u8]);
let error: StdError = str::from_utf8(&broken).unwrap_err().into();
match error {
StdError::InvalidUtf8 { msg, .. } => {
assert_eq!(msg, "invalid utf-8 sequence of 3 bytes from index 6")
Expand Down
1 change: 1 addition & 0 deletions packages/std/src/testing/assertions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ mod tests {
)]
fn assert_approx_with_custom_panic_msg() {
let adjective = "extra";
#[allow(dead_code)]
#[derive(Debug)]
struct Foo(u32);
assert_approx_eq!(
Expand Down
1 change: 1 addition & 0 deletions packages/vm/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ fn save_wasm_to_disk(dir: impl Into<PathBuf>, wasm: &[u8]) -> VmResult<Checksum>
let mut file = OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(filepath)
.map_err(|e| VmError::cache_err(format!("Error opening Wasm file for writing: {e}")))?;
file.write_all(wasm)
Expand Down

0 comments on commit 6c4ca16

Please sign in to comment.