File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ feature( box_syntax) ]
2+ #![ deny( unused_allocation) ]
3+
4+ fn main ( ) {
5+ let foo = ( box [ 1 , 2 , 3 ] ) . len ( ) ; //~ ERROR: unnecessary allocation
6+ let one = ( box vec ! [ 1 ] ) . pop ( ) ; //~ ERROR: unnecessary allocation
7+
8+ let foo = Box :: new ( [ 1 , 2 , 3 ] ) . len ( ) ; //~ ERROR: unnecessary allocation
9+ let one = Box :: new ( vec ! [ 1 ] ) . pop ( ) ; //~ ERROR: unnecessary allocation
10+ }
Original file line number Diff line number Diff line change 1+ error: unnecessary allocation, use `&` instead
2+ --> $DIR/unused-allocation.rs:5:15
3+ |
4+ LL | let foo = (box [1, 2, 3]).len();
5+ | ^^^^^^^^^^^^^^^
6+ |
7+ note: the lint level is defined here
8+ --> $DIR/unused-allocation.rs:2:9
9+ |
10+ LL | #![deny(unused_allocation)]
11+ | ^^^^^^^^^^^^^^^^^
12+
13+ error: unnecessary allocation, use `&mut` instead
14+ --> $DIR/unused-allocation.rs:6:15
15+ |
16+ LL | let one = (box vec![1]).pop();
17+ | ^^^^^^^^^^^^^
18+
19+ error: unnecessary allocation, use `&` instead
20+ --> $DIR/unused-allocation.rs:8:15
21+ |
22+ LL | let foo = Box::new([1, 2, 3]).len();
23+ | ^^^^^^^^
24+
25+ error: unnecessary allocation, use `&mut` instead
26+ --> $DIR/unused-allocation.rs:9:15
27+ |
28+ LL | let one = Box::new(vec![1]).pop();
29+ | ^^^^^^^^
30+
31+ error: aborting due to 4 previous errors
32+
You can’t perform that action at this time.
0 commit comments