File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -414,6 +414,27 @@ fn main() {
414
414
}
415
415
```
416
416
417
+ When used on a function in a trait declaration, then the behavior also applies
418
+ when the call expression is a function from an implementation of the trait.
419
+
420
+ ``` rust
421
+ trait Trait {
422
+ #[must_use]
423
+ fn use_me (& self ) -> i32 ;
424
+ }
425
+
426
+ impl Trait for i32 {
427
+ fn use_me (& self ) -> i32 { 0i32 }
428
+ }
429
+
430
+ fn main () {
431
+ // Violates the `unused_must_use` lint.
432
+ 5i32 . use_me ();
433
+ }
434
+ ```
435
+
436
+ When used on a function in an implementation, the attribute does nothing.
437
+
417
438
> Note: Trivial no-op expressions containing the value will not violate the
418
439
> lint. Examples include wrapping the value in a type that does not implement
419
440
> [ ` Drop ` ] and then not using that type and being the final expression of a
You can’t perform that action at this time.
0 commit comments