You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/attributes/diagnostics.md
+49-45Lines changed: 49 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -360,63 +360,67 @@ The `must_use` attribute may include a message by using the [MetaNameValueStr] s
360
360
r[attributes.diagnostics.must_use.type]
361
361
When used on user-defined composite types, if the [expression] of an [expression statement] has that type, then the `unused_must_use` lint is violated.
362
362
363
-
```rust
364
-
#[must_use]
365
-
structMustUse {
366
-
// some fields
367
-
}
368
-
369
-
# implMustUse {
370
-
# fnnew() ->MustUse { MustUse {} }
371
-
# }
372
-
#
373
-
// Violates the `unused_must_use` lint.
374
-
MustUse::new();
375
-
```
363
+
> [!EXAMPLE]
364
+
> ```rust
365
+
> #[must_use]
366
+
> structMustUse {
367
+
> // some fields
368
+
> }
369
+
>
370
+
> # implMustUse {
371
+
> # fnnew() ->MustUse { MustUse {} }
372
+
> # }
373
+
> #
374
+
> // Violates the `unused_must_use` lint.
375
+
> MustUse::new();
376
+
> ```
376
377
377
378
r[attributes.diagnostics.must_use.fn]
378
379
Whenusedonafunction, ifthe [expression] ofan [expressionstatement] isa [callexpression] tothatfunction, thenthe `unused_must_use` lintisviolated.
379
380
380
-
```rust
381
-
#[must_use]
382
-
fnfive() ->i32 { 5i32 }
383
-
384
-
// Violates the unused_must_use lint.
385
-
five();
386
-
```
381
+
> [!EXAMPLE]
382
+
> ```rust
383
+
> #[must_use]
384
+
> fnfive() ->i32 { 5i32 }
385
+
>
386
+
> // Violates the unused_must_use lint.
387
+
> five();
388
+
> ```
387
389
388
390
r[attributes.diagnostics.must_use.trait]
389
391
Whenusedona [traitdeclaration], a [callexpression] ofan [expressionstatement] toafunctionthatreturnsan [impltrait] ora [dyntrait] ofthattraitviolatesthe `unused_must_use` lint.
0 commit comments