From 2a4addcad018ac85de50d2684a07f2cf9330929d Mon Sep 17 00:00:00 2001 From: Max Weilandt Date: Wed, 8 Apr 2026 21:56:37 +0200 Subject: [PATCH 1/3] Add panic info in docs of rand::make_rng() --- src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index a3ad2a38b8..73b67c69d3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,6 +102,11 @@ use crate::distr::{Distribution, StandardUniform}; /// # let _ = rand::Rng::next_u32(&mut rng); /// ``` /// +/// # Panics +/// +/// If [`SysRng`] fails to obtain entropy from the OS. This is unlikely +/// outside of early boot or unusual system conditions. +/// /// # Security /// /// Refer to [`ThreadRng#Security`]. From 0033d6fa6fc3deca50b99f33c732c7bb96eab006 Mon Sep 17 00:00:00 2001 From: Max Weilandt Date: Wed, 8 Apr 2026 22:04:47 +0200 Subject: [PATCH 2/3] add #[track_caller] macro to rand::make_rng() --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 73b67c69d3..c7b85b94d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -115,6 +115,7 @@ use crate::distr::{Distribution, StandardUniform}; /// [`ThreadRng`]: crate::rngs::ThreadRng /// [`ThreadRng#Security`]: crate::rngs::ThreadRng#security #[cfg(feature = "sys_rng")] +#[track_caller] pub fn make_rng() -> R { #[cfg(feature = "thread_rng")] { From edf6a1b8257246754aee039acda9f39178156ce8 Mon Sep 17 00:00:00 2001 From: Max Weilandt Date: Thu, 9 Apr 2026 00:05:21 +0200 Subject: [PATCH 3/3] add CHANGELOG.md entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c32e4ef14..5e220fcdea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ A [separate changelog is kept for rand_core](https://github.com/rust-random/core You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful. +## [Unreleased] +- Document panic behavior of `make_rng` and add `#[track_caller]` (#1761) + ## [0.10.0] - 2026-02-08 ### Changes