From 96e0a69b5a20aec1b89ef3deced95b6c9e63f7c0 Mon Sep 17 00:00:00 2001 From: SeungMin Lee Date: Mon, 6 Jan 2020 21:14:28 +0900 Subject: [PATCH 1/2] Upgrade fixed-hash crate to 0.2.2 to prevent the latest clippy fail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, Codechain uses fixed-hash@0.2.1v that has a duplicated macro definition. The duplicated macro makes the latest clippy(+nightly-2019-12-19) fail. So, we need to upgrade it. When fixed-hash 0.2.5 was applied, an error(E0599) occurred due to incompatibility for some functions. This problem can be solved as follows. 1. Upgrade Our rust-codechain-primitives(`primtivies`) to use the upgraded fixed-hash. 2. Upgrade libraries using `primitives` used by CodeChain and modules in CodeChain. However, too many libraries(rlp, rust-codechain-crypto etc) are using `primitives` that are not updated. Also, this is not a problem that will be solved just by upgrading primitives. We need a large-scale update to use fixed-hash@≥0.2.5 and later version of some packages. Fortunately, we checked 0.2.2 had resolved the macro duplication problem. We thought it's best to upgrade to 0.2.2 under the current situation. Fixed #1938 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d36035bd46..5147ea487b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -965,9 +965,9 @@ checksum = "fb881f88714a5f816e69131f0103e2c4b444e3a2a8741077b4b68586f2d32129" [[package]] name = "fixed-hash" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b18d6fd718fb4396e7a9c93ac59ba7143501467ca7a143c145b5555a571d5576" +checksum = "0d5ec8112f00ea8a483e04748a85522184418fd1cf02890b626d8fc28683f7de" dependencies = [ "heapsize", "libc", From 5929d4a1fcf97bad0f25d28e7ca1579cc1d9b19a Mon Sep 17 00:00:00 2001 From: SeungMin Lee Date: Wed, 8 Jan 2020 13:43:37 +0900 Subject: [PATCH 2/2] Upgrade rust toolchains Currently, Codechain uses the clippy(+nightly-2019-11-06) and the rustfmt(+nightly-2019-11-06). We need to make codechain use the latest toolchains. I upgraded the clippy to `+nightly-2019-12-19` and the rustfmt to `+nigtly-2019-12-19`. Fixed #1937 --- .github/workflows/cargo-test.yml | 4 ++-- README.md | 16 +++++++------- util/io/src/lib.rs | 38 ++++++++++++++++---------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/cargo-test.yml b/.github/workflows/cargo-test.yml index c17ab82314..4bceb086fd 100644 --- a/.github/workflows/cargo-test.yml +++ b/.github/workflows/cargo-test.yml @@ -12,7 +12,7 @@ jobs: fetch-depth: 1 - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2019-11-06 + toolchain: nightly-2019-12-19 components: clippy profile: minimal override: true @@ -28,7 +28,7 @@ jobs: fetch-depth: 1 - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2019-11-06 + toolchain: nightly-2019-12-19 components: rustfmt profile: minimal override: true diff --git a/README.md b/README.md index 6847a26a10..8cce4e00ad 100644 --- a/README.md +++ b/README.md @@ -132,35 +132,35 @@ You can create a block by sending a transaction through [JSON-RPC](https://githu ## Formatting -Make sure you run `rustfmt` before creating a PR to the repo. You need to install the nightly-2019-11-06 version of `rustfmt`. +Make sure you run `rustfmt` before creating a PR to the repo. You need to install the nightly-2019-12-19 version of `rustfmt`. ```sh -rustup toolchain install nightly-2019-11-06 -rustup component add rustfmt --toolchain nightly-2019-11-06 +rustup toolchain install nightly-2019-12-19 +rustup component add rustfmt --toolchain nightly-2019-12-19 ``` To run `rustfmt`, ```sh -cargo +nightly-2019-11-06 fmt +cargo +nightly-2019-12-19 fmt ``` ## Linting You should run `clippy` also. This is a lint tool for rust. It suggests more efficient/readable code. You can see [the clippy document](https://rust-lang.github.io/rust-clippy/master/index.html) for more information. -You need to install the nightly-2019-11-06 version of `clippy`. +You need to install the nightly-2019-12-19 version of `clippy`. ### Install ```sh -rustup toolchain install nightly-2019-11-06 -rustup component add clippy --toolchain nightly-2019-11-06 +rustup toolchain install nightly-2019-12-19 +rustup component add clippy --toolchain nightly-2019-12-19 ``` ### Run ```sh -cargo +nightly-2019-11-06 clippy --all --all-targets +cargo +nightly-2019-12-19 clippy --all --all-targets ``` ## Testing diff --git a/util/io/src/lib.rs b/util/io/src/lib.rs index 3c8e1d377d..4532de4295 100644 --- a/util/io/src/lib.rs +++ b/util/io/src/lib.rs @@ -27,33 +27,33 @@ //! struct MyHandler; //! //! struct MyMessage { -//! data: u32 +//! data: u32 //! } //! //! impl IoHandler for MyHandler { -//! fn initialize(&self, io: &IoContext) -> IoHandlerResult<()> { -//! io.register_timer(0, Duration::from_secs(1)); -//! Ok(()) -//! } +//! fn initialize(&self, io: &IoContext) -> IoHandlerResult<()> { +//! io.register_timer(0, Duration::from_secs(1)); +//! Ok(()) +//! } //! -//! fn timeout(&self, _io: &IoContext, timer: TimerToken) -> IoHandlerResult<()> { -//! println!("Timeout {}", timer); -//! Ok(()) -//! } +//! fn timeout(&self, _io: &IoContext, timer: TimerToken) -> IoHandlerResult<()> { +//! println!("Timeout {}", timer); +//! Ok(()) +//! } //! -//! fn message(&self, _io: &IoContext, message: MyMessage) -> IoHandlerResult<()> { -//! println!("Message {}", message.data); -//! Ok(()) -//! } +//! fn message(&self, _io: &IoContext, message: MyMessage) -> IoHandlerResult<()> { +//! println!("Message {}", message.data); +//! Ok(()) +//! } //! } //! -//! fn main () { -//! let mut service = IoService::::start("Test").expect("Error creating network service"); -//! service.register_handler(Arc::new(MyHandler)).unwrap(); +//! fn main () { +//! let mut service = IoService::::start("Test").expect("Error creating network service"); +//! service.register_handler(Arc::new(MyHandler)).unwrap(); //! -//! // Wait for quit condition -//! // ... -//! // Drop the service +//! // Wait for quit condition +//! // ... +//! // Drop the service //! } //! ```