about summary refs log tree commit diff
diff options
context:
space:
mode:
authory21 <30553356+y21@users.noreply.github.com>2023-04-19 22:26:50 +0200
committery21 <30553356+y21@users.noreply.github.com>2023-04-29 18:59:07 +0200
commit8d8178f93184d09cf1e3f813257d6aeb19d08c57 (patch)
tree534c4d56ebf804a3d22d7b9e4abe12167d800f47
parentf10e39fd2be243b7f0d4f82f56420ba1cbd4a7bb (diff)
downloadrust-8d8178f93184d09cf1e3f813257d6aeb19d08c57.tar.gz
rust-8d8178f93184d09cf1e3f813257d6aeb19d08c57.zip
rename lint to `manual_while_let_some`
-rw-r--r--CHANGELOG.md2
-rw-r--r--clippy_lints/src/declared_lints.rs2
-rw-r--r--clippy_lints/src/loops/manual_while_let_some.rs (renamed from clippy_lints/src/loops/while_pop_unwrap.rs)4
-rw-r--r--clippy_lints/src/loops/mod.rs10
-rw-r--r--tests/ui/manual_while_let_some.fixed (renamed from tests/ui/while_pop_unwrap.fixed)4
-rw-r--r--tests/ui/manual_while_let_some.rs (renamed from tests/ui/while_pop_unwrap.rs)4
-rw-r--r--tests/ui/manual_while_let_some.stderr (renamed from tests/ui/while_pop_unwrap.stderr)16
7 files changed, 21 insertions, 21 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index da03f5c012b..d1e98a93940 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4797,6 +4797,7 @@ Released 2018-09-13
 [`manual_strip`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip
 [`manual_swap`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
 [`manual_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or
+[`manual_while_let_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_while_let_some
 [`many_single_char_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names
 [`map_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#map_clone
 [`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
 [`while_immutable_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_immutable_condition
 [`while_let_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_loop
 [`while_let_on_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator
-[`while_pop_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_pop_unwrap
 [`wildcard_dependencies`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_dependencies
 [`wildcard_enum_match_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_enum_match_arm
 [`wildcard_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports
diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs
index ff418092e4b..44e725be710 100644
--- a/clippy_lints/src/declared_lints.rs
+++ b/clippy_lints/src/declared_lints.rs
@@ -249,6 +249,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
     crate::loops::MANUAL_FIND_INFO,
     crate::loops::MANUAL_FLATTEN_INFO,
     crate::loops::MANUAL_MEMCPY_INFO,
+    crate::loops::MANUAL_WHILE_LET_SOME_INFO,
     crate::loops::MISSING_SPIN_LOOP_INFO,
     crate::loops::MUT_RANGE_BOUND_INFO,
     crate::loops::NEEDLESS_RANGE_LOOP_INFO,
@@ -258,7 +259,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
     crate::loops::WHILE_IMMUTABLE_CONDITION_INFO,
     crate::loops::WHILE_LET_LOOP_INFO,
     crate::loops::WHILE_LET_ON_ITERATOR_INFO,
-    crate::loops::WHILE_POP_UNWRAP_INFO,
     crate::macro_use::MACRO_USE_IMPORTS_INFO,
     crate::main_recursion::MAIN_RECURSION_INFO,
     crate::manual_assert::MANUAL_ASSERT_INFO,
diff --git a/clippy_lints/src/loops/while_pop_unwrap.rs b/clippy_lints/src/loops/manual_while_let_some.rs
index 3a583396230..cb9c84be4c7 100644
--- a/clippy_lints/src/loops/while_pop_unwrap.rs
+++ b/clippy_lints/src/loops/manual_while_let_some.rs
@@ -10,7 +10,7 @@ use rustc_lint::LateContext;
 use rustc_span::Span;
 use std::borrow::Cow;
 
-use super::WHILE_POP_UNWRAP;
+use super::MANUAL_WHILE_LET_SOME;
 
 /// The kind of statement that the `pop()` call appeared in.
 ///
@@ -31,7 +31,7 @@ enum PopStmt<'hir> {
 fn report_lint(cx: &LateContext<'_>, pop_span: Span, pop_stmt_kind: PopStmt<'_>, loop_span: Span, receiver_span: Span) {
     span_lint_and_then(
         cx,
-        WHILE_POP_UNWRAP,
+        MANUAL_WHILE_LET_SOME,
         pop_span,
         "you seem to be trying to pop elements from a `Vec` in a loop",
         |diag| {
diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs
index 02197e9c187..f83ad388a74 100644
--- a/clippy_lints/src/loops/mod.rs
+++ b/clippy_lints/src/loops/mod.rs
@@ -7,6 +7,7 @@ mod iter_next_loop;
 mod manual_find;
 mod manual_flatten;
 mod manual_memcpy;
+mod manual_while_let_some;
 mod missing_spin_loop;
 mod mut_range_bound;
 mod needless_range_loop;
@@ -17,7 +18,6 @@ mod utils;
 mod while_immutable_condition;
 mod while_let_loop;
 mod while_let_on_iterator;
-mod while_pop_unwrap;
 
 use clippy_utils::higher;
 use rustc_hir::{Expr, ExprKind, LoopSource, Pat};
@@ -582,7 +582,7 @@ declare_clippy_lint! {
     /// in the body as a separate operation.
     ///
     /// ### Why is this bad?
-    /// Such loops can be written in a more idiomatic way by using a while..let loop and directly
+    /// Such loops can be written in a more idiomatic way by using a while-let loop and directly
     /// pattern matching on the return value of `Vec::pop()`.
     ///
     /// ### Example
@@ -601,7 +601,7 @@ declare_clippy_lint! {
     /// }
     /// ```
     #[clippy::version = "1.70.0"]
-    pub WHILE_POP_UNWRAP,
+    pub MANUAL_WHILE_LET_SOME,
     style,
     "checking for emptiness of a `Vec` in the loop condition and popping an element in the body"
 }
@@ -625,7 +625,7 @@ declare_lint_pass!(Loops => [
     SINGLE_ELEMENT_LOOP,
     MISSING_SPIN_LOOP,
     MANUAL_FIND,
-    WHILE_POP_UNWRAP
+    MANUAL_WHILE_LET_SOME
 ]);
 
 impl<'tcx> LateLintPass<'tcx> for Loops {
@@ -675,7 +675,7 @@ impl<'tcx> LateLintPass<'tcx> for Loops {
         if let Some(higher::While { condition, body, span }) = higher::While::hir(expr) {
             while_immutable_condition::check(cx, condition, body);
             missing_spin_loop::check(cx, condition, body);
-            while_pop_unwrap::check(cx, condition, body, span);
+            manual_while_let_some::check(cx, condition, body, span);
         }
     }
 }
diff --git a/tests/ui/while_pop_unwrap.fixed b/tests/ui/manual_while_let_some.fixed
index a635e054e6e..75738209bad 100644
--- a/tests/ui/while_pop_unwrap.fixed
+++ b/tests/ui/manual_while_let_some.fixed
@@ -1,7 +1,7 @@
 // run-rustfix
 
 #![allow(unused)]
-#![warn(clippy::while_pop_unwrap)]
+#![warn(clippy::manual_while_let_some)]
 
 struct VecInStruct {
     numbers: Vec<i32>,
@@ -73,7 +73,7 @@ fn main() {
             }
         };
     }
-    // Do not warn if the loop is in a macro.
+    // Do not warn if the loop comes from a macro.
     generate_loop!();
 
     // Try other kinds of patterns
diff --git a/tests/ui/while_pop_unwrap.rs b/tests/ui/manual_while_let_some.rs
index 820ff211086..142c1471598 100644
--- a/tests/ui/while_pop_unwrap.rs
+++ b/tests/ui/manual_while_let_some.rs
@@ -1,7 +1,7 @@
 // run-rustfix
 
 #![allow(unused)]
-#![warn(clippy::while_pop_unwrap)]
+#![warn(clippy::manual_while_let_some)]
 
 struct VecInStruct {
     numbers: Vec<i32>,
@@ -73,7 +73,7 @@ fn main() {
             }
         };
     }
-    // Do not warn if the loop is in a macro.
+    // Do not warn if the loop comes from a macro.
     generate_loop!();
 
     // Try other kinds of patterns
diff --git a/tests/ui/while_pop_unwrap.stderr b/tests/ui/manual_while_let_some.stderr
index f8a6cfcda0e..633fe05c49b 100644
--- a/tests/ui/while_pop_unwrap.stderr
+++ b/tests/ui/manual_while_let_some.stderr
@@ -1,10 +1,10 @@
 error: you seem to be trying to pop elements from a `Vec` in a loop
-  --> $DIR/while_pop_unwrap.rs:23:9
+  --> $DIR/manual_while_let_some.rs:23:9
    |
 LL |         let number = numbers.pop().unwrap();
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: `-D clippy::while-pop-unwrap` implied by `-D warnings`
+   = note: `-D clippy::manual-while-let-some` implied by `-D warnings`
 help: consider using a `while..let` loop
    |
 LL ~     while let Some(number) = numbers.pop() {
@@ -12,7 +12,7 @@ LL ~
    |
 
 error: you seem to be trying to pop elements from a `Vec` in a loop
-  --> $DIR/while_pop_unwrap.rs:31:9
+  --> $DIR/manual_while_let_some.rs:31:9
    |
 LL |         let number = val.numbers.pop().unwrap();
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -24,7 +24,7 @@ LL ~
    |
 
 error: you seem to be trying to pop elements from a `Vec` in a loop
-  --> $DIR/while_pop_unwrap.rs:35:20
+  --> $DIR/manual_while_let_some.rs:35:20
    |
 LL |         accept_i32(numbers.pop().unwrap());
    |                    ^^^^^^^^^^^^^^^^^^^^^^
@@ -36,7 +36,7 @@ LL ~         accept_i32(element);
    |
 
 error: you seem to be trying to pop elements from a `Vec` in a loop
-  --> $DIR/while_pop_unwrap.rs:39:20
+  --> $DIR/manual_while_let_some.rs:39:20
    |
 LL |         accept_i32(numbers.pop().expect(""));
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -48,7 +48,7 @@ LL ~         accept_i32(element);
    |
 
 error: you seem to be trying to pop elements from a `Vec` in a loop
-  --> $DIR/while_pop_unwrap.rs:82:9
+  --> $DIR/manual_while_let_some.rs:82:9
    |
 LL |         let (a, b) = numbers.pop().unwrap();
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -60,7 +60,7 @@ LL ~
    |
 
 error: you seem to be trying to pop elements from a `Vec` in a loop
-  --> $DIR/while_pop_unwrap.rs:86:26
+  --> $DIR/manual_while_let_some.rs:86:26
    |
 LL |         accept_i32_tuple(numbers.pop().unwrap());
    |                          ^^^^^^^^^^^^^^^^^^^^^^
@@ -72,7 +72,7 @@ LL ~         accept_i32_tuple(element);
    |
 
 error: you seem to be trying to pop elements from a `Vec` in a loop
-  --> $DIR/while_pop_unwrap.rs:91:9
+  --> $DIR/manual_while_let_some.rs:91:9
    |
 LL |         let Foo { a, b } = results.pop().unwrap();
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^