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

Switch to Rust-1.66 #869

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master.yml.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion asset-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ impl<T: Config> Pallet<T> {
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::<T>::BadVersion)?;
LocationToAssetId::<T>::try_mutate(&location, |maybe_asset_id| {
LocationToAssetId::<T>::try_mutate(location, |maybe_asset_id| {
ensure!(maybe_asset_id.is_none(), Error::<T>::ConflictingLocation);
*maybe_asset_id = Some(asset_id);
Ok(())
Expand Down
18 changes: 9 additions & 9 deletions auction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ pub mod module {
#[pallet::hooks]
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {
fn on_initialize(now: T::BlockNumber) -> Weight {
T::WeightInfo::on_finalize(AuctionEndTime::<T>::iter_prefix(&now).count() as u32)
T::WeightInfo::on_finalize(AuctionEndTime::<T>::iter_prefix(now).count() as u32)
}

fn on_finalize(now: T::BlockNumber) {
for (auction_id, _) in AuctionEndTime::<T>::drain_prefix(&now) {
if let Some(auction) = Auctions::<T>::take(&auction_id) {
for (auction_id, _) in AuctionEndTime::<T>::drain_prefix(now) {
if let Some(auction) = Auctions::<T>::take(auction_id) {
T::Handler::on_auction_ended(auction_id, auction.bid);
}
}
Expand Down Expand Up @@ -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::<T>::remove(&old_end_block, id);
AuctionEndTime::<T>::remove(old_end_block, id);
}
if let Some(new_end_block) = new_end {
AuctionEndTime::<T>::insert(&new_end_block, id, ());
AuctionEndTime::<T>::insert(new_end_block, id, ());
}
auction.end = new_end;
}
Expand Down Expand Up @@ -189,10 +189,10 @@ impl<T: Config> Auction<T::AccountId, T::BlockNumber> for Pallet<T> {
) -> DispatchResult {
let auction = Auctions::<T>::get(id).ok_or(Error::<T>::AuctionNotExist)?;
if let Some(old_end) = auction.end {
AuctionEndTime::<T>::remove(&old_end, id);
AuctionEndTime::<T>::remove(old_end, id);
}
if let Some(new_end) = info.end {
AuctionEndTime::<T>::insert(&new_end, id, ());
AuctionEndTime::<T>::insert(new_end, id, ());
}
Auctions::<T>::insert(id, info);
Ok(())
Expand All @@ -211,14 +211,14 @@ impl<T: Config> Auction<T::AccountId, T::BlockNumber> for Pallet<T> {
})?;
Auctions::<T>::insert(auction_id, auction);
if let Some(end_block) = end {
AuctionEndTime::<T>::insert(&end_block, auction_id, ());
AuctionEndTime::<T>::insert(end_block, auction_id, ());
}

Ok(auction_id)
}

fn remove_auction(id: Self::AuctionId) {
if let Some(auction) = Auctions::<T>::take(&id) {
if let Some(auction) = Auctions::<T>::take(id) {
if let Some(end_block) = auction.end {
AuctionEndTime::<T>::remove(end_block, id);
}
Expand Down
12 changes: 4 additions & 8 deletions bencher/src/build_wasm/prerequisites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ fn get_rustup_nightly(selected: Option<String>) -> Option<CargoCommand> {
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;
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -260,7 +256,7 @@ fn check_wasm_toolchain_installed(cargo_command: CargoCommand) -> Result<CargoCo
let manifest_path = temp.path().join("Cargo.toml").display().to_string();

let mut build_cmd = cargo_command.command();
build_cmd.args(&[
build_cmd.args([
"build",
"--target=wasm32-unknown-unknown",
"--manifest-path",
Expand All @@ -272,7 +268,7 @@ fn check_wasm_toolchain_installed(cargo_command: CargoCommand) -> Result<CargoCo
}

let mut run_cmd = cargo_command.command();
run_cmd.args(&["run", "--manifest-path", &manifest_path]);
run_cmd.args(["run", "--manifest-path", &manifest_path]);

build_cmd.output().map_err(|_| err_msg.clone()).and_then(|s| {
if s.status.success() {
Expand Down
2 changes: 1 addition & 1 deletion bencher/src/build_wasm/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ fn build_project(project: &Path, default_rustflags: &str, cargo_cmd: CargoComman
);

build_cmd
.args(&["rustc", "--target=wasm32-unknown-unknown"])
.args(["rustc", "--target=wasm32-unknown-unknown"])
.arg(format!("--manifest-path={}", manifest_path.display()))
.env("RUSTFLAGS", rustflags)
// Unset the `CARGO_TARGET_DIR` to prevent a cargo deadlock (cargo locks a target dir exclusive).
Expand Down
2 changes: 1 addition & 1 deletion oracle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
value: value.clone(),
timestamp: now,
};
RawValues::<T, I>::insert(&who, &key, timestamped);
RawValues::<T, I>::insert(&who, key, timestamped);

// Update `Values` storage if `combined` yielded result.
if let Some(combined) = Self::combined(key) {
Expand Down
4 changes: 2 additions & 2 deletions vesting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub mod module {
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::claim((<T as Config>::MaxVestingSchedules::get() / 2) as u32))]
#[pallet::weight(T::WeightInfo::claim(<T as Config>::MaxVestingSchedules::get() / 2))]
pub fn claim(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
let locked_amount = Self::do_claim(&who);
Expand Down Expand Up @@ -301,7 +301,7 @@ pub mod module {
}

#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::claim((<T as Config>::MaxVestingSchedules::get() / 2) as u32))]
#[pallet::weight(T::WeightInfo::claim(<T as Config>::MaxVestingSchedules::get() / 2))]
pub fn claim_for(origin: OriginFor<T>, dest: <T::Lookup as StaticLookup>::Source) -> DispatchResult {
let _ = ensure_signed(origin)?;
let who = T::Lookup::lookup(dest)?;
Expand Down
6 changes: 3 additions & 3 deletions weight-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<String>("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("")
}
Expand All @@ -175,15 +175,15 @@ fn main() {
// Use default template if template path is not given.
let template = {
if let Some(path) = matches.get_one::<String>("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)
}
};

// Write benchmark to file or print to terminal if output path is not given.
if let Some(path) = matches.get_one::<String>("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)
Expand Down
4 changes: 1 addition & 3 deletions xtokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,10 +924,8 @@ pub mod module {
fn get_reserve_location(assets: &MultiAssets, fee_item: &u32) -> Option<MultiLocation> {
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)
Expand Down