Skip to content

Commit 867ed2e

Browse files
committed
Doc changes for assert macros
See #29381
1 parent c94a9ac commit 867ed2e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/libcore/macros.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ macro_rules! panic {
3535
/// This will invoke the [`panic!`] macro if the provided expression cannot be
3636
/// evaluated to `true` at runtime.
3737
///
38+
/// # Uses
39+
///
3840
/// Assertions are always checked in both debug and release builds, and cannot
3941
/// be disabled. See [`debug_assert!`] for assertions that are not enabled in
4042
/// release builds by default.
@@ -45,7 +47,9 @@ macro_rules! panic {
4547
/// Other use-cases of `assert!` include [testing] and enforcing run-time
4648
/// invariants in safe code (whose violation cannot result in unsafety).
4749
///
48-
/// This macro has a second version, where a custom panic message can
50+
/// # Custom Messages
51+
///
52+
/// This macro has a second form, where a custom panic message can
4953
/// be provided with or without arguments for formatting.
5054
///
5155
/// [`panic!`]: macro.panic.html
@@ -85,14 +89,15 @@ macro_rules! assert {
8589
);
8690
}
8791

88-
/// Asserts that two expressions are equal to each other.
92+
/// Asserts that two expressions are equal to each other (using [`PartialEq`]).
8993
///
9094
/// On panic, this macro will print the values of the expressions with their
9195
/// debug representations.
9296
///
93-
/// Like [`assert!`], this macro has a second version, where a custom
97+
/// Like [`assert!`], this macro has a second form, where a custom
9498
/// panic message can be provided.
9599
///
100+
/// [`PartialEq`]: cmp/trait.PartialEq.html
96101
/// [`assert!`]: macro.assert.html
97102
///
98103
/// # Examples
@@ -130,14 +135,15 @@ macro_rules! assert_eq {
130135
});
131136
}
132137

133-
/// Asserts that two expressions are not equal to each other.
138+
/// Asserts that two expressions are not equal to each other (using [`PartialEq`]).
134139
///
135140
/// On panic, this macro will print the values of the expressions with their
136141
/// debug representations.
137142
///
138-
/// Like `assert!()`, this macro has a second version, where a custom
143+
/// Like [`assert!`], this macro has a second form, where a custom
139144
/// panic message can be provided.
140145
///
146+
/// [`PartialEq`]: cmp/trait.PartialEq.html
141147
/// [`assert!`]: macro.assert.html
142148
///
143149
/// # Examples
@@ -183,6 +189,8 @@ macro_rules! assert_ne {
183189
/// Like [`assert!`], this macro also has a second version, where a custom panic
184190
/// message can be provided.
185191
///
192+
/// # Uses
193+
///
186194
/// Unlike [`assert!`], `debug_assert!` statements are only enabled in non
187195
/// optimized builds by default. An optimized build will omit all
188196
/// `debug_assert!` statements unless `-C debug-assertions` is passed to the

0 commit comments

Comments
 (0)