From 16a80c7efb28095438c831a2b72db84b01326a7f Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Wed, 11 Jan 2023 05:16:08 +0800 Subject: [PATCH] Switch to Rust-1.66 --- .github/workflows/coverage.yml | 2 +- .github/workflows/master.yml.disabled | 2 +- .github/workflows/test.yml | 2 +- asset-registry/src/lib.rs | 2 +- auction/src/lib.rs | 18 +++++++++--------- bencher/src/build_wasm/prerequisites.rs | 12 ++++-------- bencher/src/build_wasm/wasm_project.rs | 2 +- oracle/src/lib.rs | 2 +- vesting/src/lib.rs | 4 ++-- weight-gen/src/main.rs | 6 +++--- xtokens/src/lib.rs | 4 +--- 11 files changed, 25 insertions(+), 31 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5b6b34f7a..96a48dacf 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -34,7 +34,7 @@ jobs: - name: Install toolchain uses: dtolnay/rust-toolchain@nightly with: - toolchain: nightly-2022-08-05 + toolchain: nightly-2022-10-30 components: rustfmt target: wasm32-unknown-unknown - name: Generate code coverage diff --git a/.github/workflows/master.yml.disabled b/.github/workflows/master.yml.disabled index 1436a32f5..a1bdac623 100644 --- a/.github/workflows/master.yml.disabled +++ b/.github/workflows/master.yml.disabled @@ -15,7 +15,7 @@ jobs: - name: Install toolchain uses: dtolnay/rust-toolchain@nightly with: - toolchain: nightly-2022-08-05 + toolchain: nightly-2022-10-30 - name: Install cargo-unleash run: cargo install cargo-unleash --git https://github.com/xlc/cargo-unleash.git # https://github.com/paritytech/cargo-unleash/pull/38 - name: Prepare diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f6870a045..6b8f74e5f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,7 @@ jobs: - name: Install toolchain uses: dtolnay/rust-toolchain@nightly with: - toolchain: nightly-2022-08-05 + toolchain: nightly-2022-10-30 components: rustfmt target: wasm32-unknown-unknown - name: Install Wasm toolchain diff --git a/asset-registry/src/lib.rs b/asset-registry/src/lib.rs index 2bea733e5..b9819566f 100644 --- a/asset-registry/src/lib.rs +++ b/asset-registry/src/lib.rs @@ -313,7 +313,7 @@ impl Pallet { fn do_insert_location(asset_id: T::AssetId, location: VersionedMultiLocation) -> DispatchResult { // if the metadata contains a location, set the LocationToAssetId let location: MultiLocation = location.try_into().map_err(|()| Error::::BadVersion)?; - LocationToAssetId::::try_mutate(&location, |maybe_asset_id| { + LocationToAssetId::::try_mutate(location, |maybe_asset_id| { ensure!(maybe_asset_id.is_none(), Error::::ConflictingLocation); *maybe_asset_id = Some(asset_id); Ok(()) diff --git a/auction/src/lib.rs b/auction/src/lib.rs index 2c9c3ec4b..5c4e00010 100644 --- a/auction/src/lib.rs +++ b/auction/src/lib.rs @@ -109,12 +109,12 @@ pub mod module { #[pallet::hooks] impl Hooks for Pallet { fn on_initialize(now: T::BlockNumber) -> Weight { - T::WeightInfo::on_finalize(AuctionEndTime::::iter_prefix(&now).count() as u32) + T::WeightInfo::on_finalize(AuctionEndTime::::iter_prefix(now).count() as u32) } fn on_finalize(now: T::BlockNumber) { - for (auction_id, _) in AuctionEndTime::::drain_prefix(&now) { - if let Some(auction) = Auctions::::take(&auction_id) { + for (auction_id, _) in AuctionEndTime::::drain_prefix(now) { + if let Some(auction) = Auctions::::take(auction_id) { T::Handler::on_auction_ended(auction_id, auction.bid); } } @@ -151,10 +151,10 @@ pub mod module { match bid_result.auction_end_change { Change::NewValue(new_end) => { if let Some(old_end_block) = auction.end { - AuctionEndTime::::remove(&old_end_block, id); + AuctionEndTime::::remove(old_end_block, id); } if let Some(new_end_block) = new_end { - AuctionEndTime::::insert(&new_end_block, id, ()); + AuctionEndTime::::insert(new_end_block, id, ()); } auction.end = new_end; } @@ -189,10 +189,10 @@ impl Auction for Pallet { ) -> DispatchResult { let auction = Auctions::::get(id).ok_or(Error::::AuctionNotExist)?; if let Some(old_end) = auction.end { - AuctionEndTime::::remove(&old_end, id); + AuctionEndTime::::remove(old_end, id); } if let Some(new_end) = info.end { - AuctionEndTime::::insert(&new_end, id, ()); + AuctionEndTime::::insert(new_end, id, ()); } Auctions::::insert(id, info); Ok(()) @@ -211,14 +211,14 @@ impl Auction for Pallet { })?; Auctions::::insert(auction_id, auction); if let Some(end_block) = end { - AuctionEndTime::::insert(&end_block, auction_id, ()); + AuctionEndTime::::insert(end_block, auction_id, ()); } Ok(auction_id) } fn remove_auction(id: Self::AuctionId) { - if let Some(auction) = Auctions::::take(&id) { + if let Some(auction) = Auctions::::take(id) { if let Some(end_block) = auction.end { AuctionEndTime::::remove(end_block, id); } diff --git a/bencher/src/build_wasm/prerequisites.rs b/bencher/src/build_wasm/prerequisites.rs index 3074480df..8377af327 100644 --- a/bencher/src/build_wasm/prerequisites.rs +++ b/bencher/src/build_wasm/prerequisites.rs @@ -77,11 +77,7 @@ fn get_rustup_nightly(selected: Option) -> Option { let version = match selected { Some(selected) => selected, None => { - let output = Command::new("rustup") - .args(&["toolchain", "list"]) - .output() - .ok()? - .stdout; + let output = Command::new("rustup").args(["toolchain", "list"]).output().ok()?.stdout; let lines = output.as_slice().lines(); let mut latest_nightly = None; @@ -194,7 +190,7 @@ fn create_check_toolchain_project(project_dir: &Path) { let manifest_path = project_dir.join("Cargo.toml"); write_file_if_changed( - &manifest_path, + manifest_path, r#" [package] name = "wasm-test" @@ -260,7 +256,7 @@ fn check_wasm_toolchain_installed(cargo_command: CargoCommand) -> Result Result, I: 'static> Pallet { value: value.clone(), timestamp: now, }; - RawValues::::insert(&who, &key, timestamped); + RawValues::::insert(&who, key, timestamped); // Update `Values` storage if `combined` yielded result. if let Some(combined) = Self::combined(key) { diff --git a/vesting/src/lib.rs b/vesting/src/lib.rs index 8ca778c34..66edffc10 100644 --- a/vesting/src/lib.rs +++ b/vesting/src/lib.rs @@ -245,7 +245,7 @@ pub mod module { #[pallet::call] impl Pallet { #[pallet::call_index(0)] - #[pallet::weight(T::WeightInfo::claim((::MaxVestingSchedules::get() / 2) as u32))] + #[pallet::weight(T::WeightInfo::claim(::MaxVestingSchedules::get() / 2))] pub fn claim(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; let locked_amount = Self::do_claim(&who); @@ -301,7 +301,7 @@ pub mod module { } #[pallet::call_index(3)] - #[pallet::weight(T::WeightInfo::claim((::MaxVestingSchedules::get() / 2) as u32))] + #[pallet::weight(T::WeightInfo::claim(::MaxVestingSchedules::get() / 2))] pub fn claim_for(origin: OriginFor, dest: ::Source) -> DispatchResult { let _ = ensure_signed(origin)?; let who = T::Lookup::lookup(dest)?; diff --git a/weight-gen/src/main.rs b/weight-gen/src/main.rs index 7fdf90211..b8f521ca5 100644 --- a/weight-gen/src/main.rs +++ b/weight-gen/src/main.rs @@ -162,7 +162,7 @@ fn main() { // Use empty header if a header path is not given. let header = { if let Some(path) = matches.get_one::("header") { - ::std::fs::read_to_string(&path).expect("Header file not found") + ::std::fs::read_to_string(path).expect("Header file not found") } else { String::from("") } @@ -175,7 +175,7 @@ fn main() { // Use default template if template path is not given. let template = { if let Some(path) = matches.get_one::("template") { - ::std::fs::read_to_string(&path).expect("Template file not found") + ::std::fs::read_to_string(path).expect("Template file not found") } else { String::from(DEFAULT_TEMPLATE) } @@ -183,7 +183,7 @@ fn main() { // Write benchmark to file or print to terminal if output path is not given. if let Some(path) = matches.get_one::("output") { - let mut output_file = ::std::fs::File::create(&path).expect("Could not create output file"); + let mut output_file = ::std::fs::File::create(path).expect("Could not create output file"); handlebars .render_template_to_write(&template, &hbs_data, &mut output_file) diff --git a/xtokens/src/lib.rs b/xtokens/src/lib.rs index e75585d31..25cb2a35c 100644 --- a/xtokens/src/lib.rs +++ b/xtokens/src/lib.rs @@ -924,10 +924,8 @@ pub mod module { fn get_reserve_location(assets: &MultiAssets, fee_item: &u32) -> Option { let reserve_idx = if assets.len() == 1 { 0 - } else if *fee_item == 0 { - 1 } else { - 0 + (*fee_item == 0) as usize }; let asset = assets.get(reserve_idx); asset.and_then(T::ReserveProvider::reserve)