Skip to content

Commit

Permalink
[rust] bump compiler to nightly-2019-07-08
Browse files Browse the repository at this point in the history
Biggest change in this compiler bump is that bare trait objects are
depricated and now produce a warning. All of the problamatic sites have
been updated except our generated protos which now have
`#![allow(bare_trait_objects)]` attributes in all proto modules. These
should be removed once the crate used to generate the protos has been
updated to account for the depracation.
  • Loading branch information
bmwill authored and calibra-opensource committed Jul 8, 2019
1 parent 2861149 commit ff407e0
Show file tree
Hide file tree
Showing 42 changed files with 72 additions and 61 deletions.
2 changes: 2 additions & 0 deletions admission_control/admission_control_proto/src/proto/mod.rs
@@ -1,6 +1,8 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![allow(bare_trait_objects)]

use mempool::proto::shared::mempool_status;
use types::proto::*;

Expand Down
6 changes: 3 additions & 3 deletions benchmark/src/lib.rs
Expand Up @@ -219,7 +219,7 @@ impl Benchmarker {
program: Program,
sender_account: &mut AccountData,
) -> Result<SubmitTransactionRequest> {
let signer: Box<&TransactionSigner> = match &sender_account.key_pair {
let signer: Box<&dyn TransactionSigner> = match &sender_account.key_pair {
Some(key_pair) => Box::new(key_pair),
None => Box::new(&self.wallet),
};
Expand Down Expand Up @@ -376,8 +376,8 @@ impl Benchmarker {
}
}
}
for i in 0..result.len() {
info!("{}th chunk with {} requests", i, &(*result[i]).len());
for (i, result) in result.iter().enumerate() {
info!("{}th chunk with {} requests", i, result.len());
}
result
}
Expand Down
4 changes: 2 additions & 2 deletions client/libra_wallet/src/error.rs
Expand Up @@ -23,7 +23,7 @@ impl Error for WalletError {
}
}

