Skip to content

Commit ff5f784

Browse files
committed
Add a test for unused_allocation lint
(how come we didn't have one already??)
1 parent 9ac0da8 commit ff5f784

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(box_syntax)]
2+
#![deny(unused_allocation)]
3+
4+
fn main() {
5+
_ = (box [1]).len(); //~ error: unnecessary allocation, use `&` instead
6+
_ = Box::new([1]).len(); //~ error: unnecessary allocation, use `&` instead
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: unnecessary allocation, use `&` instead
2+
--> $DIR/unused-allocation.rs:5:9
3+
|
4+
LL | _ = (box [1]).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 `&` instead
14+
--> $DIR/unused-allocation.rs:6:9
15+
|
16+
LL | _ = Box::new([1]).len();
17+
| ^^^^^^^^^^^^^
18+
19+
error: aborting due to 2 previous errors
20+

0 commit comments

Comments
 (0)