Skip to content

make_rng: document panic and add #[track_caller]#1761

Merged
dhardy merged 3 commits intorust-random:masterfrom
maxider:master
Apr 9, 2026
Merged

make_rng: document panic and add #[track_caller]#1761
dhardy merged 3 commits intorust-random:masterfrom
maxider:master

Conversation

@maxider
Copy link
Copy Markdown
Contributor

@maxider maxider commented Apr 8, 2026

  • Added a CHANGELOG.md entry

Summary

Document that make_rng can panic, and add #[track_caller] to improve panic diagnostics.

Motivation

make_rng calls expect on the result of SysRng seeding, but had no # Panics section in its doc comment. This is inconsistent with the rest of the crate where panicking functions document the conditions (e.g. random_range, random_bool, random_ratio), and the #[track_caller] convention established in #1447.

Details

  • Added a # Panics section following the existing crate style
  • Added #[track_caller] so panics point to the call site rather than the expect inside make_rng

Copy link
Copy Markdown
Member

@dhardy dhardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A fair addition.

@dhardy
Copy link
Copy Markdown
Member

dhardy commented Apr 9, 2026

This is inconsistent with the rest of the crate

Except ThreadRng which also doesn't document potential panics.

@dhardy dhardy merged commit 98d0638 into rust-random:master Apr 9, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants