mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 17:07:17 +00:00
0ff68bb151
Fix bad suggestion when a reborrow might be required Fix bad suggestion when the value being sliced is a macro call Don't lint inside of a macro due to the previous context sensitive changes
32 lines
703 B
Rust
32 lines
703 B
Rust
#![allow(unused)]
|
|
#![warn(clippy::redundant_slicing)]
|
|
|
|
fn main() {
|
|
let slice: &[u32] = &[0];
|
|
let _ = &slice[..];
|
|
|
|
let v = vec![0];
|
|
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
|
|
}
|