Skip to content

Commit

Permalink
Rename lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nahuakang committed Jan 19, 2021
1 parent 32405b8 commit 55c1016
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,7 @@ Released 2018-09-13
[`inline_asm_x86_att_syntax`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_asm_x86_att_syntax
[`inline_asm_x86_intel_syntax`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_asm_x86_intel_syntax
[`inline_fn_without_body`]: https://rust-lang.github.io/rust-clippy/master/index.html#inline_fn_without_body
[`inspect_then_for_each`]: https://rust-lang.github.io/rust-clippy/master/index.html#inspect_then_for_each
[`inspect_for_each`]: https://rust-lang.github.io/rust-clippy/master/index.html#inspect_for_each
[`int_plus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#int_plus_one
[`integer_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_arithmetic
[`integer_division`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_division
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
&methods::FROM_ITER_INSTEAD_OF_COLLECT,
&methods::GET_UNWRAP,
&methods::INEFFICIENT_TO_STRING,
&methods::INSPECT_THEN_FOR_EACH,
&methods::INSPECT_FOR_EACH,
&methods::INTO_ITER_ON_REF,
&methods::ITERATOR_STEP_BY_ZERO,
&methods::ITER_CLONED_COLLECT,
Expand Down Expand Up @@ -1508,7 +1508,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&methods::FILTER_NEXT),
LintId::of(&methods::FLAT_MAP_IDENTITY),
LintId::of(&methods::FROM_ITER_INSTEAD_OF_COLLECT),
LintId::of(&methods::INSPECT_THEN_FOR_EACH),
LintId::of(&methods::INSPECT_FOR_EACH),
LintId::of(&methods::INTO_ITER_ON_REF),
LintId::of(&methods::ITERATOR_STEP_BY_ZERO),
LintId::of(&methods::ITER_CLONED_COLLECT),
Expand Down Expand Up @@ -1809,7 +1809,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&methods::CLONE_ON_COPY),
LintId::of(&methods::FILTER_NEXT),
LintId::of(&methods::FLAT_MAP_IDENTITY),
LintId::of(&methods::INSPECT_THEN_FOR_EACH),
LintId::of(&methods::INSPECT_FOR_EACH),
LintId::of(&methods::OPTION_AS_REF_DEREF),
LintId::of(&methods::SEARCH_IS_SOME),
LintId::of(&methods::SKIP_WHILE_NEXT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_span::source_map::Span;

use crate::utils::{match_trait_method, paths, span_lint_and_help};

use super::INSPECT_THEN_FOR_EACH;
use super::INSPECT_FOR_EACH;

/// lint use of `inspect().for_each()` for `Iterators`
pub(super) fn lint<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, inspect_span: Span) {
Expand All @@ -13,7 +13,7 @@ pub(super) fn lint<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, insp
let hint = "move the code from `inspect(..)` to `for_each(..)` and remove the `inspect(..)`";
span_lint_and_help(
cx,
INSPECT_THEN_FOR_EACH,
INSPECT_FOR_EACH,
inspect_span.with_hi(expr.span.hi()),
msg,
None,
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod bind_instead_of_map;
mod inefficient_to_string;
mod inspect_then_for_each;
mod inspect_for_each;
mod manual_saturating_arithmetic;
mod option_map_unwrap_or;
mod unnecessary_filter_map;
Expand Down Expand Up @@ -1431,7 +1431,7 @@ declare_clippy_lint! {
/// assert!(x >= 0);
/// });
/// ```
pub INSPECT_THEN_FOR_EACH,
pub INSPECT_FOR_EACH,
complexity,
"using `.inspect().for_each()`, which can be replaced with `.for_each()`"
}
Expand Down Expand Up @@ -1498,7 +1498,7 @@ impl_lint_pass!(Methods => [
UNNECESSARY_LAZY_EVALUATIONS,
MAP_COLLECT_RESULT_UNIT,
FROM_ITER_INSTEAD_OF_COLLECT,
INSPECT_THEN_FOR_EACH,
INSPECT_FOR_EACH,
]);

impl<'tcx> LateLintPass<'tcx> for Methods {
Expand Down Expand Up @@ -1585,7 +1585,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
["get_or_insert_with", ..] => unnecessary_lazy_eval::lint(cx, expr, arg_lists[0], "get_or_insert"),
["ok_or_else", ..] => unnecessary_lazy_eval::lint(cx, expr, arg_lists[0], "ok_or"),
["collect", "map"] => lint_map_collect(cx, expr, arg_lists[1], arg_lists[0]),
["for_each", "inspect"] => inspect_then_for_each::lint(cx, expr, method_spans[1]),
["for_each", "inspect"] => inspect_for_each::lint(cx, expr, method_spans[1]),
_ => {},
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![warn(clippy::inspect_then_for_each)]
#![warn(clippy::inspect_for_each)]

fn main() {
let a: Vec<usize> = vec![1, 2, 3, 4, 5];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: called `inspect(..).for_each(..)` on an `Iterator`
--> $DIR/inspect_then_for_each.rs:7:19
--> $DIR/inspect_for_each.rs:7:19
|
LL | a.into_iter().inspect(|x| assert!(*x > 0)).for_each(|x| {
| ___________________^
Expand All @@ -9,7 +9,7 @@ LL | | b.push(z);
LL | | });
| |______^
|
= note: `-D clippy::inspect-then-for-each` implied by `-D warnings`
= note: `-D clippy::inspect-for-each` implied by `-D warnings`
= help: move the code from `inspect(..)` to `for_each(..)` and remove the `inspect(..)`

error: aborting due to previous error
Expand Down

0 comments on commit 55c1016

Please sign in to comment.