Skip to content

Commit ad2e833

Browse files
committed
fix(store-encryption): Remove the displaydoc dep.
This patch removes the `displaydoc` dependency. Why? 1. It creates a warning in rustc nightly: ``` warning: non-local `impl` definition, they should be avoided as they go against expectation --> crates/matrix-sdk-store-encryption/src/lib.rs:49:17 | 49 | #[derive(Debug, Display, thiserror::Error)] | ^^^^^^^ | = help: move this `impl` block outside the of the current constant `_DERIVE_Display_FOR_Error` = note: an `impl` definition is non-local if it is nested inside an item and may impact type checking outside of that item. This can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <rust-lang/rust#120363> = note: the derive macro `Display` may come from an old version of the `displaydoc` crate, try updating your dependency with `cargo update -p displaydoc` = note: `#[warn(non_local_definitions)]` on by default = note: this warning originates in the derive macro `Display` (in Nightly builds, run with -Z macro-backtrace for more info) ``` 2. `thiserror` is already used, which seems to provide a similar issue. 3. That's less dependency, and less proc-macro, which will improve the compilation time in general.
1 parent a3f6e0f commit ad2e833

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

Cargo.lock

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/matrix-sdk-store-encryption/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ js = ["dep:getrandom", "getrandom?/js"]
1717
base64 = { workspace = true }
1818
blake3 = "1.5.0"
1919
chacha20poly1305 = { version = "0.10.1", features = ["std"] }
20-
displaydoc = "0.2.4"
2120
getrandom = { version = "0.2.10", optional = true }
2221
hmac = "0.12.1"
2322
pbkdf2 = "0.12.2"

crates/matrix-sdk-store-encryption/src/lib.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use chacha20poly1305::{
2828
aead::{Aead, Error as EncryptionError},
2929
Key as ChachaKey, KeyInit, XChaCha20Poly1305, XNonce,
3030
};
31-
use displaydoc::Display;
3231
use hmac::Hmac;
3332
use pbkdf2::pbkdf2;
3433
use rand::{thread_rng, Error as RandomError, Fill};
@@ -46,26 +45,39 @@ const BASE64: GeneralPurpose = GeneralPurpose::new(&alphabet::STANDARD, general_
4645
type MacKeySeed = [u8; 32];
4746

4847
/// Error type for the `StoreCipher` operations.
49-
#[derive(Debug, Display, thiserror::Error)]
48+
#[derive(Debug, thiserror::Error)]
5049
pub enum Error {
51-
/// Failed to serialize a value {0}
50+
/// Failed to serialize a value.
51+
#[error("Failed to serialize a value: `{0}`")]
5252
Serialization(#[from] rmp_serde::encode::Error),
53-
/// Failed to deserialize a value {0}
53+
54+
/// Failed to deserialize a value.
55+
#[error("Failed to deserialize a value: `{0}`")]
5456
Deserialization(#[from] rmp_serde::decode::Error),
55-
/// Failed to deserialize or serialize a JSON value {0}
57+
58+
/// Failed to deserialize or serialize a JSON value.
59+
#[error("Failed to deserialize or serialize a JSON value: `{0}`")]
5660
Json(#[from] serde_json::Error),
57-
/// Error encrypting or decrypting a value {0}
61+
62+
/// Error encrypting or decrypting a value.
63+
#[error("Error encrypting or decrypting a value: `{0}`")]
5864
Encryption(#[from] EncryptionError),
59-
/// Couldn't generate enough randomness for a cryptographic operation: {0}
65+
66+
/// Could not generate enough randomness for a cryptographic operation: {0}
67+
#[error("Could not generate enough randomness for a cryptographic operation: `{0}`")]
6068
Random(#[from] RandomError),
61-
/// Unsupported ciphertext version, expected {0}, got {1}
69+
70+
/// Unsupported ciphertext version.
71+
#[error("Unsupported ciphertext version, expected `{0}`, got `{1}`")]
6272
Version(u8, u8),
63-
/// The ciphertext had an invalid length, expected {0}, got {1}
73+
74+
/// The ciphertext had an invalid length.
75+
#[error("The ciphertext had an invalid length, expected `{0}`, got `{1}`")]
6476
Length(usize, usize),
65-
/**
66-
* Failed to import a store cipher, the export used a passphrase while
67-
* we're trying to import it using a key or vice-versa.
68-
*/
77+
78+
/// Failed to import a store cipher, the export used a passphrase while
79+
/// we are trying to import it using a key or vice-versa.
80+
#[error("Failed to import a store cipher, the export used a passphrase while we are trying to import it using a key or vice-versa")]
6981
KdfMismatch,
7082
}
7183

0 commit comments

Comments
 (0)