2021-01-30 11:06:34 -06:00
|
|
|
#![allow(unused)]
|
|
|
|
#![warn(clippy::redundant_slicing)]
|
|
|
|
|
|
|
|
fn main() {
|
2021-04-08 10:50:13 -05:00
|
|
|
let slice: &[u32] = &[0];
|
|
|
|
let _ = &slice[..];
|
2021-01-30 11:06:34 -06:00
|
|
|
|
|
|
|
let v = vec![0];
|
2021-04-08 10:50:13 -05:00
|
|
|
let _ = &v[..]; // Changes the type
|
|
|
|
let _ = &(&v[..])[..]; // Outer borrow is redundant
|
|
|
|
|
|
|
|
static S: &[u8] = &[0, 1, 2];
|
|
|
|
let err = &mut &S[..]; // Should reborrow instead of slice
|
|
|
|
|
|
|
|
let mut vec = vec![0];
|
|
|
|
let mut_slice = &mut *vec;
|
|
|
|
let _ = &mut mut_slice[..]; // Should reborrow instead of slice
|
|
|
|
|
|
|
|
macro_rules! m {
|
|
|
|
($e:expr) => {
|
|
|
|
$e
|
|
|
|
};
|
|
|
|
}
|
|
|
|
let _ = &m!(slice)[..];
|
|
|
|
|
|
|
|
macro_rules! m2 {
|
|
|
|
($e:expr) => {
|
|
|
|
&$e[..]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
let _ = m2!(slice); // Don't lint in a macro
|
2021-01-30 11:06:34 -06:00
|
|
|
}
|