From 64a2163958eadfd7ba34cff5716ca4264db55e54 Mon Sep 17 00:00:00 2001 From: Remix7531 <131352678+remix7531@users.noreply.github.com> Date: Wed, 18 Feb 2026 21:35:36 +0100 Subject: [PATCH] digest: add blanket-impls feature to gate blanket Digest impl Add a new `blanket-impls` feature flag (enabled by default) that gates the blanket `impl Digest for D` implementation. This allows downstream crates that provide their own manual `Digest` implementations to disable the blanket impl and avoid coherence conflicts. --- digest/Cargo.toml | 3 ++- digest/src/digest.rs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/digest/Cargo.toml b/digest/Cargo.toml index 305918d9e..1ebb09406 100644 --- a/digest/Cargo.toml +++ b/digest/Cargo.toml @@ -26,9 +26,10 @@ zeroize = { version = "1.7", optional = true, default-features = false } sha2 = "0.11.0-rc.5" [features] -default = ["block-api"] +default = ["block-api", "blanket-impls"] alloc = [] block-api = ["dep:block-buffer"] # Enable block API traits +blanket-impls = [] # Enable blanket implementations of Digest and other traits dev = ["blobby"] getrandom = ["common/getrandom", "rand_core"] mac = ["dep:ctutils"] # Enable MAC traits diff --git a/digest/src/digest.rs b/digest/src/digest.rs index 30cb3d8af..46d5ff873 100644 --- a/digest/src/digest.rs +++ b/digest/src/digest.rs @@ -56,6 +56,7 @@ pub trait Digest: OutputSizeUser { fn digest(data: impl AsRef<[u8]>) -> Output; } +#[cfg(feature = "blanket-impls")] impl Digest for D { #[inline] fn new() -> Self {