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
The *`must_use` attribute* is used to issue a diagnostic warning when a value is not "used".
352
+
The *`must_use`[attribute][attributes]* is used to issue a diagnostic warning when a value is not used.
353
+
354
+
r[attributes.diagnostics.must_use.syntax]
355
+
The `must_use` attribute uses either the [MetaWord] syntax or the [MetaNameValueStr] syntax to be able to [specify a message][attributes.diagnostics.must_use.message].
356
+
357
+
> [!EXAMPLE]
358
+
> ```rust
359
+
> #[must_use]
360
+
> fnuse_me() ->u8 { 0 }
361
+
>
362
+
> #[must_use ="explanation of why it must be used"]
The `must_use` attribute can be applied to user-defined composite types ([`struct`s][struct], [`enum`s][enum], and [`union`s][union]), [functions], and [traits].
0 commit comments