Fix some nightly warnings (#5093)
ONCE_INIT => Once::new Box<Error> => Box<dyn Error>
This commit is contained in:
parent
440d006ec1
commit
9b54528c8e
|
@ -2,9 +2,9 @@
|
|||
//! `setup()` may be called multiple times.
|
||||
|
||||
use env_logger;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
use std::sync::Once;
|
||||
|
||||
static INIT: Once = ONCE_INIT;
|
||||
static INIT: Once = Once::new();
|
||||
|
||||
/// Setup function that is only run once, even if called multiple times.
|
||||
pub fn setup() {
|
||||
|
|
|
@ -62,7 +62,7 @@ macro_rules! inc_new_counter {
|
|||
if log_enabled!($level) {
|
||||
static mut INC_NEW_COUNTER: $crate::counter::Counter =
|
||||
create_counter!($name, $lograte, $metricsrate);
|
||||
static INIT_HOOK: std::sync::Once = std::sync::ONCE_INIT;
|
||||
static INIT_HOOK: std::sync::Once = std::sync::Once::new();
|
||||
unsafe {
|
||||
INIT_HOOK.call_once(|| {
|
||||
INC_NEW_COUNTER.init();
|
||||
|
@ -197,11 +197,11 @@ mod tests {
|
|||
use serial_test_derive::serial;
|
||||
use std::env;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::{Once, RwLock, ONCE_INIT};
|
||||
use std::sync::{Once, RwLock};
|
||||
|
||||
fn get_env_lock() -> &'static RwLock<()> {
|
||||
static mut ENV_LOCK: Option<RwLock<()>> = None;
|
||||
static INIT_HOOK: Once = ONCE_INIT;
|
||||
static INIT_HOOK: Once = Once::new();
|
||||
|
||||
unsafe {
|
||||
INIT_HOOK.call_once(|| {
|
||||
|
|
|
@ -8,7 +8,7 @@ use solana_sdk::hash::hash;
|
|||
use solana_sdk::timing;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
|
||||
use std::sync::{Arc, Barrier, Mutex, Once, ONCE_INIT};
|
||||
use std::sync::{Arc, Barrier, Mutex, Once};
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{cmp, env};
|
||||
|
@ -379,7 +379,7 @@ impl Drop for MetricsAgent {
|
|||
}
|
||||
|
||||
fn get_singleton_agent() -> Arc<Mutex<MetricsAgent>> {
|
||||
static INIT: Once = ONCE_INIT;
|
||||
static INIT: Once = Once::new();
|
||||
static mut AGENT: Option<Arc<Mutex<MetricsAgent>>> = None;
|
||||
unsafe {
|
||||
INIT.call_once(|| AGENT = Some(Arc::new(Mutex::new(MetricsAgent::default()))));
|
||||
|
@ -430,7 +430,7 @@ pub fn flush() {
|
|||
/// Hook the panic handler to generate a data point on each panic
|
||||
pub fn set_panic_hook(program: &'static str) {
|
||||
use std::panic;
|
||||
static SET_HOOK: Once = ONCE_INIT;
|
||||
static SET_HOOK: Once = Once::new();
|
||||
SET_HOOK.call_once(|| {
|
||||
let default_hook = panic::take_hook();
|
||||
panic::set_hook(Box::new(move |ono| {
|
||||
|
|
|
@ -69,7 +69,7 @@ impl fmt::Display for Pubkey {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn write_pubkey(outfile: &str, pubkey: Pubkey) -> Result<(), Box<error::Error>> {
|
||||
pub fn write_pubkey(outfile: &str, pubkey: Pubkey) -> Result<(), Box<dyn error::Error>> {
|
||||
let printable = format!("{}", pubkey);
|
||||
let serialized = serde_json::to_string(&printable)?;
|
||||
|
||||
|
@ -82,7 +82,7 @@ pub fn write_pubkey(outfile: &str, pubkey: Pubkey) -> Result<(), Box<error::Erro
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn read_pubkey(infile: &str) -> Result<Pubkey, Box<error::Error>> {
|
||||
pub fn read_pubkey(infile: &str) -> Result<Pubkey, Box<dyn error::Error>> {
|
||||
let f = File::open(infile.to_string())?;
|
||||
let printable: String = serde_json::from_reader(f)?;
|
||||
Ok(Pubkey::from_str(&printable)?)
|
||||
|
@ -166,7 +166,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_read_write_pubkey() -> Result<(), Box<error::Error>> {
|
||||
fn test_read_write_pubkey() -> Result<(), Box<dyn error::Error>> {
|
||||
let filename = "test_pubkey.json";
|
||||
let pubkey = Pubkey::new_rand();
|
||||
write_pubkey(filename, pubkey)?;
|
||||
|
|
|
@ -118,7 +118,7 @@ impl KeypairUtil for Keypair {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn read_keypair(path: &str) -> Result<Keypair, Box<error::Error>> {
|
||||
pub fn read_keypair(path: &str) -> Result<Keypair, Box<dyn error::Error>> {
|
||||
let file = File::open(path.to_string())?;
|
||||
let bytes: Vec<u8> = serde_json::from_reader(file)?;
|
||||
let keypair = Keypair::from_bytes(&bytes)
|
||||
|
@ -126,7 +126,7 @@ pub fn read_keypair(path: &str) -> Result<Keypair, Box<error::Error>> {
|
|||
Ok(keypair)
|
||||
}
|
||||
|
||||
pub fn gen_keypair_file(outfile: &str) -> Result<String, Box<error::Error>> {
|
||||
pub fn gen_keypair_file(outfile: &str) -> Result<String, Box<dyn error::Error>> {
|
||||
let keypair_bytes = Keypair::new().to_bytes();
|
||||
let serialized = serde_json::to_string(&keypair_bytes.to_vec())?;
|
||||
|
||||
|
|
Loading…
Reference in New Issue