Initial implementation of redundant_slicing lint
This commit is contained in:
parent
3577cf79de
commit
837bc99065
5 changed files with 89 additions and 0 deletions
11
tests/ui/redundant_slicing.rs
Normal file
11
tests/ui/redundant_slicing.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#![allow(unused)]
|
||||
#![warn(clippy::redundant_slicing)]
|
||||
|
||||
fn main() {
|
||||
let x: &[u32] = &[0];
|
||||
let err = &x[..];
|
||||
|
||||
let v = vec![0];
|
||||
let ok = &v[..];
|
||||
let err = &(&v[..])[..];
|
||||
}
|
||||
16
tests/ui/redundant_slicing.stderr
Normal file
16
tests/ui/redundant_slicing.stderr
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
error: redundant slicing of the whole range
|
||||
--> $DIR/redundant_slicing.rs:6:15
|
||||
|
|
||||
LL | let err = &x[..];
|
||||
| ^^^^^^ help: use the original slice instead: `x`
|
||||
|
|
||||
= note: `-D clippy::redundant-slicing` implied by `-D warnings`
|
||||
|
||||
error: redundant slicing of the whole range
|
||||
--> $DIR/redundant_slicing.rs:10:15
|
||||
|
|
||||
LL | let err = &(&v[..])[..];
|
||||
| ^^^^^^^^^^^^^ help: use the original slice instead: `(&v[..])`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue