fix: Stop using `displaydoc` (#8614)
* Stop using `displaydoc` * Fix comment alignment This commit is unrelated to the solution in this branch. There's a new lint that produces a warning when lists in comments are not aligned well.
This commit is contained in:
parent
8f27d972fa
commit
c6f575319d
14
Cargo.lock
14
Cargo.lock
|
@ -1251,17 +1251,6 @@ dependencies = [
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "displaydoc"
|
|
||||||
version = "0.2.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.66",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "document-features"
|
name = "document-features"
|
||||||
version = "0.2.8"
|
version = "0.2.8"
|
||||||
|
@ -6012,7 +6001,6 @@ dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
"criterion",
|
"criterion",
|
||||||
"displaydoc",
|
|
||||||
"ed25519-zebra",
|
"ed25519-zebra",
|
||||||
"equihash",
|
"equihash",
|
||||||
"futures",
|
"futures",
|
||||||
|
@ -6070,7 +6058,6 @@ dependencies = [
|
||||||
"bls12_381",
|
"bls12_381",
|
||||||
"chrono",
|
"chrono",
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
"displaydoc",
|
|
||||||
"futures",
|
"futures",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"halo2_proofs",
|
"halo2_proofs",
|
||||||
|
@ -6255,7 +6242,6 @@ dependencies = [
|
||||||
name = "zebra-script"
|
name = "zebra-script"
|
||||||
version = "1.0.0-beta.37"
|
version = "1.0.0-beta.37"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"displaydoc",
|
|
||||||
"hex",
|
"hex",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
|
|
@ -107,7 +107,6 @@ chrono = { version = "0.4.38", default-features = false, features = ["clock", "s
|
||||||
humantime = "2.1.0"
|
humantime = "2.1.0"
|
||||||
|
|
||||||
# Error Handling & Formatting
|
# Error Handling & Formatting
|
||||||
displaydoc = "0.2.4"
|
|
||||||
static_assertions = "1.1.0"
|
static_assertions = "1.1.0"
|
||||||
thiserror = "1.0.61"
|
thiserror = "1.0.61"
|
||||||
tracing = "0.1.39"
|
tracing = "0.1.39"
|
||||||
|
|
|
@ -429,8 +429,8 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug, displaydoc::Display, Clone, PartialEq, Eq)]
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
|
#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
|
||||||
/// Errors that can be returned when validating `Amount`s
|
/// Errors that can be returned when validating `Amount`s
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// input {value} is outside of valid range for zatoshi Amount, valid_range={range:?}
|
/// input {value} is outside of valid range for zatoshi Amount, valid_range={range:?}
|
||||||
|
@ -462,6 +462,34 @@ pub enum Error {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Error {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.write_str(&match self {
|
||||||
|
Error::Constraint { value, range } => format!(
|
||||||
|
"input {value} is outside of valid range for zatoshi Amount, valid_range={range:?}"
|
||||||
|
),
|
||||||
|
Error::Convert { value, .. } => {
|
||||||
|
format!("{value} could not be converted to an i64 Amount")
|
||||||
|
}
|
||||||
|
Error::MultiplicationOverflow {
|
||||||
|
amount,
|
||||||
|
multiplier,
|
||||||
|
overflowing_result,
|
||||||
|
} => format!(
|
||||||
|
"overflow when calculating {amount}i64 * {multiplier}u64 = {overflowing_result}i128"
|
||||||
|
),
|
||||||
|
Error::DivideByZero { amount } => format!("cannot divide amount {amount} by zero"),
|
||||||
|
Error::SumOverflow {
|
||||||
|
partial_sum,
|
||||||
|
remaining_items,
|
||||||
|
} => format!(
|
||||||
|
"overflow when summing i64 amounts; \
|
||||||
|
partial sum: {partial_sum}, number of remaining items: {remaining_items}"
|
||||||
|
),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
/// Returns the invalid value for this error.
|
/// Returns the invalid value for this error.
|
||||||
///
|
///
|
||||||
|
|
|
@ -6,6 +6,7 @@ use crate::{
|
||||||
transparent,
|
transparent,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use core::fmt;
|
||||||
use std::{borrow::Borrow, collections::HashMap};
|
use std::{borrow::Borrow, collections::HashMap};
|
||||||
|
|
||||||
#[cfg(any(test, feature = "proptest-impl"))]
|
#[cfg(any(test, feature = "proptest-impl"))]
|
||||||
|
@ -385,7 +386,7 @@ impl ValueBalance<NonNegative> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug, displaydoc::Display, Clone, PartialEq, Eq)]
|
#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
|
||||||
/// Errors that can be returned when validating a [`ValueBalance`]
|
/// Errors that can be returned when validating a [`ValueBalance`]
|
||||||
pub enum ValueBalanceError {
|
pub enum ValueBalanceError {
|
||||||
/// transparent amount error {0}
|
/// transparent amount error {0}
|
||||||
|
@ -401,6 +402,17 @@ pub enum ValueBalanceError {
|
||||||
Orchard(amount::Error),
|
Orchard(amount::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for ValueBalanceError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.write_str(&match self {
|
||||||
|
Transparent(e) => format!("transparent amount err: {e}"),
|
||||||
|
Sprout(e) => format!("sprout amount err: {e}"),
|
||||||
|
Sapling(e) => format!("sapling amount err: {e}"),
|
||||||
|
Orchard(e) => format!("orchard amount err: {e}"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<C> std::ops::Add for ValueBalance<C>
|
impl<C> std::ops::Add for ValueBalance<C>
|
||||||
where
|
where
|
||||||
C: Constraint,
|
C: Constraint,
|
||||||
|
|
|
@ -44,7 +44,6 @@ rand = "0.8.5"
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
|
|
||||||
chrono = { version = "0.4.38", default-features = false, features = ["clock", "std"] }
|
chrono = { version = "0.4.38", default-features = false, features = ["clock", "std"] }
|
||||||
displaydoc = "0.2.4"
|
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
once_cell = "1.18.0"
|
once_cell = "1.18.0"
|
||||||
serde = { version = "1.0.203", features = ["serde_derive"] }
|
serde = { version = "1.0.203", features = ["serde_derive"] }
|
||||||
|
|
|
@ -12,13 +12,13 @@
|
||||||
//! Otherwise, verification of out-of-order and invalid blocks and transactions can hang
|
//! Otherwise, verification of out-of-order and invalid blocks and transactions can hang
|
||||||
//! indefinitely.
|
//! indefinitely.
|
||||||
|
|
||||||
|
use core::fmt;
|
||||||
use std::{
|
use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
};
|
};
|
||||||
|
|
||||||
use displaydoc::Display;
|
|
||||||
use futures::{FutureExt, TryFutureExt};
|
use futures::{FutureExt, TryFutureExt};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tokio::task::JoinHandle;
|
use tokio::task::JoinHandle;
|
||||||
|
@ -91,7 +91,7 @@ where
|
||||||
/// An error while semantically verifying a block.
|
/// An error while semantically verifying a block.
|
||||||
//
|
//
|
||||||
// One or both of these error variants are at least 140 bytes
|
// One or both of these error variants are at least 140 bytes
|
||||||
#[derive(Debug, Display, Error)]
|
#[derive(Debug, Error)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum RouterError {
|
pub enum RouterError {
|
||||||
/// Block could not be checkpointed
|
/// Block could not be checkpointed
|
||||||
|
@ -100,6 +100,19 @@ pub enum RouterError {
|
||||||
Block { source: Box<VerifyBlockError> },
|
Block { source: Box<VerifyBlockError> },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for RouterError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.write_str(&match self {
|
||||||
|
RouterError::Checkpoint { source } => {
|
||||||
|
format!("block could not be checkpointed due to: {source}")
|
||||||
|
}
|
||||||
|
RouterError::Block { source } => {
|
||||||
|
format!("block could not be full-verified due to: {source}")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<VerifyCheckpointError> for RouterError {
|
impl From<VerifyCheckpointError> for RouterError {
|
||||||
fn from(err: VerifyCheckpointError) -> Self {
|
fn from(err: VerifyCheckpointError) -> Self {
|
||||||
RouterError::Checkpoint {
|
RouterError::Checkpoint {
|
||||||
|
|
|
@ -20,7 +20,6 @@ zcash_script = "0.1.15"
|
||||||
zebra-chain = { path = "../zebra-chain", version = "1.0.0-beta.37" }
|
zebra-chain = { path = "../zebra-chain", version = "1.0.0-beta.37" }
|
||||||
|
|
||||||
thiserror = "1.0.61"
|
thiserror = "1.0.61"
|
||||||
displaydoc = "0.2.4"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
// We allow unsafe code, so we can call zcash_script
|
// We allow unsafe code, so we can call zcash_script
|
||||||
#![allow(unsafe_code)]
|
#![allow(unsafe_code)]
|
||||||
|
|
||||||
|
use core::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use displaydoc::Display;
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use zcash_script::{
|
use zcash_script::{
|
||||||
|
@ -22,27 +22,39 @@ use zebra_chain::{
|
||||||
transparent,
|
transparent,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Display, Error, PartialEq, Eq)]
|
|
||||||
#[non_exhaustive]
|
|
||||||
/// An Error type representing the error codes returned from zcash_script.
|
/// An Error type representing the error codes returned from zcash_script.
|
||||||
|
#[derive(Copy, Clone, Debug, Error, PartialEq, Eq)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// script failed to verify
|
/// script verification failed
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
ScriptInvalid,
|
ScriptInvalid,
|
||||||
/// could not to deserialize tx
|
/// could not deserialize tx
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
TxDeserialize,
|
TxDeserialize,
|
||||||
/// input index out of bounds for transaction's inputs
|
/// input index out of bounds
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
TxIndex,
|
TxIndex,
|
||||||
/// tx is an invalid size for it's protocol
|
/// tx has an invalid size
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
TxSizeMismatch,
|
TxSizeMismatch,
|
||||||
/// encountered unknown error kind from zcash_script: {0}
|
/// unknown error from zcash_script: {0}
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
Unknown(zcash_script_error_t),
|
Unknown(zcash_script_error_t),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Error {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.write_str(&match self {
|
||||||
|
Error::ScriptInvalid => "script verification failed".to_owned(),
|
||||||
|
Error::TxDeserialize => "could not deserialize tx".to_owned(),
|
||||||
|
Error::TxIndex => "input index out of bounds".to_owned(),
|
||||||
|
Error::TxSizeMismatch => "tx has an invalid size".to_owned(),
|
||||||
|
Error::Unknown(e) => format!("unknown error from zcash_script: {e}"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<zcash_script_error_t> for Error {
|
impl From<zcash_script_error_t> for Error {
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
fn from(err_code: zcash_script_error_t) -> Error {
|
fn from(err_code: zcash_script_error_t) -> Error {
|
||||||
|
|
|
@ -168,9 +168,9 @@ impl Argument {
|
||||||
///
|
///
|
||||||
/// # Implementation
|
/// # Implementation
|
||||||
///
|
///
|
||||||
/// 1. Generate a list with less than ten random strings. Then proceed by selecting which strings
|
/// 1. Generate a list with less than ten random strings. Then proceed by selecting which
|
||||||
/// will become key value pairs, and generate a new random string for each value that needs to
|
/// strings will become key value pairs, and generate a new random string for each value that
|
||||||
/// be paired to an argument key.
|
/// needs to be paired to an argument key.
|
||||||
pub fn list_strategy() -> impl Strategy<Value = Vec<Argument>> {
|
pub fn list_strategy() -> impl Strategy<Value = Vec<Argument>> {
|
||||||
// Generate a list with less than ten unique random strings.
|
// Generate a list with less than ten unique random strings.
|
||||||
hash_set("\\PC+", 0..10)
|
hash_set("\\PC+", 0..10)
|
||||||
|
|
Loading…
Reference in New Issue