forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#6975 - Jarcho:redundant_slicing_fp, r=llogiq
Improve `redundant_slicing` fixes: rust-lang#6968 changelog: Fix `redundant_slicing` suggestion when a reborrow might be required or when the value is from a macro call
- Loading branch information
Showing
3 changed files
with
78 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
error: redundant slicing of the whole range | ||
--> $DIR/redundant_slicing.rs:6:15 | ||
--> $DIR/redundant_slicing.rs:6:13 | ||
| | ||
LL | let err = &x[..]; | ||
| ^^^^^^ help: use the original slice instead: `x` | ||
LL | let _ = &slice[..]; | ||
| ^^^^^^^^^^ help: use the original value instead: `slice` | ||
| | ||
= note: `-D clippy::redundant-slicing` implied by `-D warnings` | ||
|
||
error: redundant slicing of the whole range | ||
--> $DIR/redundant_slicing.rs:10:15 | ||
--> $DIR/redundant_slicing.rs:10:13 | ||
| | ||
LL | let err = &(&v[..])[..]; | ||
| ^^^^^^^^^^^^^ help: use the original slice instead: `(&v[..])` | ||
LL | let _ = &(&v[..])[..]; // Outer borrow is redundant | ||
| ^^^^^^^^^^^^^ help: use the original value instead: `(&v[..])` | ||
|
||
error: aborting due to 2 previous errors | ||
error: redundant slicing of the whole range | ||
--> $DIR/redundant_slicing.rs:13:20 | ||
| | ||
LL | let err = &mut &S[..]; // Should reborrow instead of slice | ||
| ^^^^^^ help: reborrow the original value instead: `&*S` | ||
|
||
error: redundant slicing of the whole range | ||
--> $DIR/redundant_slicing.rs:17:13 | ||
| | ||
LL | let _ = &mut mut_slice[..]; // Should reborrow instead of slice | ||
| ^^^^^^^^^^^^^^^^^^ help: reborrow the original value instead: `&mut *mut_slice` | ||
|
||
error: redundant slicing of the whole range | ||
--> $DIR/redundant_slicing.rs:24:13 | ||
| | ||
LL | let _ = &m!(slice)[..]; | ||
| ^^^^^^^^^^^^^^ help: use the original value instead: `slice` | ||
|
||
error: aborting due to 5 previous errors | ||
|