Skip to content

Commit

Permalink
Rename slice_as_deref to deref_as_slicing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarcho committed Jan 13, 2022
1 parent ac282d8 commit 014b0e7
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2932,6 +2932,7 @@ Released 2018-09-13
[`deprecated_cfg_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_cfg_attr
[`deprecated_semver`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_semver
[`deref_addrof`]: https://rust-lang.github.io/rust-clippy/master/index.html#deref_addrof
[`deref_by_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#deref_by_slicing
[`derivable_impls`]: https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls
[`derive_hash_xor_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_hash_xor_eq
[`derive_ord_xor_partial_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_ord_xor_partial_ord
Expand Down Expand Up @@ -3260,7 +3261,6 @@ Released 2018-09-13
[`single_match_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
[`size_of_in_element_count`]: https://rust-lang.github.io/rust-clippy/master/index.html#size_of_in_element_count
[`skip_while_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#skip_while_next
[`slice_as_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#slice_as_deref
[`slow_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
[`stable_sort_primitive`]: https://rust-lang.github.io/rust-clippy/master/index.html#stable_sort_primitive
[`str_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#str_to_string
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.register_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ store.register_lints(&[
redundant_else::REDUNDANT_ELSE,
redundant_field_names::REDUNDANT_FIELD_NAMES,
redundant_pub_crate::REDUNDANT_PUB_CRATE,
redundant_slicing::DEREF_BY_SLICING,
redundant_slicing::REDUNDANT_SLICING,
redundant_slicing::SLICE_AS_DEREF,
redundant_static_lifetimes::REDUNDANT_STATIC_LIFETIMES,
ref_option_ref::REF_OPTION_REF,
reference::DEREF_ADDROF,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.register_restriction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ store.register_group(true, "clippy::restriction", Some("clippy_restriction"), ve
LintId::of(panic_unimplemented::UNIMPLEMENTED),
LintId::of(panic_unimplemented::UNREACHABLE),
LintId::of(pattern_type_mismatch::PATTERN_TYPE_MISMATCH),
LintId::of(redundant_slicing::SLICE_AS_DEREF),
LintId::of(redundant_slicing::DEREF_BY_SLICING),
LintId::of(same_name_method::SAME_NAME_METHOD),
LintId::of(shadow::SHADOW_REUSE),
LintId::of(shadow::SHADOW_SAME),
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/redundant_slicing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ declare_clippy_lint! {
/// let slice = &*vec;
/// ```
#[clippy::version = "1.59.0"]
pub SLICE_AS_DEREF,
pub DEREF_BY_SLICING,
restriction,
"slicing instead of dereferencing"
}

declare_lint_pass!(RedundantSlicing => [REDUNDANT_SLICING, SLICE_AS_DEREF]);
declare_lint_pass!(RedundantSlicing => [REDUNDANT_SLICING, DEREF_BY_SLICING]);

impl LateLintPass<'_> for RedundantSlicing {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
Expand Down Expand Up @@ -140,7 +140,7 @@ impl LateLintPass<'_> for RedundantSlicing {
} else {
format!("&{}{}*{}", mutability.prefix_str(), "*".repeat(indexed_ref_count), snip)
};
(SLICE_AS_DEREF, "slicing when dereferencing would work", "dereference the original value instead", sugg)
(DEREF_BY_SLICING, "slicing when dereferencing would work", "dereference the original value instead", sugg)
} else {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-rustfix

#![warn(clippy::slice_as_deref)]
#![warn(clippy::deref_by_slicing)]

fn main() {
let mut vec = vec![0];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-rustfix

#![warn(clippy::slice_as_deref)]
#![warn(clippy::deref_by_slicing)]

fn main() {
let mut vec = vec![0];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
error: slicing when dereferencing would work
--> $DIR/slice_as_deref.rs:7:13
--> $DIR/deref_by_slicing.rs:7:13
|
LL | let _ = &vec[..];
| ^^^^^^^^ help: dereference the original value instead: `&*vec`
|
= note: `-D clippy::slice-as-deref` implied by `-D warnings`
= note: `-D clippy::deref-by-slicing` implied by `-D warnings`

error: slicing when dereferencing would work
--> $DIR/slice_as_deref.rs:8:13
--> $DIR/deref_by_slicing.rs:8:13
|
LL | let _ = &mut vec[..];
| ^^^^^^^^^^^^ help: dereference the original value instead: `&mut *vec`

error: slicing when dereferencing would work
--> $DIR/slice_as_deref.rs:11:13
--> $DIR/deref_by_slicing.rs:11:13
|
LL | let _ = &ref_vec[..];
| ^^^^^^^^^^^^ help: dereference the original value instead: `&**ref_vec`

error: slicing when dereferencing would work
--> $DIR/slice_as_deref.rs:12:13
--> $DIR/deref_by_slicing.rs:12:13
|
LL | let _ = &mut ref_vec[..];
| ^^^^^^^^^^^^^^^^ help: dereference the original value instead: `&mut **ref_vec`

error: slicing when dereferencing would work
--> $DIR/slice_as_deref.rs:15:13
--> $DIR/deref_by_slicing.rs:15:13
|
LL | let _ = &s[..];
| ^^^^^^ help: dereference the original value instead: `&*s`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/redundant_slicing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-rustfix

#![allow(unused, clippy::slice_as_deref)]
#![allow(unused, clippy::deref_by_slicing)]
#![warn(clippy::redundant_slicing)]

use std::io::Read;
Expand Down

0 comments on commit 014b0e7

Please sign in to comment.