Skip to content

Commit 8f30cb2

Browse files
committed
iter conservation efforts: save the endangered .iter() and .into_iter()
Make explicit_iter_loop and explicit_into_iter_loop allow-by-default, so that people can turn them on if they want to enforce that style; avoid presenting them as *the* idiomatic Rust style, rather than just *a* style.
1 parent 2b7a530 commit 8f30cb2

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

clippy_lints/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
449449
if_not_else::IF_NOT_ELSE,
450450
infinite_iter::MAYBE_INFINITE_ITER,
451451
items_after_statements::ITEMS_AFTER_STATEMENTS,
452+
loops::EXPLICIT_INTO_ITER_LOOP,
453+
loops::EXPLICIT_ITER_LOOP,
452454
matches::SINGLE_MATCH_ELSE,
453455
methods::FILTER_MAP,
454456
methods::OPTION_MAP_UNWRAP_OR,
@@ -546,8 +548,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
546548
literal_representation::UNREADABLE_LITERAL,
547549
loops::EMPTY_LOOP,
548550
loops::EXPLICIT_COUNTER_LOOP,
549-
loops::EXPLICIT_INTO_ITER_LOOP,
550-
loops::EXPLICIT_ITER_LOOP,
551551
loops::FOR_KV_MAP,
552552
loops::FOR_LOOP_OVER_OPTION,
553553
loops::FOR_LOOP_OVER_RESULT,
@@ -718,8 +718,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
718718
literal_representation::LARGE_DIGIT_GROUPS,
719719
literal_representation::UNREADABLE_LITERAL,
720720
loops::EMPTY_LOOP,
721-
loops::EXPLICIT_INTO_ITER_LOOP,
722-
loops::EXPLICIT_ITER_LOOP,
723721
loops::FOR_KV_MAP,
724722
loops::NEEDLESS_RANGE_LOOP,
725723
loops::WHILE_LET_ON_ITERATOR,

clippy_lints/src/loops.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ declare_clippy_lint! {
8585
/// ```
8686
declare_clippy_lint! {
8787
pub EXPLICIT_ITER_LOOP,
88-
style,
88+
pedantic,
8989
"for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do"
9090
}
9191

@@ -107,7 +107,7 @@ declare_clippy_lint! {
107107
/// ```
108108
declare_clippy_lint! {
109109
pub EXPLICIT_INTO_ITER_LOOP,
110-
style,
110+
pedantic,
111111
"for-looping over `_.into_iter()` when `_` would do"
112112
}
113113

@@ -1209,7 +1209,7 @@ fn lint_iter_method(cx: &LateContext<'_, '_>, args: &[Expr], arg: &Expr, method_
12091209
cx,
12101210
EXPLICIT_ITER_LOOP,
12111211
arg.span,
1212-
"it is more idiomatic to loop over references to containers instead of using explicit \
1212+
"it is more concise to loop over references to containers instead of using explicit \
12131213
iteration methods",
12141214
"to write this more concisely, try",
12151215
format!("&{}{}", muta, object),
@@ -1247,7 +1247,7 @@ fn check_for_loop_arg(cx: &LateContext<'_, '_>, pat: &Pat, arg: &Expr, expr: &Ex
12471247
cx,
12481248
EXPLICIT_INTO_ITER_LOOP,
12491249
arg.span,
1250-
"it is more idiomatic to loop over containers instead of using explicit \
1250+
"it is more concise to loop over containers instead of using explicit \
12511251
iteration methods`",
12521252
"to write this more concisely, try",
12531253
object.to_string(),

0 commit comments

Comments
 (0)