diff --git a/Cargo.lock b/Cargo.lock index 9a654d56bd30f..bb2046afb561f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6491,7 +6491,6 @@ dependencies = [ name = "uv-fastid" version = "0.0.56" dependencies = [ - "fastrand", "rand 0.9.4", "serde", "serde_json", diff --git a/crates/uv-errors/Cargo.toml b/crates/uv-errors/Cargo.toml index 01b9bcfe3544a..0eacf4eaa6459 100644 --- a/crates/uv-errors/Cargo.toml +++ b/crates/uv-errors/Cargo.toml @@ -24,3 +24,6 @@ thiserror = { workspace = true } [lints] workspace = true + +[lib] +doctest = false diff --git a/crates/uv-fastid/Cargo.toml b/crates/uv-fastid/Cargo.toml index 571205a694676..ed177760b66cf 100644 --- a/crates/uv-fastid/Cargo.toml +++ b/crates/uv-fastid/Cargo.toml @@ -14,7 +14,6 @@ doctest = false [dependencies] rand = { workspace = true } -fastrand = { workspace = true } serde = { workspace = true, optional = true } [dev-dependencies] diff --git a/crates/uv-fastid/src/lib.rs b/crates/uv-fastid/src/lib.rs index 105129b3d49d1..4658e0366bc4d 100644 --- a/crates/uv-fastid/src/lib.rs +++ b/crates/uv-fastid/src/lib.rs @@ -24,7 +24,7 @@ impl Deref for Id { #[inline] fn deref(&self) -> &str { - // SAFETY: every `Id` constructor (`secure`, `insecure`, `FromStr`, and + // SAFETY: every `Id` constructor (`secure`, `FromStr`, and // transitively `serde::Deserialize`) guarantees the bytes are drawn from // `ALPHABET`, which is entirely ASCII. The bytes are therefore valid UTF-8. #[allow(unsafe_code)] @@ -85,16 +85,6 @@ impl Id { Self(Self::reduce(&raw)) } - /// Generate an [`Id`] from a fast, non-cryptographically secure RNG. - /// - /// The resulting ID is suitable for use in contexts where uniqueness is needed - /// but the risk of an adversarial collision is negligible (such as local cache keys). - pub fn insecure() -> Self { - let mut raw = [0u8; 16]; - fastrand::fill(&mut raw); - Self(Self::reduce(&raw)) - } - /// Reduce a 16-byte array of random bytes to a 16-byte array of ASCII characters in our ID alphabet. fn reduce(raw: &[u8; 16]) -> [u8; 16] { raw.map(|byte| ALPHABET[(byte & MASK) as usize]) @@ -138,13 +128,6 @@ mod tests { assert!(id.bytes().all(|byte| ALPHABET.contains(&byte))); } - #[test] - fn test_insecure() { - let id = Id::insecure(); - assert_eq!(id.len(), 16); - assert!(id.bytes().all(|byte| ALPHABET.contains(&byte))); - } - #[test] fn test_from_str() { for tc in ["", "short", "0123456789abcdefg", "invalid!"] { @@ -167,11 +150,6 @@ mod tests { let json = serde_json::to_string(&id).unwrap(); let parsed: Id = serde_json::from_str(&json).unwrap(); assert_eq!(id, parsed); - - let id = Id::insecure(); - let json = serde_json::to_string(&id).unwrap(); - let parsed: Id = serde_json::from_str(&json).unwrap(); - assert_eq!(id, parsed); } #[test]