File tree Expand file tree Collapse file tree 2 files changed +77
-0
lines changed
Expand file tree Collapse file tree 2 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ deny( unused_must_use) ]
2+
3+ fn foo ( _: i32 ) -> bool { todo ! ( ) }
4+
5+ fn bar ( ) -> & ' static i32 {
6+ & 42 ;
7+ //~^ unused
8+
9+ & mut foo ( 42 ) ;
10+ //~^ unused
11+
12+ & & 42 ;
13+ //~^ unused
14+
15+ & & mut 42 ;
16+ //~^ unused
17+
18+ & mut & 42 ;
19+ //~^ unused
20+
21+ let _result = foo ( 4 )
22+ && foo ( 2 ) ; // Misplaced semi-colon (perhaps due to reordering of lines)
23+ & & foo ( 42 ) ;
24+ //~^ unused
25+
26+ let _ = & 42 ; // ok
27+
28+ & 42 // ok
29+ }
30+
31+ fn main ( ) {
32+ let _ = bar ( ) ;
33+ }
Original file line number Diff line number Diff line change 1+ error: unused borrow that must be used
2+ --> $DIR/unused-borrows.rs:6:5
3+ |
4+ LL | &42;
5+ | ^^^
6+ |
7+ note: the lint level is defined here
8+ --> $DIR/unused-borrows.rs:1:9
9+ |
10+ LL | #![deny(unused_must_use)]
11+ | ^^^^^^^^^^^^^^^
12+
13+ error: unused borrow that must be used
14+ --> $DIR/unused-borrows.rs:9:5
15+ |
16+ LL | &mut foo(42);
17+ | ^^^^^^^^^^^^
18+
19+ error: unused borrow that must be used
20+ --> $DIR/unused-borrows.rs:12:5
21+ |
22+ LL | &&42;
23+ | ^^^^
24+
25+ error: unused borrow that must be used
26+ --> $DIR/unused-borrows.rs:15:5
27+ |
28+ LL | &&mut 42;
29+ | ^^^^^^^^
30+
31+ error: unused borrow that must be used
32+ --> $DIR/unused-borrows.rs:18:5
33+ |
34+ LL | &mut &42;
35+ | ^^^^^^^^
36+
37+ error: unused borrow that must be used
38+ --> $DIR/unused-borrows.rs:23:9
39+ |
40+ LL | && foo(42);
41+ | ^^^^^^^^^^
42+
43+ error: aborting due to 6 previous errors
44+
You can’t perform that action at this time.
0 commit comments