From 28a6e356a1859daa014392f2fa428e5312420af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Ver=C5=A1i=C4=87?= Date: Thu, 25 Apr 2024 07:54:42 +0200 Subject: [PATCH] [chore]: format doc comments (#4505) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marin Veršić --- .rustfmt.toml | 6 +-- client/src/http.rs | 29 ++++++----- core/src/block.rs | 19 ++++--- core/src/executor.rs | 21 ++++---- core/src/smartcontracts/isi/triggers/set.rs | 20 ++++---- core/src/smartcontracts/isi/world.rs | 14 ++--- core/src/smartcontracts/wasm.rs | 6 ++- core/src/tx.rs | 3 +- crypto/src/encryption/mod.rs | 6 ++- data_model/derive/src/lib.rs | 45 ++++++++-------- data_model/src/query/predicate.rs | 57 ++++++++++----------- ffi/derive/src/lib.rs | 30 ++++++----- ffi/src/repr_c.rs | 22 ++++---- p2p/src/network.rs | 20 +++++--- primitives/src/unique_vec.rs | 19 +++---- smart_contract/derive/src/lib.rs | 1 - smart_contract/executor/derive/src/lib.rs | 1 - telemetry/derive/src/lib.rs | 2 +- tools/parity_scale_cli/src/main.rs | 1 - tools/swarm/src/util.rs | 31 ++++++----- wasm_builder/src/lib.rs | 6 +-- 21 files changed, 185 insertions(+), 174 deletions(-) diff --git a/.rustfmt.toml b/.rustfmt.toml index 2810f43da2d..0f32415c590 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,5 +1,5 @@ newline_style="Unix" use_field_init_shorthand=true -use_try_shorthand=true -group_imports="StdExternalCrate" # unstable https://github.com/rust-lang/rustfmt/issues/5083 -imports_granularity="Crate" # unstable https://github.com/rust-lang/rustfmt/issues/4991 +format_code_in_doc_comments = true # unstable (https://github.com/rust-lang/rustfmt/issues/3348) +group_imports="StdExternalCrate" # unstable (https://github.com/rust-lang/rustfmt/issues/5083) +imports_granularity="Crate" # unstable (https://github.com/rust-lang/rustfmt/issues/4991) diff --git a/client/src/http.rs b/client/src/http.rs index 9547195da52..d974db4c4f1 100644 --- a/client/src/http.rs +++ b/client/src/http.rs @@ -95,10 +95,7 @@ pub mod ws { /// ```rust /// use eyre::{eyre, Result}; /// use iroha_client::http::{ - /// ws::conn_flow::{ - /// Events as FlowEvents, Init as FlowInit, - /// InitData, - /// }, + /// ws::conn_flow::{Events as FlowEvents, Init as FlowInit, InitData}, /// Method, RequestBuilder, /// }; /// @@ -109,7 +106,12 @@ pub mod ws { /// /// fn init(self) -> InitData { /// InitData::new( - /// R::new(Method::GET, "http://localhost:3000".parse().expect("`localhost` is a valid URL, port `3000` is sensible, `http` is supported")), + /// R::new( + /// Method::GET, + /// "http://localhost:3000".parse().expect( + /// "`localhost` is a valid URL, port `3000` is sensible, `http` is supported", + /// ), + /// ), /// vec![1, 2, 3], /// Events, /// ) @@ -139,39 +141,38 @@ pub mod ws { /// /// ```rust /// use eyre::Result; - /// use url::Url; /// use iroha_client::{ - /// data_model::prelude::EventBox, /// client::events_api::flow as events_api_flow, + /// data_model::prelude::EventBox, /// http::{ /// ws::conn_flow::{Events, Init, InitData}, - /// RequestBuilder, Method + /// Method, RequestBuilder, /// }, /// }; + /// use url::Url; /// /// // Some request builder /// struct MyBuilder; /// /// impl RequestBuilder for MyBuilder { /// fn new(_: Method, url: Url) -> Self { - /// todo!() + /// todo!() /// } /// - /// fn param, V: ?Sized + ToString>(self, _: K, _: &V) -> Self { - /// todo!() + /// fn param, V: ?Sized + ToString>(self, _: K, _: &V) -> Self { + /// todo!() /// } /// /// fn header, V: ?Sized + ToString>(self, _: N, _: &V) -> Self { - /// todo!() + /// todo!() /// } /// /// fn body(self, data: Vec) -> Self { - /// todo!() + /// todo!() /// } /// } /// /// impl MyBuilder { - /// /// fn connect(self) -> MyStream { /// /* ... */ /// MyStream {} diff --git a/core/src/block.rs b/core/src/block.rs index a17f9e759d1..68df8771241 100644 --- a/core/src/block.rs +++ b/core/src/block.rs @@ -370,17 +370,22 @@ mod valid { ) -> Result<(), TransactionValidationError> { let is_genesis = block.header().is_genesis(); - block.transactions() + block + .transactions() // TODO: Unnecessary clone? .cloned() - .try_for_each(|TransactionValue{value, error}| { + .try_for_each(|TransactionValue { value, error }| { let transaction_executor = state_block.transaction_executor(); let limits = &transaction_executor.transaction_limits; let tx = if is_genesis { - AcceptedTransaction::accept_genesis(GenesisTransaction(value), expected_chain_id, genesis_public_key) + AcceptedTransaction::accept_genesis( + GenesisTransaction(value), + expected_chain_id, + genesis_public_key, + ) } else { - AcceptedTransaction::accept(value, expected_chain_id, limits) + AcceptedTransaction::accept(value, expected_chain_id, limits) }?; if error.is_some() { @@ -389,9 +394,9 @@ mod valid { Ok(_) => Err(TransactionValidationError::RejectedIsValid), }?; } else { - transaction_executor.validate(tx, state_block).map_err(|(_tx, error)| { - TransactionValidationError::NotValid(error) - })?; + transaction_executor + .validate(tx, state_block) + .map_err(|(_tx, error)| TransactionValidationError::NotValid(error))?; } Ok(()) diff --git a/core/src/executor.rs b/core/src/executor.rs index 2f760b1aea7..50a632e54ec 100644 --- a/core/src/executor.rs +++ b/core/src/executor.rs @@ -156,9 +156,9 @@ impl Executor { Self::UserProvided(UserProvidedExecutor(loaded_executor)) => { let runtime = wasm::RuntimeBuilder::::new() - .with_engine(state_transaction.engine.clone()) // Cloning engine is cheap, see [`wasmtime::Engine`] docs - .with_config(state_transaction.config.executor_runtime) - .build()?; + .with_engine(state_transaction.engine.clone()) // Cloning engine is cheap, see [`wasmtime::Engine`] docs + .with_config(state_transaction.config.executor_runtime) + .build()?; runtime.execute_executor_validate_transaction( state_transaction, @@ -192,9 +192,9 @@ impl Executor { Self::UserProvided(UserProvidedExecutor(loaded_executor)) => { let runtime = wasm::RuntimeBuilder::::new() - .with_engine(state_transaction.engine.clone()) // Cloning engine is cheap, see [`wasmtime::Engine`] docs - .with_config(state_transaction.config.executor_runtime) - .build()?; + .with_engine(state_transaction.engine.clone()) // Cloning engine is cheap, see [`wasmtime::Engine`] docs + .with_config(state_transaction.config.executor_runtime) + .build()?; runtime.execute_executor_validate_instruction( state_transaction, @@ -224,10 +224,11 @@ impl Executor { match self { Self::Initial => Ok(()), Self::UserProvided(UserProvidedExecutor(loaded_executor)) => { - let runtime = wasm::RuntimeBuilder::>::new() - .with_engine(state_ro.engine().clone()) // Cloning engine is cheap, see [`wasmtime::Engine`] docs - .with_config(state_ro.config().executor_runtime) - .build()?; + let runtime = + wasm::RuntimeBuilder::>::new() + .with_engine(state_ro.engine().clone()) // Cloning engine is cheap, see [`wasmtime::Engine`] docs + .with_config(state_ro.config().executor_runtime) + .build()?; runtime.execute_executor_validate_query( state_ro, diff --git a/core/src/smartcontracts/isi/triggers/set.rs b/core/src/smartcontracts/isi/triggers/set.rs index 71dd449e711..c5fb3f603aa 100644 --- a/core/src/smartcontracts/isi/triggers/set.rs +++ b/core/src/smartcontracts/isi/triggers/set.rs @@ -703,16 +703,16 @@ impl Set { f: impl Fn(u32) -> Result, ) -> Result<(), ModRepeatsError> { self.inspect_by_id_mut(id, |action| match action.repeats() { - Repeats::Exactly(repeats) => { - let new_repeats = f(*repeats)?; - action.set_repeats(Repeats::Exactly(new_repeats)); - Ok(()) - } - _ => Err(ModRepeatsError::RepeatsOverflow(RepeatsOverflowError)), - }) - .ok_or_else(|| ModRepeatsError::NotFound(id.clone())) - // .flatten() -- unstable - .and_then(std::convert::identity) + Repeats::Exactly(repeats) => { + let new_repeats = f(*repeats)?; + action.set_repeats(Repeats::Exactly(new_repeats)); + Ok(()) + } + _ => Err(ModRepeatsError::RepeatsOverflow(RepeatsOverflowError)), + }) + .ok_or_else(|| ModRepeatsError::NotFound(id.clone())) + // .flatten() -- unstable + .and_then(std::convert::identity) } /// Handle [`DataEvent`]. diff --git a/core/src/smartcontracts/isi/world.rs b/core/src/smartcontracts/isi/world.rs index 30af4f45561..d5439ab0716 100644 --- a/core/src/smartcontracts/isi/world.rs +++ b/core/src/smartcontracts/isi/world.rs @@ -428,13 +428,13 @@ pub mod query { ) -> Result + 'state>, Error> { Ok(Box::new( state_ro - .world() - .roles() - .iter() - .map(|(_, role)| role) - // To me, this should probably be a method, not a field. - .map(Role::id) - .cloned(), + .world() + .roles() + .iter() + .map(|(_, role)| role) + // To me, this should probably be a method, not a field. + .map(Role::id) + .cloned(), )) } } diff --git a/core/src/smartcontracts/wasm.rs b/core/src/smartcontracts/wasm.rs index bb836227aee..c10b17a6069 100644 --- a/core/src/smartcontracts/wasm.rs +++ b/core/src/smartcontracts/wasm.rs @@ -253,7 +253,6 @@ pub(crate) struct SmartContractQueryRequest(pub QueryRequest); /// # Errors /// /// See [`Module::new`] -/// // TODO: Probably we can do some checks here such as searching for entrypoint function pub fn load_module(engine: &Engine, bytes: impl AsRef<[u8]>) -> Result { Module::new(engine, bytes).map_err(Error::ModuleLoading) @@ -854,7 +853,10 @@ impl<'wrld, 'state, 'block, S> // is validated and then it's executed. Here it's validating in both steps. // Add a flag indicating whether smart contract is being validated or executed let authority = state.authority.clone(); - state.state.0.world + state + .state + .0 + .world .executor .clone() // Cloning executor is a cheap operation .validate_instruction(state.state.0, &authority, instruction) diff --git a/core/src/tx.rs b/core/src/tx.rs index 1f9a407638f..070ff3e7d03 100644 --- a/core/src/tx.rs +++ b/core/src/tx.rs @@ -262,7 +262,8 @@ impl TransactionExecutor { let tx: SignedTransaction = tx.into(); let authority = tx.authority().clone(); - state_transaction.world + state_transaction + .world .executor .clone() // Cloning executor is a cheap operation .validate_transaction(state_transaction, &authority, tx) diff --git a/crypto/src/encryption/mod.rs b/crypto/src/encryption/mod.rs index 63be1eab7f2..bc200b7f5b3 100644 --- a/crypto/src/encryption/mod.rs +++ b/crypto/src/encryption/mod.rs @@ -65,13 +65,15 @@ fn random_bytes>() -> Result, Error> { /// # Usage /// /// ``` -/// use iroha_crypto::encryption::{SymmetricEncryptor, ChaCha20Poly1305}; +/// use iroha_crypto::encryption::{ChaCha20Poly1305, SymmetricEncryptor}; /// /// let key: Vec = (0..0x20).collect(); /// let encryptor = SymmetricEncryptor::::new_with_key(&key); /// let aad = b"Using ChaCha20Poly1305 to encrypt data"; /// let message = b"Hidden message"; -/// let ciphertext = encryptor.encrypt_easy(aad.as_ref(), message.as_ref()).unwrap(); +/// let ciphertext = encryptor +/// .encrypt_easy(aad.as_ref(), message.as_ref()) +/// .unwrap(); /// /// let res = encryptor.decrypt_easy(aad.as_ref(), ciphertext.as_slice()); /// assert_eq!(res.unwrap().as_slice(), message); diff --git a/data_model/derive/src/lib.rs b/data_model/derive/src/lib.rs index d98c1f6de1f..c6767957413 100644 --- a/data_model/derive/src/lib.rs +++ b/data_model/derive/src/lib.rs @@ -23,7 +23,7 @@ use proc_macro2::TokenStream; /// #[enum_ref(derive(Encode))] /// pub enum InnerEnum { /// A(u32), -/// B(i32) +/// B(i32), /// } /// /// #[derive(EnumRef)] @@ -51,7 +51,6 @@ use proc_macro2::TokenStream; /// } /// */ /// ``` -/// #[manyhow] #[proc_macro_derive(EnumRef, attributes(enum_ref))] pub fn enum_ref(input: TokenStream) -> Result { @@ -79,13 +78,13 @@ pub fn enum_ref(input: TokenStream) -> Result { /// #[model] /// mod model { /// pub struct DataModel1 { -/// pub item1: u32, -/// item2: u64 +/// pub item1: u32, +/// item2: u64, /// } /// /// pub(crate) struct DataModel2 { -/// pub item1: u32, -/// item2: u64 +/// pub item1: u32, +/// item2: u64, /// } /// } /// @@ -177,8 +176,8 @@ pub fn model_single(input: TokenStream) -> TokenStream { /// The common use-case: /// /// ``` +/// use iroha_data_model::{IdBox, Identifiable}; /// use iroha_data_model_derive::IdEqOrdHash; -/// use iroha_data_model::{Identifiable, IdBox}; /// /// #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] /// struct Id { @@ -237,8 +236,8 @@ pub fn model_single(input: TokenStream) -> TokenStream { /// Manual selection of the identifier field: /// /// ``` +/// use iroha_data_model::{IdBox, Identifiable}; /// use iroha_data_model_derive::IdEqOrdHash; -/// use iroha_data_model::{Identifiable, IdBox}; /// /// #[derive(Debug, IdEqOrdHash)] /// struct InnerStruct { @@ -275,7 +274,6 @@ pub fn model_single(input: TokenStream) -> TokenStream { /// name: u32, /// } /// ``` -/// #[manyhow] #[proc_macro_derive(IdEqOrdHash, attributes(id, opaque))] pub fn id_eq_ord_hash(input: TokenStream) -> TokenStream { @@ -292,8 +290,8 @@ pub fn id_eq_ord_hash(input: TokenStream) -> TokenStream { /// Derive `::serde::Serialize` trait for `enum` with possibility to avoid tags for selected variants /// /// ``` -/// use serde::Serialize; /// use iroha_data_model_derive::PartiallyTaggedSerialize; +/// use serde::Serialize; /// /// #[derive(PartiallyTaggedSerialize)] /// enum Outer { @@ -308,11 +306,13 @@ pub fn id_eq_ord_hash(input: TokenStream) -> TokenStream { /// } /// /// assert_eq!( -/// &serde_json::to_string(&Outer::Inner(Inner::B(42))).expect("Failed to serialize"), r#"{"B":42}"# +/// &serde_json::to_string(&Outer::Inner(Inner::B(42))).expect("Failed to serialize"), +/// r#"{"B":42}"# /// ); /// /// assert_eq!( -/// &serde_json::to_string(&Outer::A(42)).expect("Failed to serialize"), r#"{"A":42}"# +/// &serde_json::to_string(&Outer::A(42)).expect("Failed to serialize"), +/// r#"{"A":42}"# /// ); /// ``` #[manyhow] @@ -326,10 +326,11 @@ pub fn partially_tagged_serialize_derive(input: TokenStream) -> Result Result(r#"{"B":42}"#).expect("Failed to deserialize B"), Outer::Inner(Inner::B(42)) +/// serde_json::from_str::(r#"{"B":42}"#).expect("Failed to deserialize B"), +/// Outer::Inner(Inner::B(42)) /// ); /// /// assert_eq!( -/// serde_json::from_str::(r#"{"A":42}"#).expect("Failed to deserialize A"), Outer::A(42) +/// serde_json::from_str::(r#"{"A":42}"#).expect("Failed to deserialize A"), +/// Outer::A(42) /// ); /// ``` /// @@ -408,9 +411,8 @@ pub fn partially_tagged_deserialize_derive(input: TokenStream) -> Result Result) where Self: PartialEq + Clone, @@ -89,48 +88,48 @@ where /// /// #[derive(Clone, PartialEq)] /// enum Check { - /// Good, - /// // Encapsulates reason for badness which - /// // doesn't behave associatively - /// // (but if we ignore it, Check as a whole does) - /// Bad(String), + /// Good, + /// // Encapsulates reason for badness which + /// // doesn't behave associatively + /// // (but if we ignore it, Check as a whole does) + /// Bad(String), /// } /// /// impl core::ops::Not for Check { - /// type Output = Self; - /// fn not(self) -> Self { - /// // ... - /// todo!() - /// } + /// type Output = Self; + /// fn not(self) -> Self { + /// // ... + /// todo!() + /// } /// } /// /// impl PredicateSymbol for Check { - /// fn and(self, other: Self) -> ControlFlow { - /// // ... - /// todo!() - /// } + /// fn and(self, other: Self) -> ControlFlow { + /// // ... + /// todo!() + /// } /// - /// fn or(self, other: Self) -> ControlFlow { - /// // ... - /// todo!() - /// } + /// fn or(self, other: Self) -> ControlFlow { + /// // ... + /// todo!() + /// } /// } /// /// fn shallow_eq(left: &Check, right: &Check) -> bool { - /// match (left, right) { - /// (Check::Good, Check::Good) | (Check::Bad(_), Check::Bad(_)) => true, - /// _ => false - /// } + /// match (left, right) { + /// (Check::Good, Check::Good) | (Check::Bad(_), Check::Bad(_)) => true, + /// _ => false, + /// } /// } /// /// fn test() { - /// let good = Check::Good; - /// let bad = Check::Bad("example".to_owned()); - /// // Would fail some assertions, since derived PartialEq is "deep" - /// // PredicateSymbol::test_conformity(vec![good, bad]); + /// let good = Check::Good; + /// let bad = Check::Bad("example".to_owned()); + /// // Would fail some assertions, since derived PartialEq is "deep" + /// // PredicateSymbol::test_conformity(vec![good, bad]); /// - /// // Works as expected - /// PredicateSymbol::test_conformity_with_eq(vec![good, bad], shallow_eq); + /// // Works as expected + /// PredicateSymbol::test_conformity_with_eq(vec![good, bad], shallow_eq); /// } /// ``` fn test_conformity_with_eq(values: Vec, shallow_eq: impl FnMut(&Self, &Self) -> bool) diff --git a/ffi/derive/src/lib.rs b/ffi/derive/src/lib.rs index 195c15ec0aa..3166d2b6444 100644 --- a/ffi/derive/src/lib.rs +++ b/ffi/derive/src/lib.rs @@ -233,8 +233,7 @@ pub fn ffi_type_derive(input: TokenStream) -> TokenStream { /// /// // For a struct such as: /// #[iroha_ffi::ffi_export] -/// #[derive(iroha_ffi::FfiType)] -/// #[derive(Clone, Getters)] +/// #[derive(iroha_ffi::FfiType, Clone, Getters)] /// #[getset(get = "pub")] /// pub struct Foo { /// /// Id of the struct @@ -247,7 +246,10 @@ pub fn ffi_type_derive(input: TokenStream) -> TokenStream { /// impl Foo { /// /// Construct new type /// pub fn new(id: u8) -> Self { -/// Self {id, bar: Vec::new()} +/// Self { +/// id, +/// bar: Vec::new(), +/// } /// } /// /// Return bar /// pub fn bar(&self) -> &[u8] { @@ -392,17 +394,17 @@ pub fn ffi_export(attr: TokenStream, item: TokenStream) -> TokenStream { /// ```rust /// #[iroha_ffi::ffi_import] /// pub fn return_first_elem_from_arr(arr: [u8; 8]) -> u8 { -/// // The body of this function is replaced with something like the following: -/// // let mut store = Default::default(); -/// // let arr = iroha_ffi::FfiConvert::into_ffi(arr, &mut store); -/// // let output = MaybeUninit::uninit(); -/// // -/// // let call_res = __return_first_elem_from_arr(arr, output.as_mut_ptr()); -/// // if iroha_ffi::FfiReturn::Ok != call_res { -/// // panic!("Function call failed"); -/// // } -/// // -/// // iroha_ffi::FfiOutPtrRead::try_read_out(output.assume_init()).expect("Invalid type") +/// // The body of this function is replaced with something like the following: +/// // let mut store = Default::default(); +/// // let arr = iroha_ffi::FfiConvert::into_ffi(arr, &mut store); +/// // let output = MaybeUninit::uninit(); +/// // +/// // let call_res = __return_first_elem_from_arr(arr, output.as_mut_ptr()); +/// // if iroha_ffi::FfiReturn::Ok != call_res { +/// // panic!("Function call failed"); +/// // } +/// // +/// // iroha_ffi::FfiOutPtrRead::try_read_out(output.assume_init()).expect("Invalid type") /// } /// /// /* The following functions will be declared: diff --git a/ffi/src/repr_c.rs b/ffi/src/repr_c.rs index 7421c12cb7b..cacded81b37 100644 --- a/ffi/src/repr_c.rs +++ b/ffi/src/repr_c.rs @@ -1062,12 +1062,11 @@ impl<'slice, R: Clone> CTypeConvert<'slice, &'slice [Opaque], RefSlice<*const R> *store = source .iter() .map(|item| { - item - .as_ref() - // NOTE: This function clones every opaque pointer in the slice. This could - // be avoided with the entire slice being opaque, if that even makes sense. - .cloned() - .ok_or(FfiReturn::ArgIsNull) + item.as_ref() + // NOTE: This function clones every opaque pointer in the slice. This could + // be avoided with the entire slice being opaque, if that even makes sense. + .cloned() + .ok_or(FfiReturn::ArgIsNull) }) .collect::>()?; @@ -1109,12 +1108,11 @@ impl<'slice, R: Clone> CTypeConvert<'slice, &mut [Opaque], RefMutSlice<*mut R>> *store = source .iter() .map(|item| { - item - .as_mut() - // NOTE: This function clones every opaque pointer in the slice. This could - // be avoided with the entire slice being opaque, if that even makes sense. - .cloned() - .ok_or(FfiReturn::ArgIsNull) + item.as_mut() + // NOTE: This function clones every opaque pointer in the slice. This could + // be avoided with the entire slice being opaque, if that even makes sense. + .cloned() + .ok_or(FfiReturn::ArgIsNull) }) .collect::>()?; diff --git a/p2p/src/network.rs b/p2p/src/network.rs index ab781dcd626..ec7a3429220 100644 --- a/p2p/src/network.rs +++ b/p2p/src/network.rs @@ -309,18 +309,24 @@ impl NetworkBase { } fn update_topology(&mut self) { - let to_connect = self.current_topology + let to_connect = self + .current_topology .iter() // Peer is not connected but should - .filter_map(|(peer, is_active)| ( - !self.peers.contains_key(&peer.public_key) - && !self.connecting_peers.values().any(|public_key| peer.public_key() == public_key) - && *is_active - ).then_some(peer)) + .filter_map(|(peer, is_active)| { + (!self.peers.contains_key(&peer.public_key) + && !self + .connecting_peers + .values() + .any(|public_key| peer.public_key() == public_key) + && *is_active) + .then_some(peer) + }) .cloned() .collect::>(); - let to_disconnect = self.peers + let to_disconnect = self + .peers .keys() // Peer is connected but shouldn't .filter(|public_key| !self.current_topology.contains_key(*public_key)) diff --git a/primitives/src/unique_vec.rs b/primitives/src/unique_vec.rs index 2fa03d69ce0..0eb1ea5aa26 100644 --- a/primitives/src/unique_vec.rs +++ b/primitives/src/unique_vec.rs @@ -150,8 +150,8 @@ impl<'de, T: PartialEq + Deserialize<'de>> UniqueVec { /// # Example /// /// ``` - /// use serde::{Deserialize, de::Error as _}; /// use iroha_primitives::unique_vec::UniqueVec; + /// use serde::{de::Error as _, Deserialize}; /// /// #[derive(Debug, PartialEq, Deserialize)] /// pub struct Config { @@ -160,10 +160,7 @@ impl<'de, T: PartialEq + Deserialize<'de>> UniqueVec { /// } /// /// let err = serde_json::from_str::(r#"{"numbers": [1, 2, 3, 2, 4, 5]}"#).unwrap_err(); - /// assert_eq!( - /// err.to_string(), - /// "Duplicated value at line 1 column 25", - /// ); + /// assert_eq!(err.to_string(), "Duplicated value at line 1 column 25",); /// ``` pub fn deserialize_failing_on_duplicates(deserializer: D) -> Result where @@ -189,8 +186,8 @@ impl<'de, T: Debug + PartialEq + Deserialize<'de>> UniqueVec { /// # Example /// /// ``` - /// use serde::{Deserialize, de::Error as _}; /// use iroha_primitives::unique_vec::UniqueVec; + /// use serde::{de::Error as _, Deserialize}; /// /// #[derive(Debug, PartialEq, Deserialize)] /// pub struct Config { @@ -198,7 +195,8 @@ impl<'de, T: Debug + PartialEq + Deserialize<'de>> UniqueVec { /// arrays: UniqueVec>, /// } /// - /// let err = serde_json::from_str::(r#"{"arrays": [[1, 2, 3], [9, 8], [1, 2, 3]]}"#).unwrap_err(); + /// let err = serde_json::from_str::(r#"{"arrays": [[1, 2, 3], [9, 8], [1, 2, 3]]}"#) + /// .unwrap_err(); /// assert_eq!( /// err.to_string(), /// "Duplicated value `[1, 2, 3]` at line 1 column 41", @@ -228,8 +226,8 @@ impl<'de, T: Display + PartialEq + Deserialize<'de>> UniqueVec { /// # Example /// /// ``` - /// use serde::{Deserialize, de::Error as _}; /// use iroha_primitives::unique_vec::UniqueVec; + /// use serde::{de::Error as _, Deserialize}; /// /// #[derive(Debug, PartialEq, Deserialize)] /// pub struct Config { @@ -238,10 +236,7 @@ impl<'de, T: Display + PartialEq + Deserialize<'de>> UniqueVec { /// } /// /// let err = serde_json::from_str::(r#"{"numbers": [1, 2, 3, 2, 4, 5]}"#).unwrap_err(); - /// assert_eq!( - /// err.to_string(), - /// "Duplicated value `2` at line 1 column 25", - /// ); + /// assert_eq!(err.to_string(), "Duplicated value `2` at line 1 column 25",); /// ``` pub fn display_deserialize_failing_on_duplicates(deserializer: D) -> Result where diff --git a/smart_contract/derive/src/lib.rs b/smart_contract/derive/src/lib.rs index ca6b1789cd5..1e6a19e10b1 100644 --- a/smart_contract/derive/src/lib.rs +++ b/smart_contract/derive/src/lib.rs @@ -15,7 +15,6 @@ mod entrypoint; /// - If function has a return type /// /// # Examples -/// // `ignore` because this macro idiomatically should be imported from `iroha_wasm` crate. // /// Using without parameters: diff --git a/smart_contract/executor/derive/src/lib.rs b/smart_contract/executor/derive/src/lib.rs index 59beda04b12..713e099e810 100644 --- a/smart_contract/executor/derive/src/lib.rs +++ b/smart_contract/executor/derive/src/lib.rs @@ -324,7 +324,6 @@ pub fn derive_visit(input: TokenStream) -> TokenStream { /// block_height: u64, /// host: smart_contract::Host, /// } -/// /// ``` #[manyhow] #[proc_macro_derive(ValidateEntrypoints, attributes(entrypoints))] diff --git a/telemetry/derive/src/lib.rs b/telemetry/derive/src/lib.rs index 21f1d5bcbaf..ae41e9f6e5c 100644 --- a/telemetry/derive/src/lib.rs +++ b/telemetry/derive/src/lib.rs @@ -142,7 +142,7 @@ impl ToTokens for MetricSpec { /// # Examples /// /// ```rust -/// use iroha_core::state::{World, StateTransaction}; +/// use iroha_core::state::{StateTransaction, World}; /// use iroha_telemetry_derive::metrics; /// /// #[metrics(+"test_query", "another_test_query_without_timing")] diff --git a/tools/parity_scale_cli/src/main.rs b/tools/parity_scale_cli/src/main.rs index abe04675b8f..3f14c549f84 100644 --- a/tools/parity_scale_cli/src/main.rs +++ b/tools/parity_scale_cli/src/main.rs @@ -219,7 +219,6 @@ impl<'map> ScaleToRustDecoder<'map> { } /// Try to decode every type from `bytes` and print to `writer` - /// // TODO: Can be parallelized when there will be too many types fn decode_by_guess(&self, bytes: &[u8], writer: &mut W) -> Result<()> { let count = self diff --git a/tools/swarm/src/util.rs b/tools/swarm/src/util.rs index 4855577df8d..4805aedc084 100644 --- a/tools/swarm/src/util.rs +++ b/tools/swarm/src/util.rs @@ -54,22 +54,21 @@ impl AbsolutePath { /// Relative path from self to other. pub fn relative_to(&self, other: &(impl AsRef + ?Sized)) -> color_eyre::Result { pathdiff::diff_paths(self, other) - .ok_or_else(|| { - eyre!( - "failed to build relative path from {} to {}", - other.as_ref().display(), - self.display(), - ) - }) - // docker-compose might not like "test" path, but "./test" instead - .map(|rel| { - if rel.starts_with("..") { - rel - } else { - Path::new("./").join(rel) - - } - }) + .ok_or_else(|| { + eyre!( + "failed to build relative path from {} to {}", + other.as_ref().display(), + self.display(), + ) + }) + // docker-compose might not like "test" path, but "./test" instead + .map(|rel| { + if rel.starts_with("..") { + rel + } else { + Path::new("./").join(rel) + } + }) } } diff --git a/wasm_builder/src/lib.rs b/wasm_builder/src/lib.rs index 8d56caa5f03..d73a5f30379 100644 --- a/wasm_builder/src/lib.rs +++ b/wasm_builder/src/lib.rs @@ -21,8 +21,8 @@ const TOOLCHAIN: &str = "+nightly-2024-04-18"; /// # Example /// /// ```no_run -/// use iroha_wasm_builder::Builder; /// use eyre::Result; +/// use iroha_wasm_builder::Builder; /// /// fn main() -> Result<()> { /// let bytes = Builder::new("relative/path/to/smartcontract/") @@ -372,9 +372,7 @@ fn cargo_command() -> Command { // when running with `-C instrument-coverage` // TODO: Check if there are no problems with that .env_remove("CARGO_ENCODED_RUSTFLAGS") - .args([ - TOOLCHAIN, - ]); + .args([TOOLCHAIN]); cargo }