Add a test for unused_allocation lint

(how come we didn't have one already??)
This commit is contained in:
Maybe Waffle 2022-11-13 14:05:04 +00:00
parent 9ac0da8f39
commit ff5f784140
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,7 @@
#![feature(box_syntax)]
#![deny(unused_allocation)]
fn main() {
_ = (box [1]).len(); //~ error: unnecessary allocation, use `&` instead
_ = Box::new([1]).len(); //~ error: unnecessary allocation, use `&` instead
}

View file

@ -0,0 +1,20 @@
error: unnecessary allocation, use `&` instead
--> $DIR/unused-allocation.rs:5:9
|
LL | _ = (box [1]).len();
| ^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/unused-allocation.rs:2:9
|
LL | #![deny(unused_allocation)]
| ^^^^^^^^^^^^^^^^^
error: unnecessary allocation, use `&` instead
--> $DIR/unused-allocation.rs:6:9
|
LL | _ = Box::new([1]).len();
| ^^^^^^^^^^^^^
error: aborting due to 2 previous errors