From 3da25ed955baffe8c14cee4950762d268f1b48e7 Mon Sep 17 00:00:00 2001 From: nahuakang Date: Wed, 27 Jan 2021 09:49:53 +0100 Subject: [PATCH] Rename lint --- CHANGELOG.md | 3 ++- clippy_lints/src/lib.rs | 6 +++--- clippy_lints/src/loops.rs | 6 +++--- ...over_options.rs => for_loops_over_options_or_results.rs} | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) rename tests/ui/{for_loops_over_options.rs => for_loops_over_options_or_results.rs} (92%) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8e738313..4bd04ffbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1969,7 +1969,8 @@ Released 2018-09-13 [`fn_to_numeric_cast_with_truncation`]: https://rust-lang.github.io/rust-clippy/master/index.html#fn_to_numeric_cast_with_truncation [`for_kv_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_kv_map [`for_loops_over_fallibles`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_fallibles -[`for_loops_over_options`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_options +[`for_loops_over_options_or_results`]: +https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_options_or_results [`forget_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_copy [`forget_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_ref [`from_iter_instead_of_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 379320873..dae6c93c7 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -685,7 +685,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: &loops::EXPLICIT_ITER_LOOP, &loops::FOR_KV_MAP, &loops::FOR_LOOPS_OVER_FALLIBLES, - &loops::FOR_LOOPS_OVER_OPTIONS, + &loops::FOR_LOOPS_OVER_OPTIONS_OR_RESULTS, &loops::ITER_NEXT_LOOP, &loops::MANUAL_MEMCPY, &loops::MUT_RANGE_BOUND, @@ -1489,7 +1489,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: LintId::of(&loops::EXPLICIT_COUNTER_LOOP), LintId::of(&loops::FOR_KV_MAP), LintId::of(&loops::FOR_LOOPS_OVER_FALLIBLES), - LintId::of(&loops::FOR_LOOPS_OVER_OPTIONS), + LintId::of(&loops::FOR_LOOPS_OVER_OPTIONS_OR_RESULTS), LintId::of(&loops::ITER_NEXT_LOOP), LintId::of(&loops::MANUAL_MEMCPY), LintId::of(&loops::MUT_RANGE_BOUND), @@ -1822,7 +1822,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: LintId::of(&lifetimes::EXTRA_UNUSED_LIFETIMES), LintId::of(&lifetimes::NEEDLESS_LIFETIMES), LintId::of(&loops::EXPLICIT_COUNTER_LOOP), - LintId::of(&loops::FOR_LOOPS_OVER_OPTIONS), + LintId::of(&loops::FOR_LOOPS_OVER_OPTIONS_OR_RESULTS), LintId::of(&loops::MUT_RANGE_BOUND), LintId::of(&loops::SINGLE_ELEMENT_LOOP), LintId::of(&loops::WHILE_LET_LOOP), diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index c1a59650c..e9047cce1 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -520,7 +520,7 @@ declare_clippy_lint! { /// println!("{}", n); /// } /// ``` - pub FOR_LOOPS_OVER_OPTIONS, + pub FOR_LOOPS_OVER_OPTIONS_OR_RESULTS, complexity, "for loops over `Option`s or `Result`s with a single expression can be simplified" } @@ -532,7 +532,7 @@ declare_lint_pass!(Loops => [ EXPLICIT_INTO_ITER_LOOP, ITER_NEXT_LOOP, FOR_LOOPS_OVER_FALLIBLES, - FOR_LOOPS_OVER_OPTIONS, + FOR_LOOPS_OVER_OPTIONS_OR_RESULTS, WHILE_LET_LOOP, NEEDLESS_COLLECT, EXPLICIT_COUNTER_LOOP, @@ -2012,7 +2012,7 @@ fn check_for_loop_over_options_or_results<'tcx>( let arg_snippet = snippet(cx, arg.span, ".."); let msg = "looping over `Option`s or `Result`s with an `if let` expression."; let hint = format!("try turn {} into an `Iterator` and use `flatten`: `{}.iter().flatten()`", arg_snippet, arg_snippet); - span_lint_and_help(cx, FOR_LOOPS_OVER_OPTIONS, expr.span, msg, None, &hint); + span_lint_and_help(cx, FOR_LOOPS_OVER_OPTIONS_OR_RESULTS, expr.span, msg, None, &hint); } } } diff --git a/tests/ui/for_loops_over_options.rs b/tests/ui/for_loops_over_options_or_results.rs similarity index 92% rename from tests/ui/for_loops_over_options.rs rename to tests/ui/for_loops_over_options_or_results.rs index d8144864a..02e24b250 100644 --- a/tests/ui/for_loops_over_options.rs +++ b/tests/ui/for_loops_over_options_or_results.rs @@ -1,4 +1,4 @@ -#![warn(clippy::for_loops_over_options)] +#![warn(clippy::for_loops_over_options_or_results)] fn main() { let x = vec![Some(1), Some(2), Some(3)];