]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/vec_init_then_push.rs
1 #![allow(unused_variables)]
2 #![warn(clippy::vec_init_then_push)]
5 let mut def_err
: Vec
<u32> = Default
::default();
6 //~^ ERROR: calls to `push` immediately after creation
7 //~| NOTE: `-D clippy::vec-init-then-push` implied by `-D warnings`
10 let mut new_err
= Vec
::<u32>::new();
11 //~^ ERROR: calls to `push` immediately after creation
14 let mut cap_err
= Vec
::with_capacity(2);
15 //~^ ERROR: calls to `push` immediately after creation
20 // don't include this one
24 let mut cap_ok
= Vec
::with_capacity(10);
28 //~^ ERROR: calls to `push` immediately after creation
31 let mut vec
= Vec
::new();
32 // control flow at block final expression
38 let mut vec
= Vec
::with_capacity(5);
45 pub fn no_lint() -> Vec
<i32> {
47 let mut vec
= Vec
::new();
59 fn _from_iter(items
: impl Iterator
<Item
= u32>) -> Vec
<u32> {
60 let mut v
= Vec
::new();
67 fn _cond_push(x
: bool
) -> Vec
<u32> {
68 let mut v
= Vec
::new();
77 fn _push_then_edit(x
: u32) -> Vec
<u32> {
78 let mut v
= Vec
::new();
79 //~^ ERROR: calls to `push` immediately after creation
86 fn _cond_push_with_large_start(x
: bool
) -> Vec
<u32> {
87 let mut v
= Vec
::new();
88 //~^ ERROR: calls to `push` immediately after creation
101 let mut v2
= Vec
::new();
102 //~^ ERROR: calls to `push` immediately after creation
117 let mut v
= Vec
::new();
118 //~^ ERROR: calls to `push` immediately after creation
119 v
.push((0i32, 0i32));
120 let y
= v
[0].0.abs();