Rename lint

This commit is contained in:
nahuakang 2021-01-27 09:49:53 +01:00
parent 5753614152
commit 3da25ed955
4 changed files with 9 additions and 8 deletions

View file

@ -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 [`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_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_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_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 [`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 [`from_iter_instead_of_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect

View file

@ -685,7 +685,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
&loops::EXPLICIT_ITER_LOOP, &loops::EXPLICIT_ITER_LOOP,
&loops::FOR_KV_MAP, &loops::FOR_KV_MAP,
&loops::FOR_LOOPS_OVER_FALLIBLES, &loops::FOR_LOOPS_OVER_FALLIBLES,
&loops::FOR_LOOPS_OVER_OPTIONS, &loops::FOR_LOOPS_OVER_OPTIONS_OR_RESULTS,
&loops::ITER_NEXT_LOOP, &loops::ITER_NEXT_LOOP,
&loops::MANUAL_MEMCPY, &loops::MANUAL_MEMCPY,
&loops::MUT_RANGE_BOUND, &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::EXPLICIT_COUNTER_LOOP),
LintId::of(&loops::FOR_KV_MAP), LintId::of(&loops::FOR_KV_MAP),
LintId::of(&loops::FOR_LOOPS_OVER_FALLIBLES), 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::ITER_NEXT_LOOP),
LintId::of(&loops::MANUAL_MEMCPY), LintId::of(&loops::MANUAL_MEMCPY),
LintId::of(&loops::MUT_RANGE_BOUND), 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::EXTRA_UNUSED_LIFETIMES),
LintId::of(&lifetimes::NEEDLESS_LIFETIMES), LintId::of(&lifetimes::NEEDLESS_LIFETIMES),
LintId::of(&loops::EXPLICIT_COUNTER_LOOP), 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::MUT_RANGE_BOUND),
LintId::of(&loops::SINGLE_ELEMENT_LOOP), LintId::of(&loops::SINGLE_ELEMENT_LOOP),
LintId::of(&loops::WHILE_LET_LOOP), LintId::of(&loops::WHILE_LET_LOOP),

View file

@ -520,7 +520,7 @@ declare_clippy_lint! {
/// println!("{}", n); /// println!("{}", n);
/// } /// }
/// ``` /// ```
pub FOR_LOOPS_OVER_OPTIONS, pub FOR_LOOPS_OVER_OPTIONS_OR_RESULTS,
complexity, complexity,
"for loops over `Option`s or `Result`s with a single expression can be simplified" "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, EXPLICIT_INTO_ITER_LOOP,
ITER_NEXT_LOOP, ITER_NEXT_LOOP,
FOR_LOOPS_OVER_FALLIBLES, FOR_LOOPS_OVER_FALLIBLES,
FOR_LOOPS_OVER_OPTIONS, FOR_LOOPS_OVER_OPTIONS_OR_RESULTS,
WHILE_LET_LOOP, WHILE_LET_LOOP,
NEEDLESS_COLLECT, NEEDLESS_COLLECT,
EXPLICIT_COUNTER_LOOP, EXPLICIT_COUNTER_LOOP,
@ -2012,7 +2012,7 @@ fn check_for_loop_over_options_or_results<'tcx>(
let arg_snippet = snippet(cx, arg.span, ".."); let arg_snippet = snippet(cx, arg.span, "..");
let msg = "looping over `Option`s or `Result`s with an `if let` expression."; 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); 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);
} }
} }
} }

View file

@ -1,4 +1,4 @@
#![warn(clippy::for_loops_over_options)] #![warn(clippy::for_loops_over_options_or_results)]
fn main() { fn main() {
let x = vec![Some(1), Some(2), Some(3)]; let x = vec![Some(1), Some(2), Some(3)];