File tree 2 files changed +65
-0
lines changed
2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ deny( unused_must_use) ]
2
+
3
+ use std:: { ops:: Deref , pin:: Pin } ;
4
+
5
+ #[ must_use]
6
+ struct MustUse ;
7
+
8
+ #[ must_use]
9
+ struct MustUsePtr < ' a , T > ( & ' a T ) ;
10
+
11
+ impl < ' a , T > Deref for MustUsePtr < ' a , T > {
12
+ type Target = T ;
13
+
14
+ fn deref ( & self ) -> & Self :: Target {
15
+ self . 0
16
+ }
17
+ }
18
+
19
+ fn pin_ref ( ) -> Pin < & ' static ( ) > {
20
+ Pin :: new ( & ( ) )
21
+ }
22
+
23
+ fn pin_ref_mut ( ) -> Pin < & ' static mut ( ) > {
24
+ Pin :: new ( unimplemented ! ( ) )
25
+ }
26
+
27
+ fn pin_must_use_ptr ( ) -> Pin < MustUsePtr < ' static , ( ) > > {
28
+ Pin :: new ( MustUsePtr ( & ( ) ) )
29
+ }
30
+
31
+ fn pin_box ( ) -> Pin < Box < ( ) > > {
32
+ Box :: pin ( ( ) )
33
+ }
34
+
35
+ fn pin_box_must_use ( ) -> Pin < Box < MustUse > > {
36
+ Box :: pin ( MustUse )
37
+ }
38
+
39
+ fn main ( ) {
40
+ pin_ref ( ) ;
41
+ pin_ref_mut ( ) ;
42
+ pin_must_use_ptr ( ) ; //~ ERROR unused pinned `MustUsePtr` that must be used
43
+ pin_box ( ) ;
44
+ pin_box_must_use ( ) ; //~ ERROR unused pinned boxed `MustUse` that must be used
45
+ }
Original file line number Diff line number Diff line change
1
+ error: unused pinned `MustUsePtr` that must be used
2
+ --> $DIR/must_use-pin.rs:42:5
3
+ |
4
+ LL | pin_must_use_ptr();
5
+ | ^^^^^^^^^^^^^^^^^^
6
+ |
7
+ note: the lint level is defined here
8
+ --> $DIR/must_use-pin.rs:1:9
9
+ |
10
+ LL | #![deny(unused_must_use)]
11
+ | ^^^^^^^^^^^^^^^
12
+
13
+ error: unused pinned boxed `MustUse` that must be used
14
+ --> $DIR/must_use-pin.rs:44:5
15
+ |
16
+ LL | pin_box_must_use();
17
+ | ^^^^^^^^^^^^^^^^^^
18
+
19
+ error: aborting due to 2 previous errors
20
+
You can’t perform that action at this time.
0 commit comments