Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Upgrades Rust to 1.72.0 & nightly-2023-08-25 (#32961)
Browse files Browse the repository at this point in the history
* allow pedantic invalid cast lint

* allow lint with false-positive triggered by `test-case` crate

* nightly `fmt` correction

* adapt to rust layout changes

* remove dubious test

* Use transmute instead of pointer cast and de/ref when check_aligned is false.

* Renames clippy::integer_arithmetic to clippy::arithmetic_side_effects.

* bump rust nightly to 2023-08-25

* Upgrades Rust to 1.72.0

---------

Co-authored-by: Trent Nelson <trent@solana.com>
  • Loading branch information
Lichtso and t-nelson authored Sep 1, 2023
1 parent 114b5b9 commit 9e703f8
Show file tree
Hide file tree
Showing 151 changed files with 167 additions and 198 deletions.
2 changes: 1 addition & 1 deletion account-decoder/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
#[macro_use]
extern crate lazy_static;
#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion accounts-bench/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

#[macro_use]
extern crate log;
Expand Down
2 changes: 1 addition & 1 deletion accounts-cluster-bench/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
clap::{crate_description, crate_name, value_t, values_t_or_exit, App, Arg},
log::*,
Expand Down
2 changes: 2 additions & 0 deletions accounts-db/src/append_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ pub mod tests {
fn set_data_len_unsafe(&self, new_data_len: u64) {
// UNSAFE: cast away & (= const ref) to &mut to force to mutate append-only (=read-only) AppendVec
unsafe {
#[allow(invalid_reference_casting)]
std::ptr::write(
std::mem::transmute::<*const u64, *mut u64>(&self.meta.data_len),
new_data_len,
Expand All @@ -711,6 +712,7 @@ pub mod tests {
fn set_executable_as_byte(&self, new_executable_byte: u8) {
// UNSAFE: Force to interpret mmap-backed &bool as &u8 to write some crafted value;
unsafe {
#[allow(invalid_reference_casting)]
std::ptr::write(
std::mem::transmute::<*const bool, *mut u8>(&self.account_meta.executable),
new_executable_byte,
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

#[macro_use]
extern crate lazy_static;
Expand Down
2 changes: 1 addition & 1 deletion banking-bench/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
clap::{crate_description, crate_name, Arg, ArgEnum, Command},
crossbeam_channel::{unbounded, Receiver},
Expand Down
2 changes: 1 addition & 1 deletion banks-server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
pub mod banks_server;
2 changes: 1 addition & 1 deletion bench-streamer/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

use {
clap::{crate_description, crate_name, Arg, Command},
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
pub mod bench;
pub mod bench_tps_client;
pub mod cli;
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
clap::value_t,
log::*,
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/tests/bench_tps.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

use {
serial_test::serial,
Expand Down
2 changes: 1 addition & 1 deletion bucket_map/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
mod bucket;
pub mod bucket_api;
mod bucket_item;
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-rust-nightly/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM solanalabs/rust:1.69.0
FROM solanalabs/rust:1.72.0
ARG date

RUN set -x \
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Note: when the rust version is changed also modify
# ci/rust-version.sh to pick up the new image tag
FROM rust:1.69.0
FROM rust:1.72.0

RUN set -x \
&& apt update \
Expand Down
2 changes: 1 addition & 1 deletion ci/rust-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fi
if [[ -n $RUST_NIGHTLY_VERSION ]]; then
nightly_version="$RUST_NIGHTLY_VERSION"
else
nightly_version=2023-04-19
nightly_version=2023-08-25
fi


Expand Down
4 changes: 2 additions & 2 deletions ci/test-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ nightly_clippy_allows=(--allow=clippy::redundant_clone)
_ scripts/cargo-for-all-lock-files.sh -- "+${rust_nightly}" clippy --workspace --all-targets --features dummy-for-ci-check -- \
--deny=warnings \
--deny=clippy::default_trait_access \
--deny=clippy::integer_arithmetic \
--deny=clippy::arithmetic_side_effects \
--deny=clippy::manual_let_else \
--deny=clippy::used_underscore_binding \
"${nightly_clippy_allows[@]}"
Expand All @@ -87,7 +87,7 @@ _ scripts/cargo-for-all-lock-files.sh -- "+${rust_nightly}" clippy --workspace -
_ scripts/cargo-for-all-lock-files.sh -- clippy --workspace --tests --bins --examples --features dummy-for-ci-check -- \
--deny=warnings \
--deny=clippy::default_trait_access \
--deny=clippy::integer_arithmetic \
--deny=clippy::arithmetic_side_effects \
--deny=clippy::manual_let_else \
--deny=clippy::used_underscore_binding

Expand Down
2 changes: 1 addition & 1 deletion cli-output/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
mod cli_output;
pub mod cli_version;
pub mod display;
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
macro_rules! ACCOUNT_STRING {
() => {
r#", one of:
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/nonce.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
solana_cli::{
check_balance,
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/program.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

use {
serde_json::Value,
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/request_airdrop.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
solana_cli::cli::{process_command, CliCommand, CliConfig},
solana_faucet::faucet::run_local_faucet,
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/stake.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
#![allow(clippy::redundant_closure)]
use {
assert_matches::assert_matches,
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
#![allow(clippy::redundant_closure)]
use {
solana_cli::{
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/vote.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
solana_cli::{
check_balance,
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

pub mod connection_cache;
pub mod nonblocking;
Expand Down
2 changes: 1 addition & 1 deletion client/src/transaction_executor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
log::*,
solana_measure::measure::Measure,
Expand Down
2 changes: 1 addition & 1 deletion connection-cache/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

pub mod client_connection;
pub mod connection_cache;
Expand Down
2 changes: 1 addition & 1 deletion core/benches/banking_stage.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
#![feature(test)]

extern crate test;
Expand Down
2 changes: 1 addition & 1 deletion core/benches/consumer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
#![feature(test)]

use {
Expand Down
2 changes: 1 addition & 1 deletion core/benches/shredder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
#![feature(test)]

extern crate test;
Expand Down
2 changes: 1 addition & 1 deletion core/benches/sigverify_stage.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(test)]
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

extern crate solana_core;
extern crate test;
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
#![recursion_limit = "2048"]
//! The `solana` library implements the Solana high-performance blockchain architecture.
//! It includes a full Rust implementation of the architecture (see
Expand Down
5 changes: 4 additions & 1 deletion core/tests/epoch_accounts_hash.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// REMOVE once https://github.com/rust-lang/rust-clippy/issues/11153 is fixed
#![allow(clippy::items_after_test_module)]

use {
crate::snapshot_utils::create_tmp_accounts_dir_for_tests,
log::*,
Expand Down Expand Up @@ -665,7 +668,7 @@ fn test_epoch_accounts_hash_and_warping() {
// https://github.com/rust-lang/rust/pull/88582
// https://github.com/jhpratt/rust/blob/727a4fc7e3f836938dfeb4a2ab237cfca612222d/library/core/src/num/uint_macros.rs#L1811-L1837
const fn next_multiple_of(lhs: u64, rhs: u64) -> u64 {
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
match lhs % rhs {
0 => lhs,
r => lhs + (rhs - r),
Expand Down
2 changes: 1 addition & 1 deletion core/tests/fork-selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
//! ```
//! time: 4007, tip converged: 10, trunk id: 3830, trunk time: 3827, trunk converged 100, trunk height 348
//! ```
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

extern crate rand;
use {
Expand Down
2 changes: 1 addition & 1 deletion core/tests/ledger_cleanup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
// Long-running ledger_cleanup tests

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion core/tests/snapshots.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

use {
crate::snapshot_utils::create_tmp_accounts_dir_for_tests,
Expand Down
2 changes: 1 addition & 1 deletion cost-model/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

pub mod block_cost_limits;
pub mod cost_model;
Expand Down
2 changes: 1 addition & 1 deletion dos/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
pub mod cli;
2 changes: 1 addition & 1 deletion dos/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
//! solana-dos $COMMON --valid-blockhash --transaction-type account-creation
//! ```
//!
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
crossbeam_channel::{select, tick, unbounded, Receiver, Sender},
itertools::Itertools,
Expand Down
2 changes: 1 addition & 1 deletion download-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
console::Emoji,
indicatif::{ProgressBar, ProgressStyle},
Expand Down
2 changes: 1 addition & 1 deletion entry/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
pub mod entry;
pub mod poh;

Expand Down
2 changes: 1 addition & 1 deletion genesis/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
pub mod address_generator;
pub mod genesis_accounts;
pub mod stakes;
Expand Down
2 changes: 1 addition & 1 deletion genesis/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! A command-line executable for generating the chain's genesis config.
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

use {
base64::{prelude::BASE64_STANDARD, Engine},
Expand Down
2 changes: 1 addition & 1 deletion gossip/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

pub mod cluster_info;
pub mod cluster_info_metrics;
Expand Down
2 changes: 1 addition & 1 deletion gossip/tests/crds_gossip.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
bincode::serialized_size,
log::*,
Expand Down
2 changes: 1 addition & 1 deletion gossip/tests/gossip.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
#[macro_use]
extern crate log;

Expand Down
2 changes: 1 addition & 1 deletion install/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
#[macro_use]
extern crate lazy_static;

Expand Down
2 changes: 1 addition & 1 deletion keygen/src/keygen.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
bip39::{Mnemonic, MnemonicType, Seed},
clap::{crate_description, crate_name, Arg, ArgMatches, Command},
Expand Down
2 changes: 1 addition & 1 deletion ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
crate::{args::*, bigtable::*, ledger_path::*, ledger_utils::*, output::*, program::*},
chrono::{DateTime, Utc},
Expand Down
2 changes: 1 addition & 1 deletion ledger/benches/blockstore.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
#![feature(test)]
extern crate solana_ledger;
extern crate test;
Expand Down
2 changes: 1 addition & 1 deletion ledger/benches/protobuf.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
#![feature(test)]
extern crate test;

Expand Down
2 changes: 1 addition & 1 deletion ledger/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]

pub mod bank_forks_utils;
pub mod bigtable_delete;
Expand Down
2 changes: 1 addition & 1 deletion ledger/tests/shred.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
solana_entry::entry::Entry,
solana_ledger::shred::{
Expand Down
2 changes: 1 addition & 1 deletion local-cluster/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
pub mod cluster;
pub mod cluster_tests;
pub mod integration_tests;
Expand Down
2 changes: 1 addition & 1 deletion local-cluster/tests/local_cluster.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {
assert_matches::assert_matches,
crossbeam_channel::{unbounded, Receiver},
Expand Down
2 changes: 1 addition & 1 deletion log-analyzer/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
extern crate byte_unit;

use {
Expand Down
2 changes: 1 addition & 1 deletion measure/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
pub mod macros;
pub mod measure;
2 changes: 1 addition & 1 deletion memory-management/src/aligned_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl<const ALIGN: usize, T: AsRef<[u8]>> From<T> for AlignedMemory<ALIGN> {

#[cfg(test)]
mod tests {
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::arithmetic_side_effects)]
use {super::*, std::io::Write};

fn do_test<const ALIGN: usize>() {
Expand Down
Loading

0 comments on commit 9e703f8

Please sign in to comment.