diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-11-13 14:05:04 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-03-03 17:47:40 +0000 |
| commit | ff5f7841401df797d94818fac43777327dbecf9a (patch) | |
| tree | 948aa2907cc506e0f6bfd19098d154e0ee2d2dcc | |
| parent | 9ac0da8f39680f1b09321980187bc502580b526a (diff) | |
| download | rust-ff5f7841401df797d94818fac43777327dbecf9a.tar.gz rust-ff5f7841401df797d94818fac43777327dbecf9a.zip | |
Add a test for `unused_allocation` lint
(how come we didn't have one already??)
| -rw-r--r-- | tests/ui/lint/unused/unused-allocation.rs | 7 | ||||
| -rw-r--r-- | tests/ui/lint/unused/unused-allocation.stderr | 20 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/lint/unused/unused-allocation.rs b/tests/ui/lint/unused/unused-allocation.rs new file mode 100644 index 00000000000..df51dd194d5 --- /dev/null +++ b/tests/ui/lint/unused/unused-allocation.rs @@ -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 +} diff --git a/tests/ui/lint/unused/unused-allocation.stderr b/tests/ui/lint/unused/unused-allocation.stderr new file mode 100644 index 00000000000..91bd1da35a3 --- /dev/null +++ b/tests/ui/lint/unused/unused-allocation.stderr @@ -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 + |
