Skip to content

Commit a64b477

Browse files
committed
Edge cases of fn must-use
1 parent 407d714 commit a64b477

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/attributes.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ fn main() {
400400

401401
When used on a function, if the [expression] of an
402402
[expression statement] is a [call expression] to that function, then the
403-
`unused_must_use` lint is violated.
403+
`unused_must_use` lint is violated. The exceptions to this is if the return type
404+
of the function is `()`, `!`, or a [zero-variant enum], in which case the
405+
attribute does nothing.
404406

405407
```rust
406408
#[must_use]
@@ -513,4 +515,5 @@ You can implement `derive` for your own type through [procedural macros].
513515
[block expression]: expressions/block-expr.html
514516
[`Drop`]: special-types-and-traits.html#drop
515517
[let statement]: statements.html#let-statements
516-
[unstable book plugin]: ../unstable-book/language-features/plugin.html#lint-plugins
518+
[unstable book plugin]: ../unstable-book/language-features/plugin.html#lint-plugins
519+
[zero-variant enum]: enumerations.html#zero-variant-enums

0 commit comments

Comments
 (0)