diff --git a/Cargo.toml b/Cargo.toml index f1e82af249e..228caded553 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -128,9 +128,9 @@ mv = { version = "0.1.0" } [workspace.lints] rustdoc.private_doc_tests = "deny" -rust.future_incompatible = {level = "deny", priority = -1 } -rust.nonstandard_style = {level = "deny", priority = -1 } -rust.rust_2018_idioms = {level = "deny", priority = -1 } +rust.future_incompatible = { level = "deny", priority = -1 } +rust.nonstandard_style = { level = "deny", priority = -1 } +rust.rust_2018_idioms = { level = "deny", priority = -1 } rust.unused = { level = "deny", priority = -1 } rust.anonymous_parameters = "deny" @@ -149,6 +149,12 @@ rust.single_use_lifetimes = "warn" rust.unused_lifetimes = "warn" # TODO: reenable # rust.unsafe_op_in_unsafe_fn = "deny" +rust.unexpected_cfgs = { level = "warn", check-cfg = [ + # FIXME: https://github.com/hyperledger/iroha/issues/3102 + 'cfg(feature, values("ffi_import"))', + # It is set by `cargo-llvm-cov` + 'cfg(coverage)' +] } # pedantic clippy.pedantic = { level = "warn", priority = -1 } diff --git a/crates/iroha_crypto/src/lib.rs b/crates/iroha_crypto/src/lib.rs index 6c15aa8ad2e..939c707d3a4 100755 --- a/crates/iroha_crypto/src/lib.rs +++ b/crates/iroha_crypto/src/lib.rs @@ -995,7 +995,6 @@ mod ffi { } // NOTE: Makes sure that only one `dealloc` is exported per generated dynamic library - #[cfg(any(crate_type = "dylib", crate_type = "cdylib"))] #[cfg(all(feature = "ffi_export", not(feature = "ffi_import")))] mod dylib { #[cfg(not(feature = "std"))] diff --git a/crates/iroha_data_model/src/lib.rs b/crates/iroha_data_model/src/lib.rs index b0f296f2845..a74a339f478 100644 --- a/crates/iroha_data_model/src/lib.rs +++ b/crates/iroha_data_model/src/lib.rs @@ -468,7 +468,6 @@ mod ffi { } // NOTE: Makes sure that only one `dealloc` is exported per generated dynamic library - #[cfg(any(crate_type = "dylib", crate_type = "cdylib"))] #[cfg(all(feature = "ffi_export", not(feature = "ffi_import")))] mod dylib { #[cfg(not(feature = "std"))] diff --git a/crates/iroha_telemetry/Cargo.toml b/crates/iroha_telemetry/Cargo.toml index 0688b839cf7..99dea48ec01 100644 --- a/crates/iroha_telemetry/Cargo.toml +++ b/crates/iroha_telemetry/Cargo.toml @@ -15,7 +15,7 @@ workspace = true # Should not be enabled on production builds. dev-telemetry = [] # Export Prometheus metrics. See https://prometheus.io/. -metric-instrumentation = [] +metric-instrumentation = ["iroha_telemetry_derive/metric-instrumentation"] [dependencies] iroha_telemetry_derive = { path = "../iroha_telemetry_derive" } diff --git a/crates/iroha_telemetry_derive/Cargo.toml b/crates/iroha_telemetry_derive/Cargo.toml index 3a4f7e9fe21..be453c38274 100644 --- a/crates/iroha_telemetry_derive/Cargo.toml +++ b/crates/iroha_telemetry_derive/Cargo.toml @@ -18,6 +18,10 @@ is-it-maintained-issue-resolution = { repository = "https://github.com/hyperledg is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/iroha" } maintenance = { status = "actively-developed" } +[features] +# FIXME: it doesn't work https://github.com/hyperledger/iroha/issues/5134 +metric-instrumentation = [] + [dependencies] syn = { workspace = true } quote = { workspace = true } diff --git a/crates/iroha_telemetry_derive/src/lib.rs b/crates/iroha_telemetry_derive/src/lib.rs index 15c434f4598..d5febea0894 100644 --- a/crates/iroha_telemetry_derive/src/lib.rs +++ b/crates/iroha_telemetry_derive/src/lib.rs @@ -1,6 +1,9 @@ //! Attribute-like macro for instrumenting `isi` for `prometheus` //! metrics. See [`macro@metrics`] for more details. +// FIXME +#![allow(unused)] + use iroha_macro_utils::Emitter; use manyhow::{emit, manyhow, Result}; use proc_macro2::TokenStream; @@ -181,12 +184,16 @@ pub fn metrics(attr: TokenStream, item: TokenStream) -> TokenStream { return emitter.finish_token_stream(); }; - let result = impl_metrics(&mut emitter, &metric_specs, &func); + let result = impl_metrics(&mut emitter, metric_specs, &func); emitter.finish_token_stream_with(result) } -fn impl_metrics(emitter: &mut Emitter, _specs: &MetricSpecs, func: &syn::ItemFn) -> TokenStream { +fn impl_metrics( + emitter: &mut Emitter, + #[cfg_attr(not(feature = "metric-instrumentation"), allow(unused))] specs: MetricSpecs, + func: &syn::ItemFn, +) -> TokenStream { let syn::ItemFn { attrs, vis, @@ -224,7 +231,8 @@ fn impl_metrics(emitter: &mut Emitter, _specs: &MetricSpecs, func: &syn::ItemFn) // Again this may seem fragile, but if we move the metrics from // the `WorldStateView`, we'd need to refactor many things anyway - let _metric_arg_ident = match arg_metrics(&sig.inputs) { + #[cfg_attr(not(feature = "metric-instrumentation"), allow(unused_variables))] + let metric_arg_ident = match arg_metrics(&sig.inputs) { Ok(ident) => ident, Err(args) => { emit!( @@ -236,34 +244,34 @@ fn impl_metrics(emitter: &mut Emitter, _specs: &MetricSpecs, func: &syn::ItemFn) } }; - #[cfg(feature = "metric-instrumentation")] - let res = { - let (totals, successes, times) = write_metrics(_metric_arg_ident, _specs); - quote!( - #(#attrs)* #vis #sig { - let _closure = || #block; - let started_at = std::time::Instant::now(); - - #totals - let res = _closure(); - - #times - if let Ok(_) = res { - #successes - }; - res - }); - }; + // #[cfg(feature = "metric-instrumentation")] + // { + // let (totals, successes, times) = write_metrics(metric_arg_ident, specs); + // quote!( + // #(#attrs)* #vis #sig { + // let closure = || #block; + // let started_at = std::time::Instant::now(); + // + // #totals + // let res = closure(); + // + // #times + // if let Ok(_) = res { + // #successes + // }; + // res + // }) + // } - #[cfg(not(feature = "metric-instrumentation"))] - let res = quote!( + // #[cfg(not(feature = "metric-instrumentation"))] + quote!( #(#attrs)* #vis #sig { #block } - ); - res + ) } +// FIXME: metrics were removed https://github.com/hyperledger/iroha/issues/5134 #[cfg(feature = "metric-instrumentation")] fn write_metrics( metric_arg_ident: proc_macro2::Ident, diff --git a/wasm_samples/default_executor/src/lib.rs b/wasm_samples/default_executor/src/lib.rs index 4e3d4a282d2..738ad185fa4 100644 --- a/wasm_samples/default_executor/src/lib.rs +++ b/wasm_samples/default_executor/src/lib.rs @@ -2,7 +2,6 @@ #![no_std] -extern crate alloc; #[cfg(not(test))] extern crate panic_halt; diff --git a/wasm_samples/executor_with_migration_fail/src/lib.rs b/wasm_samples/executor_with_migration_fail/src/lib.rs index 6417ccff63c..1bab3082384 100644 --- a/wasm_samples/executor_with_migration_fail/src/lib.rs +++ b/wasm_samples/executor_with_migration_fail/src/lib.rs @@ -2,7 +2,6 @@ #![no_std] -extern crate alloc; #[cfg(not(test))] extern crate panic_halt; diff --git a/wasm_samples/query_assets_and_save_cursor/src/lib.rs b/wasm_samples/query_assets_and_save_cursor/src/lib.rs index 7026bdf506a..d7a8784680d 100644 --- a/wasm_samples/query_assets_and_save_cursor/src/lib.rs +++ b/wasm_samples/query_assets_and_save_cursor/src/lib.rs @@ -5,8 +5,6 @@ #[cfg(not(test))] extern crate panic_halt; -extern crate alloc; - use dlmalloc::GlobalDlmalloc; use iroha_smart_contract::{ data_model::query::{