Skip to content

Commit

Permalink
Renamed lint to match_on_vec_items
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyRoka committed Apr 25, 2020
1 parent b0115fb commit 63b451e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -1348,11 +1348,11 @@ Released 2018-09-13
[`map_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
[`match_as_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_as_ref
[`match_bool`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_bool
[`match_on_vec_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_on_vec_items
[`match_overlapping_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_overlapping_arm
[`match_ref_pats`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_ref_pats
[`match_same_arms`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_same_arms
[`match_single_binding`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_single_binding
[`match_vec_item`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_vec_item
[`match_wild_err_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#match_wild_err_arm
[`maybe_infinite_iter`]: https://rust-lang.github.io/rust-clippy/master/index.html#maybe_infinite_iter
[`mem_discriminant_non_enum`]: https://rust-lang.github.io/rust-clippy/master/index.html#mem_discriminant_non_enum
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/lib.rs
Expand Up @@ -249,7 +249,7 @@ mod macro_use;
mod main_recursion;
mod map_clone;
mod map_unit_fn;
mod match_vec_item;
mod match_on_vec_items;
mod matches;
mod mem_discriminant;
mod mem_forget;
Expand Down Expand Up @@ -630,7 +630,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
&map_clone::MAP_CLONE,
&map_unit_fn::OPTION_MAP_UNIT_FN,
&map_unit_fn::RESULT_MAP_UNIT_FN,
&match_vec_item::MATCH_VEC_ITEM,
&match_on_vec_items::MATCH_ON_VEC_ITEMS,
&matches::INFALLIBLE_DESTRUCTURING_MATCH,
&matches::MATCH_AS_REF,
&matches::MATCH_BOOL,
Expand Down Expand Up @@ -1062,7 +1062,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_late_pass(|| box future_not_send::FutureNotSend);
store.register_late_pass(|| box utils::internal_lints::CollapsibleCalls);
store.register_late_pass(|| box if_let_mutex::IfLetMutex);
store.register_late_pass(|| box match_vec_item::MatchVecItem);
store.register_late_pass(|| box match_on_vec_items::MatchOnVecItems);

store.register_group(true, "clippy::restriction", Some("clippy_restriction"), vec![
LintId::of(&arithmetic::FLOAT_ARITHMETIC),
Expand Down Expand Up @@ -1280,7 +1280,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&map_clone::MAP_CLONE),
LintId::of(&map_unit_fn::OPTION_MAP_UNIT_FN),
LintId::of(&map_unit_fn::RESULT_MAP_UNIT_FN),
LintId::of(&match_vec_item::MATCH_VEC_ITEM),
LintId::of(&match_on_vec_items::MATCH_ON_VEC_ITEMS),
LintId::of(&matches::INFALLIBLE_DESTRUCTURING_MATCH),
LintId::of(&matches::MATCH_AS_REF),
LintId::of(&matches::MATCH_BOOL),
Expand Down Expand Up @@ -1473,7 +1473,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&loops::WHILE_LET_ON_ITERATOR),
LintId::of(&main_recursion::MAIN_RECURSION),
LintId::of(&map_clone::MAP_CLONE),
LintId::of(&match_vec_item::MATCH_VEC_ITEM),
LintId::of(&match_on_vec_items::MATCH_ON_VEC_ITEMS),
LintId::of(&matches::INFALLIBLE_DESTRUCTURING_MATCH),
LintId::of(&matches::MATCH_BOOL),
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
Expand Down
Expand Up @@ -37,14 +37,14 @@ declare_clippy_lint! {
/// _ => {},
/// }
/// ```
pub MATCH_VEC_ITEM,
pub MATCH_ON_VEC_ITEMS,
style,
"match vector by indexing can panic"
"matching on vector elements can panic"
}

declare_lint_pass!(MatchVecItem => [MATCH_VEC_ITEM]);
declare_lint_pass!(MatchOnVecItems => [MATCH_ON_VEC_ITEMS]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MatchVecItem {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MatchOnVecItems {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'tcx>) {
if_chain! {
if !in_external_macro(cx.sess(), expr.span);
Expand All @@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MatchVecItem {
let mut applicability = Applicability::MaybeIncorrect;
span_lint_and_sugg(
cx,
MATCH_VEC_ITEM,
MATCH_ON_VEC_ITEMS,
match_expr.span,
"indexing vector may panic. Consider using `get`",
"try this",
Expand Down
14 changes: 7 additions & 7 deletions src/lintlist/mod.rs
Expand Up @@ -1144,6 +1144,13 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
deprecation: None,
module: "matches",
},
Lint {
name: "match_on_vec_items",
group: "style",
desc: "matching on vector elements can panic",
deprecation: None,
module: "match_on_vec_items",
},
Lint {
name: "match_overlapping_arm",
group: "style",
Expand Down Expand Up @@ -1172,13 +1179,6 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
deprecation: None,
module: "matches",
},
Lint {
name: "match_vec_item",
group: "style",
desc: "match vector by indexing can panic",
deprecation: None,
module: "match_vec_item",
},
Lint {
name: "match_wild_err_arm",
group: "style",
Expand Down
@@ -1,4 +1,4 @@
#![warn(clippy::match_vec_item)]
#![warn(clippy::match_on_vec_items)]

fn main() {
match_with_wildcard();
Expand Down
@@ -1,49 +1,49 @@
error: indexing vector may panic. Consider using `get`
--> $DIR/match_vec_item.rs:18:11
--> $DIR/match_on_vec_items.rs:18:11
|
LL | match arr[idx] {
| ^^^^^^^^ help: try this: `arr.get(idx)`
|
= note: `-D clippy::match-vec-item` implied by `-D warnings`
= note: `-D clippy::match-on-vec-items` implied by `-D warnings`

error: indexing vector may panic. Consider using `get`
--> $DIR/match_vec_item.rs:25:11
--> $DIR/match_on_vec_items.rs:25:11
|
LL | match arr[range] {
| ^^^^^^^^^^ help: try this: `arr.get(range)`

error: indexing vector may panic. Consider using `get`
--> $DIR/match_vec_item.rs:38:11
--> $DIR/match_on_vec_items.rs:38:11
|
LL | match arr[idx] {
| ^^^^^^^^ help: try this: `arr.get(idx)`

error: indexing vector may panic. Consider using `get`
--> $DIR/match_vec_item.rs:45:11
--> $DIR/match_on_vec_items.rs:45:11
|
LL | match arr[range] {
| ^^^^^^^^^^ help: try this: `arr.get(range)`

error: indexing vector may panic. Consider using `get`
--> $DIR/match_vec_item.rs:58:11
--> $DIR/match_on_vec_items.rs:58:11
|
LL | match arr[idx] {
| ^^^^^^^^ help: try this: `arr.get(idx)`

error: indexing vector may panic. Consider using `get`
--> $DIR/match_vec_item.rs:65:11
--> $DIR/match_on_vec_items.rs:65:11
|
LL | match arr[range] {
| ^^^^^^^^^^ help: try this: `arr.get(range)`

error: indexing vector may panic. Consider using `get`
--> $DIR/match_vec_item.rs:78:11
--> $DIR/match_on_vec_items.rs:78:11
|
LL | match arr[idx] {
| ^^^^^^^^ help: try this: `arr.get(idx)`

error: indexing vector may panic. Consider using `get`
--> $DIR/match_vec_item.rs:85:11
--> $DIR/match_on_vec_items.rs:85:11
|
LL | match arr[range] {
| ^^^^^^^^^^ help: try this: `arr.get(range)`
Expand Down

0 comments on commit 63b451e

Please sign in to comment.