Merge commit 'd5e2a7aca5' into clippyup

This commit is contained in:
Philipp Krones 2023-03-24 14:04:35 +01:00
parent 58eb9964cc
commit 8df896c076
184 changed files with 3000 additions and 1635 deletions

View file

@ -7,6 +7,11 @@ struct MyVec {
vec: Vec<u8>,
}
union MyOwnMaybeUninit {
value: u8,
uninit: (),
}
fn main() {
// with_capacity() -> set_len() should be detected
let mut vec: Vec<u8> = Vec::with_capacity(1000);
@ -97,4 +102,26 @@ fn main() {
unsafe {
vec.set_len(0);
}
// ZSTs should not be detected
let mut vec: Vec<()> = Vec::with_capacity(1000);
unsafe {
vec.set_len(10);
}
// unions should not be detected
let mut vec: Vec<MyOwnMaybeUninit> = Vec::with_capacity(1000);
unsafe {
vec.set_len(10);
}
polymorphic::<()>();
fn polymorphic<T>() {
// We are conservative around polymorphic types.
let mut vec: Vec<T> = Vec::with_capacity(1000);
unsafe {
vec.set_len(10);
}
}
}