Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid clippy bug #534

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ NODE_BRANCH="next"

# --- Linting -------------------------------------------------------------------------------------

## TODO: Remove '--allow clippy::needless_return' once rust-clippy issue #13458 is fixed

.PHONY: clippy
clippy: ## Run Clippy with configs
cargo +nightly clippy --workspace --exclude miden-client-web --all-targets $(FEATURES_CLI) -- -D warnings
cargo +nightly clippy --workspace --exclude miden-client-web --all-targets $(FEATURES_CLI) -- -D warnings --allow clippy::needless_return

.PHONY: clippy-wasm
clippy-wasm: ## Run Clippy for the miden-client-web package
cargo +nightly clippy --package miden-client-web --target wasm32-unknown-unknown --all-targets $(FEATURES_WEB_CLIENT) -- -D warnings
cargo +nightly clippy --package miden-client-web --target wasm32-unknown-unknown --all-targets $(FEATURES_WEB_CLIENT) -- -D warnings --allow clippy::needless_return

.PHONY: fix
fix: ## Run Fix with configs
Expand Down
8 changes: 4 additions & 4 deletions crates/rust-client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ fn compile_tonic_client_proto(proto_dir: &Path) -> miette::Result<()> {
.file_descriptor_set_path(&file_descriptor_path)
.skip_protoc_run()
.out_dir(WEB_TONIC_CLIENT_PROTO_OUT_DIR)
.compile_with_config(web_tonic_prost_config, protos, includes)
.compile_protos_with_config(web_tonic_prost_config, protos, includes)
.into_diagnostic()?;

tonic_build::configure()
.build_server(false)
.file_descriptor_set_path(&file_descriptor_path)
.skip_protoc_run()
.out_dir(TONIC_CLIENT_PROTO_OUT_DIR)
.compile_with_config(prost_config, protos, includes)
.compile_protos_with_config(prost_config, protos, includes)
.into_diagnostic()?;

Ok(())
Expand All @@ -86,11 +86,11 @@ fn generate_known_script_roots() -> std::io::Result<()> {
// Get the output directory from the environment variables
let out_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("src/notes/script_roots.rs");
println!("{:?}", dest_path);

let mut f = File::create(&dest_path)?;
// Write the top-level doc comment
writeln!(f, "//! Well-known note script roots.")?;
writeln!(f, "/// This file was generated by build.rs.\n")?;
writeln!(f, "//! This file was generated by build.rs.\n")?;

writeln!(f, "/// Script root of the P2ID note script")?;
writeln!(f, "pub const P2ID: &str = \"{}\";\n", p2id().hash())?;
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-client/src/notes/script_roots.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Well-known note script roots.
/// This file was generated by build.rs.
// This file was generated by build.rs.

/// Script root of the P2ID note script
pub const P2ID: &str = "0xc491aa07f9a0da9838de1ae841ea7dc8d45cd5641f74a89faeb2ff8fa8cf801b";
Expand Down
38 changes: 17 additions & 21 deletions crates/rust-client/src/rpc/tonic_client/generated/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// This file is @generated by prost-build.
/// Generated client implementations.
pub mod api_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -97,8 +103,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -121,8 +126,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -148,8 +152,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -174,8 +177,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -201,8 +203,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -225,8 +226,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -250,8 +250,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -274,8 +273,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -299,8 +297,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -321,8 +318,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand Down
38 changes: 17 additions & 21 deletions crates/rust-client/src/rpc/web_tonic_client/generated/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// This file is @generated by prost-build.
/// Generated client implementations.
pub mod api_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -86,8 +92,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -110,8 +115,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -137,8 +141,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -163,8 +166,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -190,8 +192,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -214,8 +215,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -239,8 +239,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -263,8 +262,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -288,8 +286,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand All @@ -310,8 +307,7 @@ pub mod api_client {
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
Expand Down
1 change: 1 addition & 0 deletions crates/rust-client/src/tests.rs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the --allow clippy::needless_return I don't think it's necessary to remove the semicolons.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-added it

Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ async fn test_import_note_validation() {
})
.await
.unwrap();

assert!(expected_note.inclusion_proof().is_none());
assert!(committed_note.inclusion_proof().is_some());
}