Add a test for unused_allocation
lint
(how come we didn't have one already??)
This commit is contained in:
parent
9ac0da8f39
commit
ff5f784140
7
tests/ui/lint/unused/unused-allocation.rs
Normal file
7
tests/ui/lint/unused/unused-allocation.rs
Normal 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
|
||||
}
|
20
tests/ui/lint/unused/unused-allocation.stderr
Normal file
20
tests/ui/lint/unused/unused-allocation.stderr
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user