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

Rust 1.35.0付属のrustfmt 1.2.0-stableとclippy 0.0.212に対応 #37

Merged
merged 2 commits into from
May 28, 2019

Conversation

yuezato
Copy link
Member

@yuezato yuezato commented May 27, 2019

このPRの狙い

Rust 1.35.0にバージョンが上がり、clippyのバージョンが以下のようになりました

$ cargo clippy --version
clippy 0.0.212 (265318db 2019-05-17)

これに伴い以下のようなwarningが生じています:

warning: identical conversion
   --> src/storage/journal/region.rs:333:23
    |
333 |         for result in track!(self.ring_buffer.restore_entries())? {
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `track!(self.ring_buffer.restore_entries())?()`: `track!(self.ring_buffer.restore_entries())?`
    |
    = note: #[warn(clippy::identity_conversion)] on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_conversion
warning: identical conversion
   --> src/storage/journal/region.rs:333:23
    |
333 |         for result in track!(self.ring_buffer.restore_entries())? {
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `track!(self.ring_buffer.restore_entries())?()`: `track!(self.ring_buffer.restore_entries())?`
    |
    = note: #[warn(clippy::identity_conversion)] on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_conversion

これを解決します。

内容

解決するといってもtrack!を取り除くことはできないので、clippy::identity_conversionをallowしました。

追加の変更点

Rust fmtがしばらく実行されていなかったようなので、これも併せて実行します。

rustfmt 1.2.0-stable (09940a70 2019-03-27)

@koba-e964
Copy link
Contributor

問題の箇所を以下の2行に分けても (allow(clippy::identity_conversion) なしで) 警告が消えるように見えます:

        let it = track!(self.ring_buffer.restore_entries())?;
        for result in it {

以下の2行だとit?のところで警告が出ます:

        let it = track!(self.ring_buffer.restore_entries());
        for result in it? {
warning: identical conversion
   --> src/storage/journal/region.rs:335:23
    |
335 |         for result in it? {
    |                       ^^^ help: consider removing `it?()`: `it?`
    |
    = note: #[warn(clippy::identity_conversion)] on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_conversion

もしかしたら clippy の偽陽性かもしれません。調べてみます。

@koba-e964
Copy link
Contributor

koba-e964 commented May 27, 2019

Copy link
Contributor

@koba-e964 koba-e964 left a comment

Choose a reason for hiding this comment

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

clippy のバグのようなので、いずれ元に戻したいです。
当面は、以下の2種類のうちどちらでも良いような気がします:

  • #[allow(clippy::identity_conversion)] を付ける
  • 2行に分けて #[allow(clippy::identity_conversion)] を付けない
    いずれ戻す旨のコメントも付けていただけると幸いです。

@@ -329,6 +329,7 @@ where
}

/// リングバッファおよびインデックスを前回の状態に復元する.
#[allow(clippy::identity_conversion)]
Copy link
Contributor

Choose a reason for hiding this comment

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

これが必要なのは内部の for 式だけなので、for 式に直接つけてしまってもよい気がしました。

Copy link
Member Author

Choose a reason for hiding this comment

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

確かにInner attributeにした方が良いですね。
attributeをつけつつ、後々で外すというコメントも記載する対応でいきたいと思います。

Copy link
Contributor

@koba-e964 koba-e964 left a comment

Choose a reason for hiding this comment

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

LGTM です!

@yuezato yuezato merged commit 70e62b4 into frugalos:master May 28, 2019
@brly brly mentioned this pull request Feb 25, 2020
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.

2 participants