Skip to content

Commit

Permalink
Merge pull request #714 from input-output-hk/jpraynaud/fix-clippy-war…
Browse files Browse the repository at this point in the history
…nings-rust-1.67.0

Fix clippy warnings from Rust `1.67.0`
  • Loading branch information
jpraynaud authored Jan 30, 2023
2 parents 909e141 + 35eadff commit 513e09c
Show file tree
Hide file tree
Showing 70 changed files with 262 additions and 343 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions demo/protocol-demo/src/demonstrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ pub struct Party {
impl Party {
/// Party factory
pub fn new(party_id: usize, stake: u64) -> Self {
println!("Party #{}: party created with {} stakes", party_id, stake);
println!("Party #{party_id}: party created with {stake} stakes");
Self {
party_id: format!("{}", party_id) as ProtocolPartyId,
party_id: format!("{party_id}") as ProtocolPartyId,
stake: stake as ProtocolStake,
params: None,
initializer: None,
Expand Down Expand Up @@ -225,7 +225,7 @@ impl Verifier {

/// Update protocol parameters
pub fn update_params(&mut self, params: &ProtocolParameters) {
println!("Verifier: protocol params updated to {:?}", params);
println!("Verifier: protocol params updated to {params:?}");
self.params = Some(*params);
}

Expand All @@ -242,7 +242,7 @@ impl Verifier {
.iter()
.map(|(party_id, stake, _verification_key)| (party_id.to_owned(), *stake))
.collect::<Vec<_>>();
println!("Verifier: protocol keys registration from {:?}", players);
println!("Verifier: protocol keys registration from {players:?}");

let mut key_reg = ProtocolKeyRegistrationNotCertified::init();
for (_party_id, stake, verification_key) in players_with_keys {
Expand Down Expand Up @@ -404,7 +404,7 @@ impl ProtocolDemonstrator for Demonstrator {
let mut multi_signature_artifacts = Vec::new();
for (i, message) in self.messages.iter().enumerate() {
// Issue certificates
println!("Message #{} to sign: {:?}", i, message);
println!("Message #{i} to sign: {message:?}");
let mut signatures = Vec::<ProtocolSingleSignature>::new();
for party in self.parties.iter_mut() {
if let Some(party_signature) = party.sign_message(message) {
Expand Down Expand Up @@ -465,7 +465,7 @@ impl ProtocolDemonstrator for Demonstrator {

/// Write artifacts helper
pub fn write_artifacts<T: Serialize>(artifact_name: &str, value: &T) {
let artifacts_file_path_name = format!("artifacts/{}.json", artifact_name);
let artifacts_file_path_name = format!("artifacts/{artifact_name}.json");
let artifacts_file_path = env::current_dir()
.unwrap()
.join(path::Path::new(&artifacts_file_path_name));
Expand All @@ -477,7 +477,7 @@ pub fn write_artifacts<T: Serialize>(artifact_name: &str, value: &T) {
serde_json::to_string_pretty(value).unwrap()
)
.unwrap();
println!("Artifacts written to {}", artifacts_file_path_name);
println!("Artifacts written to {artifacts_file_path_name}");
}

#[cfg(test)]
Expand Down
7 changes: 2 additions & 5 deletions demo/protocol-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ pub struct Config {
fn main() {
let config = Config::parse();

println!(
">> Launch Mithril protocol demonstrator with configuration: \n{:#?}",
config
);
println!(">> Launch Mithril protocol demonstrator with configuration: \n{config:#?}");

//////////////////////
// establish phase //
Expand Down Expand Up @@ -68,7 +65,7 @@ fn main() {
println!("\n>> Congrats, protocol terminated with success!\n")
}
Err(err) => {
println!("\n>> Certificate verification failed: {}\n", err)
println!("\n>> Certificate verification failed: {err}\n")
}
}
}
2 changes: 1 addition & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.2.8"
version = "0.2.9"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
24 changes: 12 additions & 12 deletions mithril-aggregator/src/command_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ impl ServeCommand {
config_builder = config_builder.add_source(self.clone());
let config: Configuration = config_builder
.build()
.map_err(|e| format!("configuration build error: {}", e))?
.map_err(|e| format!("configuration build error: {e}"))?
.try_deserialize()
.map_err(|e| format!("configuration deserialize error: {}", e))?;
debug!("SERVE command"; "config" => format!("{:?}", config));
.map_err(|e| format!("configuration deserialize error: {e}"))?;
debug!("SERVE command"; "config" => format!("{config:?}"));
let sqlite_db_path = Some(config.get_sqlite_file());
check_database_migration(config.get_sqlite_file())?;

Expand Down Expand Up @@ -542,10 +542,10 @@ impl ExportGenesisSubCommand {
) -> Result<(), Box<dyn Error>> {
let config: GenesisConfiguration = config_builder
.build()
.map_err(|e| format!("configuration build error: {}", e))?
.map_err(|e| format!("configuration build error: {e}"))?
.try_deserialize()
.map_err(|e| format!("configuration deserialize error: {}", e))?;
debug!("EXPORT GENESIS command"; "config" => format!("{:?}", config));
.map_err(|e| format!("configuration deserialize error: {e}"))?;
debug!("EXPORT GENESIS command"; "config" => format!("{config:?}"));
println!(
"Genesis export payload to sign to {}",
self.target_path.display()
Expand All @@ -571,10 +571,10 @@ impl ImportGenesisSubCommand {
) -> Result<(), Box<dyn Error>> {
let config: GenesisConfiguration = config_builder
.build()
.map_err(|e| format!("configuration build error: {}", e))?
.map_err(|e| format!("configuration build error: {e}"))?
.try_deserialize()
.map_err(|e| format!("configuration deserialize error: {}", e))?;
debug!("IMPORT GENESIS command"; "config" => format!("{:?}", config));
.map_err(|e| format!("configuration deserialize error: {e}"))?;
debug!("IMPORT GENESIS command"; "config" => format!("{config:?}"));
println!(
"Genesis import signed payload from {}",
self.signed_payload_path.to_string_lossy()
Expand Down Expand Up @@ -602,10 +602,10 @@ impl BootstrapGenesisSubCommand {
) -> Result<(), Box<dyn Error>> {
let config: GenesisConfiguration = config_builder
.build()
.map_err(|e| format!("configuration build error: {}", e))?
.map_err(|e| format!("configuration build error: {e}"))?
.try_deserialize()
.map_err(|e| format!("configuration deserialize error: {}", e))?;
debug!("BOOTSTRAP GENESIS command"; "config" => format!("{:?}", config));
.map_err(|e| format!("configuration deserialize error: {e}"))?;
debug!("BOOTSTRAP GENESIS command"; "config" => format!("{config:?}"));
println!("Genesis bootstrap for test only!");
let dependencies = setup_genesis_dependencies(&config)?;

Expand Down
12 changes: 6 additions & 6 deletions mithril-aggregator/src/http_server/routes/certificate_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.reply(&setup_router(Arc::new(dependency_manager)))
.await;

Expand All @@ -143,7 +143,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.reply(&setup_router(Arc::new(dependency_manager)))
.await;

Expand All @@ -164,7 +164,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.reply(&setup_router(Arc::new(dependency_manager)))
.await;

Expand All @@ -191,7 +191,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.reply(&setup_router(Arc::new(dependency_manager)))
.await;

Expand All @@ -213,7 +213,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.reply(&setup_router(Arc::new(dependency_manager)))
.await;

Expand All @@ -240,7 +240,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.reply(&setup_router(Arc::new(dependency_manager)))
.await;

Expand Down
6 changes: 3 additions & 3 deletions mithril-aggregator/src/http_server/routes/epoch_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod handlers {
protocol_parameters,
next_protocol_parameters,
};
println!("EpochSettings={:?}", epoch_settings);
println!("EpochSettings={epoch_settings:?}");
let epoch_settings_message =
ToEpochSettingsMessageAdapter::adapt(epoch_settings);
Ok(reply::json(&epoch_settings_message, StatusCode::OK))
Expand Down Expand Up @@ -116,7 +116,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.reply(&setup_router(Arc::new(dependency_manager)))
.await;

Expand All @@ -137,7 +137,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.reply(&setup_router(Arc::new(dependency_manager)))
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.json(&message)
.reply(&setup_router(Arc::new(dependency_manager)))
.await;
Expand Down Expand Up @@ -132,7 +132,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.json(&message)
.reply(&setup_router(Arc::new(dependency_manager)))
.await;
Expand Down Expand Up @@ -165,7 +165,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.json(&message)
.reply(&setup_router(Arc::new(dependency_manager)))
.await;
Expand Down Expand Up @@ -198,7 +198,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.json(&message)
.reply(&setup_router(Arc::new(dependency_manager)))
.await;
Expand Down
8 changes: 4 additions & 4 deletions mithril-aggregator/src/http_server/routes/signer_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.json(&signer)
.reply(&setup_router(Arc::new(dependency_manager)))
.await;
Expand Down Expand Up @@ -142,7 +142,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.json(&signer)
.reply(&setup_router(Arc::new(dependency_manager)))
.await;
Expand Down Expand Up @@ -176,7 +176,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.json(&signer)
.reply(&setup_router(Arc::new(dependency_manager)))
.await;
Expand Down Expand Up @@ -209,7 +209,7 @@ mod tests {

let response = request()
.method(method)
.path(&format!("/{}{}", SERVER_BASE_PATH, path))
.path(&format!("/{SERVER_BASE_PATH}{path}"))
.json(&signer)
.reply(&setup_router(Arc::new(dependency_manager)))
.await;
Expand Down
Loading

0 comments on commit 513e09c

Please sign in to comment.