Skip to content

Commit 6e49c83

Browse files
committed
Add explanation for #[must_use] on Debug builders
1 parent 1abed9c commit 6e49c83

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libcore/fmt/builders.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<'a> fmt::Write for PadAdapter<'a> {
8484
/// // prints "Foo { bar: 10, baz: "Hello World" }"
8585
/// println!("{:?}", Foo { bar: 10, baz: "Hello World".to_string() });
8686
/// ```
87-
#[must_use]
87+
#[must_use = "must eventually call `finish()` on Debug builders"]
8888
#[allow(missing_debug_implementations)]
8989
#[stable(feature = "debug_builders", since = "1.2.0")]
9090
pub struct DebugStruct<'a, 'b: 'a> {
@@ -181,7 +181,7 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
181181
/// // prints "Foo(10, "Hello World")"
182182
/// println!("{:?}", Foo(10, "Hello World".to_string()));
183183
/// ```
184-
#[must_use]
184+
#[must_use = "must eventually call `finish()` on Debug builders"]
185185
#[allow(missing_debug_implementations)]
186186
#[stable(feature = "debug_builders", since = "1.2.0")]
187187
pub struct DebugTuple<'a, 'b: 'a> {
@@ -319,7 +319,7 @@ impl<'a, 'b: 'a> DebugInner<'a, 'b> {
319319
/// // prints "{10, 11}"
320320
/// println!("{:?}", Foo(vec![10, 11]));
321321
/// ```
322-
#[must_use]
322+
#[must_use = "must eventually call `finish()` on Debug builders"]
323323
#[allow(missing_debug_implementations)]
324324
#[stable(feature = "debug_builders", since = "1.2.0")]
325325
pub struct DebugSet<'a, 'b: 'a> {
@@ -390,7 +390,7 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
390390
/// // prints "[10, 11]"
391391
/// println!("{:?}", Foo(vec![10, 11]));
392392
/// ```
393-
#[must_use]
393+
#[must_use = "must eventually call `finish()` on Debug builders"]
394394
#[allow(missing_debug_implementations)]
395395
#[stable(feature = "debug_builders", since = "1.2.0")]
396396
pub struct DebugList<'a, 'b: 'a> {
@@ -461,7 +461,7 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
461461
/// // prints "{"A": 10, "B": 11}"
462462
/// println!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)]));
463463
/// ```
464-
#[must_use]
464+
#[must_use = "must eventually call `finish()` on Debug builders"]
465465
#[allow(missing_debug_implementations)]
466466
#[stable(feature = "debug_builders", since = "1.2.0")]
467467
pub struct DebugMap<'a, 'b: 'a> {

0 commit comments

Comments
 (0)