Skip to content

Commit 8d8178f

Browse files
committed
rename lint to manual_while_let_some
1 parent f10e39f commit 8d8178f

7 files changed

+21
-21
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4797,6 +4797,7 @@ Released 2018-09-13
47974797
[`manual_strip`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip
47984798
[`manual_swap`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
47994799
[`manual_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or
4800+
[`manual_while_let_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_while_let_some
48004801
[`many_single_char_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names
48014802
[`map_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_clone
48024803
[`map_collect_result_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_collect_result_unit
@@ -5160,7 +5161,6 @@ Released 2018-09-13
51605161
[`while_immutable_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_immutable_condition
51615162
[`while_let_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_loop
51625163
[`while_let_on_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator
5163-
[`while_pop_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_pop_unwrap
51645164
[`wildcard_dependencies`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_dependencies
51655165
[`wildcard_enum_match_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_enum_match_arm
51665166
[`wildcard_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports

clippy_lints/src/declared_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
249249
crate::loops::MANUAL_FIND_INFO,
250250
crate::loops::MANUAL_FLATTEN_INFO,
251251
crate::loops::MANUAL_MEMCPY_INFO,
252+
crate::loops::MANUAL_WHILE_LET_SOME_INFO,
252253
crate::loops::MISSING_SPIN_LOOP_INFO,
253254
crate::loops::MUT_RANGE_BOUND_INFO,
254255
crate::loops::NEEDLESS_RANGE_LOOP_INFO,
@@ -258,7 +259,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
258259
crate::loops::WHILE_IMMUTABLE_CONDITION_INFO,
259260
crate::loops::WHILE_LET_LOOP_INFO,
260261
crate::loops::WHILE_LET_ON_ITERATOR_INFO,
261-
crate::loops::WHILE_POP_UNWRAP_INFO,
262262
crate::macro_use::MACRO_USE_IMPORTS_INFO,
263263
crate::main_recursion::MAIN_RECURSION_INFO,
264264
crate::manual_assert::MANUAL_ASSERT_INFO,

clippy_lints/src/loops/while_pop_unwrap.rs renamed to clippy_lints/src/loops/manual_while_let_some.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_lint::LateContext;
1010
use rustc_span::Span;
1111
use std::borrow::Cow;
1212

13-
use super::WHILE_POP_UNWRAP;
13+
use super::MANUAL_WHILE_LET_SOME;
1414

1515
/// The kind of statement that the `pop()` call appeared in.
1616
///
@@ -31,7 +31,7 @@ enum PopStmt<'hir> {
3131
fn report_lint(cx: &LateContext<'_>, pop_span: Span, pop_stmt_kind: PopStmt<'_>, loop_span: Span, receiver_span: Span) {
3232
span_lint_and_then(
3333
cx,
34-
WHILE_POP_UNWRAP,
34+
MANUAL_WHILE_LET_SOME,
3535
pop_span,
3636
"you seem to be trying to pop elements from a `Vec` in a loop",
3737
|diag| {

clippy_lints/src/loops/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod iter_next_loop;
77
mod manual_find;
88
mod manual_flatten;
99
mod manual_memcpy;
10+
mod manual_while_let_some;
1011
mod missing_spin_loop;
1112
mod mut_range_bound;
1213
mod needless_range_loop;
@@ -17,7 +18,6 @@ mod utils;
1718
mod while_immutable_condition;
1819
mod while_let_loop;
1920
mod while_let_on_iterator;
20-
mod while_pop_unwrap;
2121

2222
use clippy_utils::higher;
2323
use rustc_hir::{Expr, ExprKind, LoopSource, Pat};
@@ -582,7 +582,7 @@ declare_clippy_lint! {
582582
/// in the body as a separate operation.
583583
///
584584
/// ### Why is this bad?
585-
/// Such loops can be written in a more idiomatic way by using a while..let loop and directly
585+
/// Such loops can be written in a more idiomatic way by using a while-let loop and directly
586586
/// pattern matching on the return value of `Vec::pop()`.
587587
///
588588
/// ### Example
@@ -601,7 +601,7 @@ declare_clippy_lint! {
601601
/// }
602602
/// ```
603603
#[clippy::version = "1.70.0"]
604-
pub WHILE_POP_UNWRAP,
604+
pub MANUAL_WHILE_LET_SOME,
605605
style,
606606
"checking for emptiness of a `Vec` in the loop condition and popping an element in the body"
607607
}
@@ -625,7 +625,7 @@ declare_lint_pass!(Loops => [
625625
SINGLE_ELEMENT_LOOP,
626626
MISSING_SPIN_LOOP,
627627
MANUAL_FIND,
628-
WHILE_POP_UNWRAP
628+
MANUAL_WHILE_LET_SOME
629629
]);
630630

631631
impl<'tcx> LateLintPass<'tcx> for Loops {
@@ -675,7 +675,7 @@ impl<'tcx> LateLintPass<'tcx> for Loops {
675675
if let Some(higher::While { condition, body, span }) = higher::While::hir(expr) {
676676
while_immutable_condition::check(cx, condition, body);
677677
missing_spin_loop::check(cx, condition, body);
678-
while_pop_unwrap::check(cx, condition, body, span);
678+
manual_while_let_some::check(cx, condition, body, span);
679679
}
680680
}
681681
}

tests/ui/while_pop_unwrap.fixed renamed to tests/ui/manual_while_let_some.fixed

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-rustfix
22

33
#![allow(unused)]
4-
#![warn(clippy::while_pop_unwrap)]
4+
#![warn(clippy::manual_while_let_some)]
55

66
struct VecInStruct {
77
numbers: Vec<i32>,
@@ -73,7 +73,7 @@ fn main() {
7373
}
7474
};
7575
}
76-
// Do not warn if the loop is in a macro.
76+
// Do not warn if the loop comes from a macro.
7777
generate_loop!();
7878

7979
// Try other kinds of patterns

tests/ui/while_pop_unwrap.rs renamed to tests/ui/manual_while_let_some.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-rustfix
22

33
#![allow(unused)]
4-
#![warn(clippy::while_pop_unwrap)]
4+
#![warn(clippy::manual_while_let_some)]
55

66
struct VecInStruct {
77
numbers: Vec<i32>,
@@ -73,7 +73,7 @@ fn main() {
7373
}
7474
};
7575
}
76-
// Do not warn if the loop is in a macro.
76+
// Do not warn if the loop comes from a macro.
7777
generate_loop!();
7878

7979
// Try other kinds of patterns

tests/ui/while_pop_unwrap.stderr renamed to tests/ui/manual_while_let_some.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
error: you seem to be trying to pop elements from a `Vec` in a loop
2-
--> $DIR/while_pop_unwrap.rs:23:9
2+
--> $DIR/manual_while_let_some.rs:23:9
33
|
44
LL | let number = numbers.pop().unwrap();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= note: `-D clippy::while-pop-unwrap` implied by `-D warnings`
7+
= note: `-D clippy::manual-while-let-some` implied by `-D warnings`
88
help: consider using a `while..let` loop
99
|
1010
LL ~ while let Some(number) = numbers.pop() {
1111
LL ~
1212
|
1313

1414
error: you seem to be trying to pop elements from a `Vec` in a loop
15-
--> $DIR/while_pop_unwrap.rs:31:9
15+
--> $DIR/manual_while_let_some.rs:31:9
1616
|
1717
LL | let number = val.numbers.pop().unwrap();
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -24,7 +24,7 @@ LL ~
2424
|
2525

2626
error: you seem to be trying to pop elements from a `Vec` in a loop
27-
--> $DIR/while_pop_unwrap.rs:35:20
27+
--> $DIR/manual_while_let_some.rs:35:20
2828
|
2929
LL | accept_i32(numbers.pop().unwrap());
3030
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -36,7 +36,7 @@ LL ~ accept_i32(element);
3636
|
3737

3838
error: you seem to be trying to pop elements from a `Vec` in a loop
39-
--> $DIR/while_pop_unwrap.rs:39:20
39+
--> $DIR/manual_while_let_some.rs:39:20
4040
|
4141
LL | accept_i32(numbers.pop().expect(""));
4242
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -48,7 +48,7 @@ LL ~ accept_i32(element);
4848
|
4949

5050
error: you seem to be trying to pop elements from a `Vec` in a loop
51-
--> $DIR/while_pop_unwrap.rs:82:9
51+
--> $DIR/manual_while_let_some.rs:82:9
5252
|
5353
LL | let (a, b) = numbers.pop().unwrap();
5454
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -60,7 +60,7 @@ LL ~
6060
|
6161

6262
error: you seem to be trying to pop elements from a `Vec` in a loop
63-
--> $DIR/while_pop_unwrap.rs:86:26
63+
--> $DIR/manual_while_let_some.rs:86:26
6464
|
6565
LL | accept_i32_tuple(numbers.pop().unwrap());
6666
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -72,7 +72,7 @@ LL ~ accept_i32_tuple(element);
7272
|
7373

7474
error: you seem to be trying to pop elements from a `Vec` in a loop
75-
--> $DIR/while_pop_unwrap.rs:91:9
75+
--> $DIR/manual_while_let_some.rs:91:9
7676
|
7777
LL | let Foo { a, b } = results.pop().unwrap();
7878
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)