fn cause(&self) -> Option<&Error> {
fn cause(&self) -> Option<&dyn Error> {
match *self {
WalletError::LibraWalletGeneric(_) => None,
}
Expand All @@ -40,7 +40,7 @@ impl fmt::Display for WalletError {

impl fmt::Debug for WalletError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(self as &fmt::Display).fmt(f)
(self as &dyn fmt::Display).fmt(f)
}
}

Expand Down
4 changes: 2 additions & 2 deletions client/src/client_proxy.rs
Expand Up @@ -460,7 +460,7 @@ impl ClientProxy {
let signer_account = self.accounts.get(signer_account_ref_id).ok_or_else(|| {
format_err!("Unable to find sender account: {}", signer_account_ref_id)
})?;
let signer: Box<&TransactionSigner> = match &signer_account.key_pair {
let signer: Box<&dyn TransactionSigner> = match &signer_account.key_pair {
Some(key_pair) => Box::new(key_pair),
None => Box::new(&self.wallet),
};
Expand Down Expand Up @@ -907,7 +907,7 @@ impl ClientProxy {
max_gas_amount: Option<u64>,
gas_unit_price: Option<u64>,
) -> Result<SubmitTransactionRequest> {
let signer: Box<&TransactionSigner> = match &sender_account.key_pair {
let signer: Box<&dyn TransactionSigner> = match &sender_account.key_pair {
Some(key_pair) => Box::new(key_pair),
None => Box::new(&self.wallet),
};
Expand Down
2 changes: 2 additions & 0 deletions common/debug_interface/src/proto/mod.rs
@@ -1,5 +1,7 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![allow(bare_trait_objects)]

pub mod node_debug_interface;
pub mod node_debug_interface_grpc;
2 changes: 1 addition & 1 deletion common/logger/src/http_local_slog_drain.rs
Expand Up @@ -46,7 +46,7 @@ impl HttpLocalSlogDrain {
pub fn new(client: HttpLogClient) -> Self {
HttpLocalSlogDrain { client }
}
fn log_impl(&self, record: &Record, values: &OwnedKVList) -> Result<(), Box<Error>> {
fn log_impl(&self, record: &Record, values: &OwnedKVList) -> Result<(), Box<dyn Error>> {
let mut serializer = PlainKVSerializer::new();
values.serialize(record, &mut serializer)?;
record.kv().serialize(record, &mut serializer)?;
Expand Down
2 changes: 2 additions & 0 deletions common/proto_conv/tests/proto/mod.rs
@@ -1,4 +1,6 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![allow(bare_trait_objects)]

pub mod test;
4 changes: 2 additions & 2 deletions consensus/src/chained_bft/block_storage/block_store.rs
Expand Up @@ -57,7 +57,7 @@ pub enum NeedFetchResult {
pub struct BlockStore<T> {
inner: Arc<RwLock<BlockTree<T>>>,
validator_signer: ValidatorSigner,
state_computer: Arc<StateComputer<Payload = T>>,
state_computer: Arc<dyn StateComputer<Payload = T>>,
enforce_increasing_timestamps: bool,
/// The persistent storage backing up the in-memory data structure, every write should go
/// through this before in-memory tree.
Expand All @@ -69,7 +69,7 @@ impl<T: Payload> BlockStore<T> {
storage: Arc<dyn PersistentStorage<T>>,
initial_data: RecoveryData<T>,
validator_signer: ValidatorSigner,
state_computer: Arc<StateComputer<Payload = T>>,
state_computer: Arc<dyn StateComputer<Payload = T>>,
enforce_increasing_timestamps: bool,
max_pruned_blocks_in_mem: usize,
) -> Self {
Expand Down
5 changes: 1 addition & 4 deletions consensus/src/chained_bft/event_processor.rs
Expand Up @@ -624,7 +624,6 @@ impl<T: Payload, P: ProposerInfo> EventProcessor<T, P> {
.error(VoteReceptionResult::DuplicateVote)
.data(vote)
.log();
return;
}
VoteReceptionResult::NewQuorumCertificate(qc) => {
if self.block_store.need_fetch_for_quorum_cert(&qc) == NeedFetchResult::NeedFetch {
Expand Down Expand Up @@ -652,9 +651,7 @@ impl<T: Payload, P: ProposerInfo> EventProcessor<T, P> {
.await;
}
// nothing interesting with votes arriving for the QC that has been formed
_ => {
return;
}
_ => {}
};
}

Expand Down
2 changes: 1 addition & 1 deletion consensus/src/chained_bft/event_processor_test.rs
Expand Up @@ -97,7 +97,7 @@ impl NodeSetup {
fn create_pacemaker(
executor: TaskExecutor,
time_service: Arc<dyn TimeService>,
) -> (Arc<Pacemaker>, channel::Receiver<NewRoundEvent>) {
) -> (Arc<dyn Pacemaker>, channel::Receiver<NewRoundEvent>) {
let base_timeout = Duration::new(60, 0);
let time_interval = Box::new(ExponentialTimeInterval::fixed(base_timeout));
let highest_certified_round = 0;
Expand Down
6 changes: 3 additions & 3 deletions consensus/src/chained_bft/liveness/local_pacemaker.rs
Expand Up @@ -110,7 +110,7 @@ impl PacemakerTimeInterval for ExponentialTimeInterval {
/// QC to f+1 other replicas for instance.
struct LocalPacemakerInner {
// Determines the time interval for a round interval
time_interval: Box<PacemakerTimeInterval>,
time_interval: Box<dyn PacemakerTimeInterval>,
// Highest round that a block was committed
highest_committed_round: Round,
// Highest round known certified by QC.
Expand All @@ -137,7 +137,7 @@ struct LocalPacemakerInner {
impl LocalPacemakerInner {
pub fn new(
persistent_liveness_storage: Box<dyn PersistentLivenessStorage>,
time_interval: Box<PacemakerTimeInterval>,
time_interval: Box<dyn PacemakerTimeInterval>,
highest_committed_round: Round,
highest_qc_round: Round,
time_service: Arc<dyn TimeService>,
Expand Down Expand Up @@ -337,7 +337,7 @@ impl LocalPacemaker {
pub fn new(
executor: TaskExecutor,
persistent_liveness_storage: Box<dyn PersistentLivenessStorage>,
time_interval: Box<PacemakerTimeInterval>,
time_interval: Box<dyn PacemakerTimeInterval>,
highest_committed_round: Round,
highest_qc_round: Round,
time_service: Arc<dyn TimeService>,
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/chained_bft/liveness/proposal_generator.rs
Expand Up @@ -68,7 +68,7 @@ pub struct ProposalGenerator<T> {
impl<T: Payload> ProposalGenerator<T> {
pub fn new(
block_store: Arc<dyn BlockReader<Payload = T> + Send + Sync>,
txn_manager: Arc<TxnManager<Payload = T>>,
txn_manager: Arc<dyn TxnManager<Payload = T>>,
time_service: Arc<dyn TimeService>,
max_block_size: u64,
enforce_increasing_timestamps: bool,
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/chained_bft/persistent_storage.rs
Expand Up @@ -365,7 +365,7 @@ impl<T: Payload> PersistentStorage<T> for StorageWriteProxy {
)
.unwrap_or_else(|e| panic!("Can not construct recovery data due to {}", e));

<PersistentStorage<T>>::prune_tree(proxy.as_ref(), initial_data.take_blocks_to_prune())
<dyn PersistentStorage<T>>::prune_tree(proxy.as_ref(), initial_data.take_blocks_to_prune())
.expect("unable to prune dangling blocks during restart");

debug!("Consensus root to start with: {}", initial_data.root.0);
Expand Down
Expand Up @@ -46,7 +46,7 @@ impl StateComputer for MockStateComputer {
fn commit(
&self,
commit: LedgerInfoWithSignatures,
) -> Pin<Box<Future<Output = Result<()>> + Send>> {
) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> {
self.commit_callback
.unbounded_send(commit)
.expect("Fail to notify about commit.");
Expand Down
4 changes: 2 additions & 2 deletions consensus/src/chained_bft/test_utils/mock_storage.rs
Expand Up @@ -98,7 +98,7 @@ impl<T: Payload> PersistentLivenessStorage for MockStorage<T> {

// A impl that always start from genesis.
impl<T: Payload> PersistentStorage<T> for MockStorage<T> {
fn persistent_liveness_storage(&self) -> Box<PersistentLivenessStorage> {
fn persistent_liveness_storage(&self) -> Box<dyn PersistentLivenessStorage> {
Box::new(MockStorage {
shared_storage: Arc::clone(&self.shared_storage),
})
Expand Down Expand Up @@ -182,7 +182,7 @@ impl PersistentLivenessStorage for EmptyStorage {
}

impl<T: Payload> PersistentStorage<T> for EmptyStorage {
fn persistent_liveness_storage(&self) -> Box<PersistentLivenessStorage> {
fn persistent_liveness_storage(&self) -> Box<dyn PersistentLivenessStorage> {
Box::new(EmptyStorage)
}

Expand Down
2 changes: 1 addition & 1 deletion consensus/src/state_synchronizer/sync_test.rs
Expand Up @@ -57,7 +57,7 @@ impl SynchronizerEnv {
}

fn new_with(
handler: Box<Fn() -> Result<TransactionListWithProof> + Send + 'static>,
handler: Box<dyn Fn() -> Result<TransactionListWithProof> + Send + 'static>,
opt_config: Option<NodeConfig>,
) -> Self {
let mut runtime = test_utils::consensus_runtime();
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/state_synchronizer/synchronizer.rs
Expand Up @@ -28,7 +28,7 @@ use types::transaction::TransactionListWithProof;
/// Used for synchronization between validators for committed states
pub struct StateSynchronizer {
synchronizer_to_coordinator: mpsc::UnboundedSender<CoordinatorMsg>,
storage_read_client: Arc<StorageRead>,
storage_read_client: Arc<dyn StorageRead>,
}

impl StateSynchronizer {
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/time_service.rs
Expand Up @@ -159,7 +159,7 @@ pub enum WaitingError {
/// There are 4 potential outcomes, 2 successful and 2 errors, each represented by
/// WaitingSuccess and WaitingError.
pub async fn wait_if_possible(
time_service: &TimeService,
time_service: &dyn TimeService,
min_duration_since_epoch: Duration,
max_instant: Instant,
) -> Result<WaitingSuccess, WaitingError> {
Expand Down
1 change: 1 addition & 0 deletions crypto/secret_service/src/proto/mod.rs
@@ -1,6 +1,7 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![allow(bare_trait_objects)]
#![allow(missing_docs)]
// use types::proto::*;
pub mod secret_service;
Expand Down
2 changes: 2 additions & 0 deletions execution/execution_proto/src/proto/mod.rs
@@ -1,6 +1,8 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![allow(bare_trait_objects)]

use types::proto::*;

pub mod execution;
Expand Down
2 changes: 1 addition & 1 deletion language/functional_tests/Cargo.toml
Expand Up @@ -17,6 +17,6 @@ config = { path = "../../config" }
transaction_builder = { path = "../transaction_builder" }
termcolor = "1.0.4"
filecheck = "0.4.0"
datatest = "0.3.1"
datatest = "0.3.5"
lazy_static = "1.3.0"
regex = "1.1.6"
7 changes: 5 additions & 2 deletions language/tools/cost_synthesis/src/global_state/inhabitor.rs
Expand Up @@ -33,7 +33,7 @@ where

/// The module cache for all of the other modules in the universe. We need this in order to
/// resolve struct and function handles to other modules other then the root module.
module_cache: &'txn ModuleCache<'alloc>,
module_cache: &'txn dyn ModuleCache<'alloc>,

/// A reverse lookup table to find the struct definition for a struct handle. Needed for
/// generating an inhabitant for a struct SignatureToken. This is lazily populated.
Expand All @@ -48,7 +48,10 @@ where
///
/// It initializes each of the internal resolution tables for structs and function handles to
/// be empty.
pub fn new(root_module: &'txn LoadedModule, module_cache: &'txn ModuleCache<'alloc>) -> Self {
pub fn new(
root_module: &'txn LoadedModule,
module_cache: &'txn dyn ModuleCache<'alloc>,
) -> Self {
let seed: [u8; 32] = [0; 32];
Self {
gen: StdRng::from_seed(seed),
Expand Down
4 changes: 2 additions & 2 deletions language/tools/cost_synthesis/src/stack_generator.rs
Expand Up @@ -96,7 +96,7 @@ where

/// The module cache for all of the other modules in the universe. We need this in order to
/// resolve struct and function handles to other modules other then the root module.
module_cache: &'txn ModuleCache<'alloc>,
module_cache: &'txn dyn ModuleCache<'alloc>,

/// The bytecode instruction for which stack states are generated.
op: Bytecode,
Expand Down Expand Up @@ -134,7 +134,7 @@ where
pub fn new(
account_address: &'txn AccountAddress,
root_module: &'txn LoadedModule,
module_cache: &'txn ModuleCache<'alloc>,
module_cache: &'txn dyn ModuleCache<'alloc>,
op: &Bytecode,
max_stack_size: u64,
iters: u16,
Expand Down
2 changes: 1 addition & 1 deletion language/vm/src/deserializer.rs
Expand Up @@ -118,7 +118,7 @@ fn check_binary(cursor: &mut Cursor<&[u8]>) -> BinaryLoaderResult<u8> {
if let Ok(count) = cursor.read_u8() {
Ok(count)
} else {
return Err(BinaryError::Malformed);
Err(BinaryError::Malformed)
}
}

Expand Down
1 change: 0 additions & 1 deletion language/vm/src/lib.rs
Expand Up @@ -3,7 +3,6 @@

#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(type_alias_enum_variants)]

#[macro_use]
extern crate mirai_annotations;
Expand Down
4 changes: 2 additions & 2 deletions language/vm/vm_runtime/src/data_cache.rs
Expand Up @@ -85,11 +85,11 @@ pub struct TransactionDataCache<'txn> {
// case moving forward, so we need to review this.
// Also need to relate this to a ResourceKey.
data_map: BTreeMap<AccessPath, GlobalRef>,
data_cache: &'txn RemoteCache,
data_cache: &'txn dyn RemoteCache,
}

impl<'txn> TransactionDataCache<'txn> {
pub fn new(data_cache: &'txn RemoteCache) -> Self {
pub fn new(data_cache: &'txn dyn RemoteCache) -> Self {
TransactionDataCache {
data_cache,
data_map: BTreeMap::new(),
Expand Down
4 changes: 2 additions & 2 deletions language/vm/vm_runtime/src/process_txn/mod.rs
Expand Up @@ -23,7 +23,7 @@ where
{
txn: SignatureCheckedTransaction,
module_cache: P,
data_cache: &'txn RemoteCache,
data_cache: &'txn dyn RemoteCache,
allocator: &'txn Arena<LoadedModule>,
phantom: PhantomData<&'alloc ()>,
}
Expand All @@ -37,7 +37,7 @@ where
pub fn new(
txn: SignatureCheckedTransaction,
module_cache: P,
data_cache: &'txn RemoteCache,
data_cache: &'txn dyn RemoteCache,
allocator: &'txn Arena<LoadedModule>,
) -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion language/vm/vm_runtime/src/process_txn/validate.rs
Expand Up @@ -292,7 +292,7 @@ where
fn new(
metadata: TransactionMetadata,
module_cache: P,
data_cache: &'txn RemoteCache,
data_cache: &'txn dyn RemoteCache,
allocator: &'txn Arena<LoadedModule>,
) -> Self {
// This temporary cache is used for modules published by a single transaction.
Expand Down
4 changes: 2 additions & 2 deletions language/vm/vm_runtime/src/txn_executor.rs
Expand Up @@ -98,7 +98,7 @@ where
/// transactions within the same block.
pub fn new(
module_cache: P,
data_cache: &'txn RemoteCache,
data_cache: &'txn dyn RemoteCache,
txn_data: TransactionMetadata,
) -> Self {
TransactionExecutor {
Expand Down Expand Up @@ -816,7 +816,7 @@ pub fn execute_function(
caller_script: VerifiedScript,
modules: Vec<VerifiedModule>,
_args: Vec<TransactionArgument>,
data_cache: &RemoteCache,
data_cache: &dyn RemoteCache,
) -> VMResult<()> {
let allocator = Arena::new();
let module_cache = VMModuleCache::new(&allocator);
Expand Down
1 change: 1 addition & 0 deletions mempool/src/proto/mod.rs
@@ -1,6 +1,7 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

#![allow(bare_trait_objects)]
#![allow(missing_docs)]
use crate::proto::shared::*;
use types::proto::*;
Expand Down
6 changes: 3 additions & 3 deletions network/netcore/src/negotiate/mod.rs
Expand Up @@ -17,6 +17,6 @@ pub use self::{
outbound::{negotiate_outbound_interactive, negotiate_outbound_select},
};

static PROTOCOL_INTERACTIVE: &'static [u8] = b"/libra/protocol-interactive/1.0.0";
static PROTOCOL_SELECT: &'static [u8] = b"/libra/protocol-select/1.0.0";
static PROTOCOL_NOT_SUPPORTED: &'static [u8] = b"not supported";
static PROTOCOL_INTERACTIVE: &[u8] = b"/libra/protocol-interactive/1.0.0";
static PROTOCOL_SELECT: &[u8] = b"/libra/protocol-select/1.0.0";
static PROTOCOL_NOT_SUPPORTED: &[u8] = b"not supported";

0 comments on commit ff407e0

Please sign in to comment.