Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update contracts and packages to cw 0.13.2 #220

Merged
merged 3 commits into from
Jan 19, 2021
Merged

Update contracts and packages to cw 0.13.2 #220

merged 3 commits into from
Jan 19, 2021

Conversation

orkunkl
Copy link
Contributor

@orkunkl orkunkl commented Jan 18, 2021

No description provided.

@@ -158,6 +158,7 @@ pub fn handle_unbond(
})
}

#[allow(const_item_mutation)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this linter config the following error is thrown:

warning: taking a mutable reference to a `const` item
   --> contracts/cw4-stake/src/contract.rs:184:5
    |
184 | /     TOTAL.update(storage, |total| -> StdResult<_> {
185 | |         let res = total + new.unwrap_or_default() - old.unwrap_or_default();
186 | |         Ok(res)
187 | |     })?;
    | |______^
    |
    = note: `#[warn(const_item_mutation)]` on by default
    = note: each usage of a `const` item creates a new temporary
    = note: the mutable reference will refer to this temporary, not the original `const` item
note: mutable reference created due to call to this method
   --> /code/packages/storage-plus/src/item.rs:64:5
    |
64  | /     pub fn update<A, E>(&mut self, store: &mut dyn Storage, action: A) -> Result<T, E>
65  | |     where
66  | |         A: FnOnce(T) -> Result<T, E>,
67  | |         E: From<StdError>,
...   |
72  | |         Ok(output)
73  | |     }
    | |_____^
note: `const` item defined here
   --> contracts/cw4-stake/src/state.rs:25:1
    |
25  | pub const TOTAL: Item<u64> = Item::new(TOTAL_KEY);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: 1 warning emitted

Compiler assumes the TOTAL value is being mutated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you're using the same linter version than the CI:

export CLIP_VERSION="+1.47.0"
cargo $CLIP_VERSION clippy -- -D warnings

When doing that, this warning is not reported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clippy version mismatch is why you're hitting errors in the CI, by the way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah you are right, I was running on rust version 1.49

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug is the &mut self in update.
I think this was fixed (or at least reported).
I will check, we should definitely modify that - not disable the warning, but make it non mut

Copy link
Contributor

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@@ -158,6 +158,7 @@ pub fn handle_unbond(
})
}

#[allow(const_item_mutation)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you're using the same linter version than the CI:

export CLIP_VERSION="+1.47.0"
cargo $CLIP_VERSION clippy -- -D warnings

When doing that, this warning is not reported.

Copy link
Member

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed some hanging &mut self which were rightly causing linter errors.
Otherwise, looks good.

@ethanfrey ethanfrey merged commit 4c6e509 into master Jan 19, 2021
@ethanfrey ethanfrey deleted the update-0.13.2 branch January 19, 2021 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants