Skip to content

Commit

Permalink
[rust] migrate to beta toolchain
Browse files Browse the repository at this point in the history
Now that the `async_await` feature has been stabilized on the 1.39.0
beta toolchain we can migrate from using a nightly toolchain to the beta
toolchain.

To that end this patch does the following:
    * change rust-toolchain to pin to the `beta` toolchain
    * remove all occurrences of `#[feature(async_await)]` since the feature
      has been stabilized
    * remove a number of nightly rustfmt features from `rustfmt.toml`
      that we were using and run rustfmt to fix a couple of formatting
      changes
    * temporarily allow the new on-by-default lint
      `clippy::inherent-to-string` to avoid having to fix all violations
      of this lint during the compiler bump
    * remove the `nightly_features.sh` script that we used to check for
      whitelisted nightly features as it is no longer needed as the
      compiler will now error out if any nightly features are used
    * bump the futures crate to version 0.3.0-alpha.19 which is
      compatible with the 1.39.0 beta toolchain

Closes: #286

Closes: #1072
Approved by: metajack
  • Loading branch information
bmwill authored and bors-libra committed Sep 26, 2019
1 parent 389b0eb commit 6020c8f
Show file tree
Hide file tree
Showing 42 changed files with 95 additions and 134 deletions.
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ jobs:
- run:
name: Linting
command: |
[[ $CIRCLE_NODE_INDEX =~ [123] ]] || ./scripts/nightly_features.sh
[[ $CIRCLE_NODE_INDEX =~ [123] ]] || ./scripts/clippy.sh
[[ $CIRCLE_NODE_INDEX =~ [123] ]] || cargo fmt -- --check
- run:
Expand Down
120 changes: 64 additions & 56 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion admission_control/admission_control_service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[dependencies]
futures = "0.1.28"
futures03 = { version = "=0.3.0-alpha.17", package = "futures-preview" }
futures03 = { version = "=0.3.0-alpha.19", package = "futures-preview" }
grpcio = { version = "0.4.4", default-features = false, features = ["protobuf-codec"] }
lazy_static = "1.3.0"
protobuf = "~2.7"
Expand Down
2 changes: 1 addition & 1 deletion common/bounded-executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ edition = "2018"

[dependencies]
futures-semaphore = { path = "../futures-semaphore" }
futures = { version = "=0.3.0-alpha.17", package = "futures-preview", features = ["async-await", "nightly", "compat"] }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["async-await", "compat"] }
tokio = "0.1.22"
2 changes: 0 additions & 2 deletions common/bounded-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
//! concurrently when spawned through this executor, defined by the initial
//! `capacity`.
#![feature(async_await)]

use futures::future::{Future, FutureExt, TryFutureExt};
use futures_semaphore::Semaphore;
use tokio::runtime::TaskExecutor;
Expand Down
2 changes: 1 addition & 1 deletion common/channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish = false
edition = "2018"

[dependencies]
futures = { version = "=0.3.0-alpha.17", package = "futures-preview" }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview" }
lazy_static = "1.3.0"
logger = { path = "../logger" }
metrics = { path = "../metrics" }
Expand Down
5 changes: 4 additions & 1 deletion common/channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ impl<T> Sender<T> {
}
}

impl<T> FusedStream for Receiver<T> {
impl<T> FusedStream for Receiver<T>
where
T: std::fmt::Debug,
{
fn is_terminated(&self) -> bool {
self.inner.is_terminated()
}
Expand Down
2 changes: 1 addition & 1 deletion common/futures-semaphore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[dependencies]
futures01 = { version = "0.1.28", package = "futures" }
futures03 = { version = "=0.3.0-alpha.17", package = "futures-preview", features = ["async-await", "nightly", "compat"] }
futures03 = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["async-await", "compat"] }
tokio-sync = "0.1.6"

[dev-dependencies]
Expand Down
2 changes: 0 additions & 2 deletions common/futures-semaphore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
//! could potentially deadlock the futures runtime if enough tasks are waiting on
//! the semaphore.
#![feature(async_await)]

use futures01::{future::Future as Future01, Async as Async01, Poll as Poll01};
use futures03::compat::Future01CompatExt;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion common/grpc_helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[dependencies]
grpcio = { version = "0.4.4", default-features = false, features = ["protobuf-codec"] }
futures = { version = "0.3.0-alpha.17", package = "futures-preview", features = ["compat"] }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["compat"] }
futures_01 = { version = "0.1.28", package = "futures" }

failure = { package = "failure_ext", path = "../failure_ext" }
Expand Down
1 change: 0 additions & 1 deletion common/logger/src/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,4 @@ mod tests {
r#"{"event":"TestError","error":"Error","data":["SampleData { i: 255, s: [144, 205, 128] }","\"second_payload\""],"backtrace":null}"#,
);
}

}
2 changes: 1 addition & 1 deletion consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"
[dependencies]
byteorder = { version = "1.3.2", default-features = false }
bytes = "0.4.12"
futures = { version = "=0.3.0-alpha.17", package = "futures-preview", features = ["io-compat", "compat"] }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["io-compat", "compat"] }
grpcio = { version = "0.4.4", default-features = false }
lazy_static = { version = "1.3.0", default-features = false }
mirai-annotations = { version = "1.4.0", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#![cfg_attr(not(feature = "fuzzing"), deny(missing_docs))]
#![cfg_attr(feature = "fuzzing", allow(dead_code))]
#![feature(async_await)]
#![recursion_limit = "512"]
extern crate failure;

Expand Down
2 changes: 1 addition & 1 deletion execution/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"
[dependencies]
backoff = { version = "0.1.5", default-features = false }
config_builder = { path = "../../config/config_builder" }
futures = { version = "=0.3.0-alpha.17", package = "futures-preview" }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview" }
itertools = { version = "0.8.0", default-features = false }
lazy_static = { version = "1.3.0", default-features = false }
rusty-fork = { version = "0.2.2", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion libra_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ crash_handler = { path = "../common/crash_handler" }
debug_interface = { path = "../common/debug_interface" }
executable_helpers = { path = "../common/executable_helpers" }
executor = { path = "../execution/executor" }
futures = { version = "=0.3.0-alpha.17", package = "futures-preview", features = ["async-await", "nightly", "io-compat", "compat"] }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["async-await", "io-compat", "compat"] }
grpc_helpers = { path = "../common/grpc_helpers" }
logger = { path = "../common/logger" }
mempool = { path = "../mempool" }
Expand Down
4 changes: 2 additions & 2 deletions libra_swarm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn main() {
.expect("Failed to launch full node swarm");
}

let validator_config = NodeConfig::load(&validator_swarm.config.configs[0]).unwrap();;
let validator_config = NodeConfig::load(&validator_swarm.config.configs[0]).unwrap();
let validator_set_file = validator_swarm
.dir
.as_ref()
Expand All @@ -103,7 +103,7 @@ fn main() {
faucet_key_file_path,
);
if let Some(ref swarm) = full_node_swarm {
let full_node_config = NodeConfig::load(&swarm.config.configs[0]).unwrap();;
let full_node_config = NodeConfig::load(&swarm.config.configs[0]).unwrap();
println!("To connect to the full nodes you just spawned, use this command:");
println!(
"\tcargo run --bin client -- -a localhost -p {} -s {:?} -m {:?}",
Expand Down
2 changes: 1 addition & 1 deletion mempool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"
[dependencies]
chrono = "0.4.7"
futures = "0.1.28"
futures-preview = { version = "=0.3.0-alpha.17", package = "futures-preview", features = ["compat"] }
futures-preview = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["compat"] }
grpcio = { version = "0.4.4", default-features = false, features = ["protobuf-codec"] }
grpcio-sys = "0.4.4"
lazy_static = "1.3.0"
Expand Down
1 change: 0 additions & 1 deletion mempool/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![feature(async_await)]
#![deny(missing_docs)]
//! Mempool is used to hold transactions that have been submitted but not yet agreed upon and
//! executed.
Expand Down
2 changes: 1 addition & 1 deletion network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"

[dependencies]
bytes = "0.4.12"
futures = { version = "=0.3.0-alpha.17", package = "futures-preview", features = ["async-await", "nightly", "io-compat", "compat"] }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["async-await", "io-compat", "compat"] }
lazy_static = "1.3.0"
parity-multiaddr = "0.5.0"
pin-utils = "=0.1.0-alpha.4"
Expand Down
1 change: 0 additions & 1 deletion network/benches/network_bench.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![feature(async_await)]
// Allow KiB, MiB consts
#![allow(non_upper_case_globals, non_snake_case)]
// Allow fns to take &usize, since criterion only passes parameters by ref
Expand Down
1 change: 0 additions & 1 deletion network/benches/socket_muxer_bench.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![feature(async_await)]
// Allow KiB, MiB consts
#![allow(non_upper_case_globals, non_snake_case)]
// Allow fns to take &usize, since criterion only passes parameters by ref
Expand Down
2 changes: 1 addition & 1 deletion network/memsocket/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ edition = "2018"
publish = false

[dependencies]
futures = { version = "=0.3.0-alpha.17", package = "futures-preview" }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview" }
bytes = { version = "0.4.12", default-features = false }
lazy_static = { version = "1.3.0", default-features = false }
3 changes: 0 additions & 3 deletions network/memsocket/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct SwitchBoard(HashMap<NonZeroU16, UnboundedSender<MemorySocket>>, u16);
/// # Examples
///
/// ```rust,no_run
/// #![feature(async_await)]
/// use std::io::Result;
///
/// use memsocket::{MemoryListener, MemorySocket};
Expand Down Expand Up @@ -162,7 +161,6 @@ impl MemoryListener {
/// # Examples
///
/// ```rust,no_run
/// #![feature(async_await)]
/// use futures::prelude::*;
/// use memsocket::MemoryListener;
///
Expand Down Expand Up @@ -224,7 +222,6 @@ impl<'a> Stream for Incoming<'a> {
/// # Examples
///
/// ```rust, no_run
/// #![feature(async_await)]
/// use futures::prelude::*;
/// use memsocket::MemorySocket;
///
Expand Down
2 changes: 1 addition & 1 deletion network/netcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[dependencies]
bytes = { version = "0.4.12", default-features = false }
futures = { version = "=0.3.0-alpha.17", package = "futures-preview", features = ["io-compat", "compat"] }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["io-compat", "compat"] }
futures_01 = { version = "0.1.28", package = "futures" }
parity-multiaddr = { version = "0.5.0", default-features = false }
pin-utils = "=0.1.0-alpha.4"
Expand Down
2 changes: 0 additions & 2 deletions network/netcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//! network from building `Transport`s and `StreamMultiplexer`s to negotiating protocols on a
//! socket.
#![feature(async_await)]

pub mod multiplexing;
pub mod negotiate;
pub mod transport;
Expand Down
2 changes: 1 addition & 1 deletion network/noise/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish = false
edition = "2018"

[dependencies]
futures = { version = "=0.3.0-alpha.17", package = "futures-preview" }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview" }
snow = { version = "0.5.2", features=["ring-accelerated"]}
crypto = { path = "../../crypto/crypto" }
netcore = { path = "../netcore" }
Expand Down
2 changes: 0 additions & 2 deletions network/noise/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![feature(async_await)]

//! [Noise protocol framework][noise] support for use in Libra.
//!
//! The main feature of this module is [`NoiseSocket`](crate::socket::NoiseSocket) which
Expand Down
2 changes: 1 addition & 1 deletion network/socket_bench_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[dependencies]
bytes = { version = "0.4.12", default-features = false }
futures = { version = "=0.3.0-alpha.17", package = "futures-preview", features = ["async-await", "nightly", "io-compat", "compat"] }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["async-await", "io-compat", "compat"] }
futures_01 = { version = "0.1.28", package = "futures" }
parity-multiaddr = "0.5.0"
tokio = { version = "0.1.22", default-features = false }
Expand Down
2 changes: 0 additions & 2 deletions network/socket_bench_server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![feature(async_await)]

use bytes::Bytes;
use futures::{
compat::Sink01CompatExt,
Expand Down
2 changes: 0 additions & 2 deletions network/socket_bench_server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![feature(async_await)]

//! Standalone server for socket_muxer_bench
//! ========================================
//!
Expand Down
3 changes: 0 additions & 3 deletions network/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

// The nightly features that are commonly needed with async / await
// Lets turn these on so that we can experiment a little bit
#![feature(async_await)]
// <Black magic>
// Increase recursion limit to allow for use of select! macro.
#![recursion_limit = "1024"]
Expand Down
1 change: 0 additions & 1 deletion network/src/validator_network/state_synchronizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,4 @@ mod tests {
let event = block_on(stream.next()).unwrap().unwrap();
assert_eq!(event, expected_event);
}

}
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2019-07-08
beta
8 changes: 0 additions & 8 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
comment_width = 100
edition = "2018"
merge_imports = true
use_field_init_shorthand = true
wrap_comments = true

# Ignore generated files.
ignore = [
"language/compiler/src/parser/syntax.rs",
]
5 changes: 5 additions & 0 deletions scripts/clippy.args
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ allowed_lints=(
"-A" "clippy::needless_lifetimes"
# This ends up being platform dependent, e.g. the Instant type
"-A" "clippy::trivially-copy-pass-by-ref"

# Temporarily allow the `clippy::inheret-to-string` lint to avoid having to
# fix all violations in our codebase during the compiler bump to 1.39.0
# beta where it was changed to be on-by-default.
"-A" "clippy::inherent-to-string"
)

echo "${allowed_lints[@]}"
20 changes: 0 additions & 20 deletions scripts/nightly_features.sh

This file was deleted.

2 changes: 1 addition & 1 deletion state_synchronizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish = false
edition = "2018"

[dependencies]
futures = { version = "=0.3.0-alpha.17", package = "futures-preview", features = ["compat"] }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["compat"] }
grpcio = { version = "0.4.4", default-features = false }
lazy_static = { version = "1.3.0", default-features = false }
rand = "0.6.5"
Expand Down
1 change: 0 additions & 1 deletion state_synchronizer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
//! Used to perform catching up between nodes for committed states.
//! Used for node restarts, network partitions, full node syncs
#![feature(async_await)]
#![recursion_limit = "1024"]
use types::{account_address::AccountAddress, crypto_proxies::LedgerInfoWithSignatures};

Expand Down
2 changes: 1 addition & 1 deletion storage/storage_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish = false
edition = "2018"

[dependencies]
futures = { version = "0.3.0-alpha.17", package = "futures-preview", features = ["compat"] }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["compat"] }
futures_01 = { version = "0.1.28", package = "futures" }
grpcio = { version = "0.4.4", default-features = false, features = ["protobuf-codec"] }
protobuf = "~2.7"
Expand Down
2 changes: 1 addition & 1 deletion storage/storage_service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish = false
edition = "2018"

[dependencies]
futures = { version = "0.3.0-alpha.17", package = "futures-preview", features = ["compat"] }
futures = { version = "=0.3.0-alpha.19", package = "futures-preview", features = ["compat"] }
grpcio = { version = "0.4.4", default-features = false, features = ["protobuf-codec"] }
protobuf = "~2.7"

Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/libratest/smoke_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn setup_env(
tmp_mnemonic_file
.create_as_file()
.expect("could not create temporary mnemonic_file_path");
let config = NodeConfig::load(&swarm.config.configs[0]).unwrap();;
let config = NodeConfig::load(&swarm.config.configs[0]).unwrap();
let validator_set_file = swarm
.dir
.as_ref()
Expand Down Expand Up @@ -295,7 +295,7 @@ fn test_basic_state_synchronization() {
.create_as_file()
.expect("could not create temporary mnemonic_file_path");
let ac_port = swarm.get_validator(node_to_restart).unwrap().ac_port();
let config = NodeConfig::load(&swarm.config.configs[0]).unwrap();;
let config = NodeConfig::load(&swarm.config.configs[0]).unwrap();
let validator_set_file = swarm
.dir
.as_ref()
Expand Down
1 change: 0 additions & 1 deletion vm_validator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![feature(async_await)]
pub mod mocks;
pub mod vm_validator;

0 comments on commit 6020c8f

Please sign in to comment.