From 558f49d7aae7142864ee98fb26e593c12c1a3cd3 Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Fri, 28 Jul 2023 18:09:12 -0700 Subject: [PATCH 1/5] inline trivial (noop) flush calls --- library/std/src/fs.rs | 3 +++ library/std/src/io/readbuf.rs | 1 + library/std/src/net/tcp.rs | 2 ++ library/std/src/os/unix/net/stream.rs | 1 + library/std/src/process.rs | 2 ++ library/std/src/sys/hermit/fs.rs | 1 + library/std/src/sys/unix/fs.rs | 1 + library/std/src/sys/unix/stdio.rs | 2 ++ 8 files changed, 13 insertions(+) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 0f79e74f55552..a7e65305386ee 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -791,6 +791,7 @@ impl Write for &File { self.inner.is_write_vectored() } + #[inline] fn flush(&mut self) -> io::Result<()> { self.inner.flush() } @@ -836,6 +837,7 @@ impl Write for File { fn is_write_vectored(&self) -> bool { (&&*self).is_write_vectored() } + #[inline] fn flush(&mut self) -> io::Result<()> { (&*self).flush() } @@ -881,6 +883,7 @@ impl Write for Arc { fn is_write_vectored(&self) -> bool { (&**self).is_write_vectored() } + #[inline] fn flush(&mut self) -> io::Result<()> { (&**self).flush() } diff --git a/library/std/src/io/readbuf.rs b/library/std/src/io/readbuf.rs index 1f3f80b9618e1..034ddd8df9aed 100644 --- a/library/std/src/io/readbuf.rs +++ b/library/std/src/io/readbuf.rs @@ -310,6 +310,7 @@ impl<'a> Write for BorrowedCursor<'a> { Ok(buf.len()) } + #[inline] fn flush(&mut self) -> Result<()> { Ok(()) } diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index 141a18a42dde6..32fd54c8e7510 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -647,6 +647,7 @@ impl Write for TcpStream { self.0.is_write_vectored() } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) } @@ -685,6 +686,7 @@ impl Write for &TcpStream { self.0.is_write_vectored() } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) } diff --git a/library/std/src/os/unix/net/stream.rs b/library/std/src/os/unix/net/stream.rs index e20170873bbbd..41290e0017ac3 100644 --- a/library/std/src/os/unix/net/stream.rs +++ b/library/std/src/os/unix/net/stream.rs @@ -712,6 +712,7 @@ impl<'a> io::Write for &'a UnixStream { self.0.is_write_vectored() } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) } diff --git a/library/std/src/process.rs b/library/std/src/process.rs index f9cb755b01a3a..789ec7e55997a 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -280,6 +280,7 @@ impl Write for ChildStdin { io::Write::is_write_vectored(&&*self) } + #[inline] fn flush(&mut self) -> io::Result<()> { (&*self).flush() } @@ -299,6 +300,7 @@ impl Write for &ChildStdin { self.inner.is_write_vectored() } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) } diff --git a/library/std/src/sys/hermit/fs.rs b/library/std/src/sys/hermit/fs.rs index 4bb735668d24c..6aa4ea7f5b4fb 100644 --- a/library/std/src/sys/hermit/fs.rs +++ b/library/std/src/sys/hermit/fs.rs @@ -335,6 +335,7 @@ impl File { false } + #[inline] pub fn flush(&self) -> io::Result<()> { Ok(()) } diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index fbc7f04ce9ae0..625f351fdef3a 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -1227,6 +1227,7 @@ impl File { self.0.write_vectored_at(bufs, offset) } + #[inline] pub fn flush(&self) -> io::Result<()> { Ok(()) } diff --git a/library/std/src/sys/unix/stdio.rs b/library/std/src/sys/unix/stdio.rs index a26f20795a191..97e75f1b5b669 100644 --- a/library/std/src/sys/unix/stdio.rs +++ b/library/std/src/sys/unix/stdio.rs @@ -54,6 +54,7 @@ impl io::Write for Stdout { true } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) } @@ -81,6 +82,7 @@ impl io::Write for Stderr { true } + #[inline] fn flush(&mut self) -> io::Result<()> { Ok(()) } From 80277dd8f2cc1bd1b30b0c1df86b5838ca83f87b Mon Sep 17 00:00:00 2001 From: Ryan Lowe Date: Sun, 30 Jul 2023 11:21:24 -0400 Subject: [PATCH 2/5] Avoid using ptr::Unique in LinkedList code --- library/alloc/src/collections/linked_list.rs | 24 +++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index 052edf453f679..2c26f9e031244 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -18,7 +18,7 @@ use core::hash::{Hash, Hasher}; use core::iter::FusedIterator; use core::marker::PhantomData; use core::mem; -use core::ptr::{NonNull, Unique}; +use core::ptr::NonNull; use super::SpecExtend; use crate::alloc::{Allocator, Global}; @@ -168,15 +168,16 @@ impl LinkedList { /// Adds the given node to the front of the list. /// /// # Safety - /// `node` must point to a valid node that was boxed using the list's allocator. + /// `node` must point to a valid node that was boxed and leaked using the list's allocator. + /// This method takes ownership of the node, so the pointer should not be used again. #[inline] - unsafe fn push_front_node(&mut self, node: Unique>) { + unsafe fn push_front_node(&mut self, node: NonNull>) { // This method takes care not to create mutable references to whole nodes, // to maintain validity of aliasing pointers into `element`. unsafe { (*node.as_ptr()).next = self.head; (*node.as_ptr()).prev = None; - let node = Some(NonNull::from(node)); + let node = Some(node); match self.head { None => self.tail = node, @@ -212,15 +213,16 @@ impl LinkedList { /// Adds the given node to the back of the list. /// /// # Safety - /// `node` must point to a valid node that was boxed using the list's allocator. + /// `node` must point to a valid node that was boxed and leaked using the list's allocator. + /// This method takes ownership of the node, so the pointer should not be used again. #[inline] - unsafe fn push_back_node(&mut self, node: Unique>) { + unsafe fn push_back_node(&mut self, node: NonNull>) { // This method takes care not to create mutable references to whole nodes, // to maintain validity of aliasing pointers into `element`. unsafe { (*node.as_ptr()).next = None; (*node.as_ptr()).prev = self.tail; - let node = Some(NonNull::from(node)); + let node = Some(node); match self.tail { None => self.head = node, @@ -842,8 +844,8 @@ impl LinkedList { #[stable(feature = "rust1", since = "1.0.0")] pub fn push_front(&mut self, elt: T) { let node = Box::new_in(Node::new(elt), &self.alloc); - let node_ptr = Unique::from(Box::leak(node)); - // SAFETY: node_ptr is a unique pointer to a node we boxed with self.alloc + let node_ptr = NonNull::from(Box::leak(node)); + // SAFETY: node_ptr is a unique pointer to a node we boxed with self.alloc and leaked unsafe { self.push_front_node(node_ptr); } @@ -890,8 +892,8 @@ impl LinkedList { #[stable(feature = "rust1", since = "1.0.0")] pub fn push_back(&mut self, elt: T) { let node = Box::new_in(Node::new(elt), &self.alloc); - let node_ptr = Unique::from(Box::leak(node)); - // SAFETY: node_ptr is a unique pointer to a node we boxed with self.alloc + let node_ptr = NonNull::from(Box::leak(node)); + // SAFETY: node_ptr is a unique pointer to a node we boxed with self.alloc and leaked unsafe { self.push_back_node(node_ptr); } From a090e97f686a927f7f0e1efead7bfedf86194685 Mon Sep 17 00:00:00 2001 From: Taras Tsugrii Date: Tue, 1 Aug 2023 21:53:21 -0700 Subject: [PATCH 3/5] [library/std] Replace condv while loop with `cvar.wait_while`. `wait_while` takes care of spurious wake-ups in centralized place, reducing chances for mistakes and potential future optimizations (who knows, maybe in future there will be no spurious wake-ups? :) --- library/std/src/sync/barrier.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/library/std/src/sync/barrier.rs b/library/std/src/sync/barrier.rs index e39254aa43491..ed3c55120847f 100644 --- a/library/std/src/sync/barrier.rs +++ b/library/std/src/sync/barrier.rs @@ -130,11 +130,8 @@ impl Barrier { let local_gen = lock.generation_id; lock.count += 1; if lock.count < self.num_threads { - // We need a while loop to guard against spurious wakeups. - // https://en.wikipedia.org/wiki/Spurious_wakeup - while local_gen == lock.generation_id { - lock = self.cvar.wait(lock).unwrap(); - } + let _guard = + self.cvar.wait_while(lock, |state| local_gen == state.generation_id).unwrap(); BarrierWaitResult(false) } else { lock.count = 0; From f1fc871ce6b9e9f3549745043f28b54aa367d662 Mon Sep 17 00:00:00 2001 From: July Tikhonov Date: Thu, 3 Aug 2023 10:44:23 +0300 Subject: [PATCH 4/5] Fix documentation of Rc as From> --- library/alloc/src/rc.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 60b07485c3a8e..afed3fdf7459f 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -2491,9 +2491,9 @@ impl From> for Rc<[T], A> { /// /// ``` /// # use std::rc::Rc; - /// let original: Box> = Box::new(vec![1, 2, 3]); - /// let shared: Rc> = Rc::from(original); - /// assert_eq!(vec![1, 2, 3], *shared); + /// let unique: Vec = vec![1, 2, 3]; + /// let shared: Rc<[i32]> = Rc::from(unique); + /// assert_eq!(&[1, 2, 3], &shared[..]); /// ``` #[inline] fn from(v: Vec) -> Rc<[T], A> { From c0ae75bf37e67790775f26a1b68d582efa171787 Mon Sep 17 00:00:00 2001 From: Catherine Flores Date: Thu, 10 Aug 2023 22:03:20 +0000 Subject: [PATCH 5/5] Revert "New lint [`filter_map_bool_then`]" This reverts commits 978b1daf99d8326718684381704902fdaaf71b18 and 3235d9d612909bc64550eea3a0d387e1187e93dd. --- src/tools/clippy/CHANGELOG.md | 1 - .../clippy/clippy_lints/src/declared_lints.rs | 1 - .../src/methods/filter_map_bool_then.rs | 45 ------------------- .../clippy/clippy_lints/src/methods/mod.rs | 34 -------------- src/tools/clippy/clippy_utils/src/paths.rs | 2 - .../tests/ui/filter_map_bool_then.fixed | 44 ------------------ .../clippy/tests/ui/filter_map_bool_then.rs | 44 ------------------ .../tests/ui/filter_map_bool_then.stderr | 34 -------------- 8 files changed, 205 deletions(-) delete mode 100644 src/tools/clippy/clippy_lints/src/methods/filter_map_bool_then.rs delete mode 100644 src/tools/clippy/tests/ui/filter_map_bool_then.fixed delete mode 100644 src/tools/clippy/tests/ui/filter_map_bool_then.rs delete mode 100644 src/tools/clippy/tests/ui/filter_map_bool_then.stderr diff --git a/src/tools/clippy/CHANGELOG.md b/src/tools/clippy/CHANGELOG.md index 2655d93599e7e..6357511cc4cbb 100644 --- a/src/tools/clippy/CHANGELOG.md +++ b/src/tools/clippy/CHANGELOG.md @@ -4844,7 +4844,6 @@ Released 2018-09-13 [`field_reassign_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default [`filetype_is_file`]: https://rust-lang.github.io/rust-clippy/master/index.html#filetype_is_file [`filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map -[`filter_map_bool_then`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_bool_then [`filter_map_identity`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_identity [`filter_map_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_next [`filter_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_next diff --git a/src/tools/clippy/clippy_lints/src/declared_lints.rs b/src/tools/clippy/clippy_lints/src/declared_lints.rs index d4e0d2863348b..9a9998cca4ac7 100644 --- a/src/tools/clippy/clippy_lints/src/declared_lints.rs +++ b/src/tools/clippy/clippy_lints/src/declared_lints.rs @@ -337,7 +337,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::methods::EXPECT_USED_INFO, crate::methods::EXTEND_WITH_DRAIN_INFO, crate::methods::FILETYPE_IS_FILE_INFO, - crate::methods::FILTER_MAP_BOOL_THEN_INFO, crate::methods::FILTER_MAP_IDENTITY_INFO, crate::methods::FILTER_MAP_NEXT_INFO, crate::methods::FILTER_NEXT_INFO, diff --git a/src/tools/clippy/clippy_lints/src/methods/filter_map_bool_then.rs b/src/tools/clippy/clippy_lints/src/methods/filter_map_bool_then.rs deleted file mode 100644 index 4aee22a4afc3b..0000000000000 --- a/src/tools/clippy/clippy_lints/src/methods/filter_map_bool_then.rs +++ /dev/null @@ -1,45 +0,0 @@ -use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::paths::BOOL_THEN; -use clippy_utils::source::snippet_opt; -use clippy_utils::ty::is_copy; -use clippy_utils::{is_from_proc_macro, is_trait_method, match_def_path, peel_blocks}; -use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind}; -use rustc_lint::{LateContext, LintContext}; -use rustc_middle::lint::in_external_macro; -use rustc_span::{sym, Span}; - -use super::FILTER_MAP_BOOL_THEN; - -pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, arg: &Expr<'_>, call_span: Span) { - if !in_external_macro(cx.sess(), expr.span) - && is_trait_method(cx, expr, sym::Iterator) - && let ExprKind::Closure(closure) = arg.kind - && let body = cx.tcx.hir().body(closure.body) - && let value = peel_blocks(body.value) - // Indexing should be fine as `filter_map` always has 1 input, we unfortunately need both - // `inputs` and `params` here as we need both the type and the span - && let param_ty = closure.fn_decl.inputs[0] - && let param = body.params[0] - && is_copy(cx, cx.typeck_results().node_type(param_ty.hir_id).peel_refs()) - && let ExprKind::MethodCall(_, recv, [then_arg], _) = value.kind - && let ExprKind::Closure(then_closure) = then_arg.kind - && let then_body = peel_blocks(cx.tcx.hir().body(then_closure.body).value) - && let Some(def_id) = cx.typeck_results().type_dependent_def_id(value.hir_id) - && match_def_path(cx, def_id, &BOOL_THEN) - && !is_from_proc_macro(cx, expr) - && let Some(param_snippet) = snippet_opt(cx, param.span) - && let Some(filter) = snippet_opt(cx, recv.span) - && let Some(map) = snippet_opt(cx, then_body.span) - { - span_lint_and_sugg( - cx, - FILTER_MAP_BOOL_THEN, - call_span, - "usage of `bool::then` in `filter_map`", - "use `filter` then `map` instead", - format!("filter(|&{param_snippet}| {filter}).map(|{param_snippet}| {map})"), - Applicability::MachineApplicable, - ); - } -} diff --git a/src/tools/clippy/clippy_lints/src/methods/mod.rs b/src/tools/clippy/clippy_lints/src/methods/mod.rs index dd694ce7393e2..28a8978973fed 100644 --- a/src/tools/clippy/clippy_lints/src/methods/mod.rs +++ b/src/tools/clippy/clippy_lints/src/methods/mod.rs @@ -21,7 +21,6 @@ mod expect_used; mod extend_with_drain; mod filetype_is_file; mod filter_map; -mod filter_map_bool_then; mod filter_map_identity; mod filter_map_next; mod filter_next; @@ -3477,37 +3476,6 @@ declare_clippy_lint! { "disallows `.skip(0)`" } -declare_clippy_lint! { - /// ### What it does - /// Checks for usage of `bool::then` in `Iterator::filter_map`. - /// - /// ### Why is this bad? - /// This can be written with `filter` then `map` instead, which would reduce nesting and - /// separates the filtering from the transformation phase. This comes with no cost to - /// performance and is just cleaner. - /// - /// ### Limitations - /// Does not lint `bool::then_some`, as it eagerly evaluates its arguments rather than lazily. - /// This can create differing behavior, so better safe than sorry. - /// - /// ### Example - /// ```rust - /// # fn really_expensive_fn(i: i32) -> i32 { i } - /// # let v = vec![]; - /// _ = v.into_iter().filter_map(|i| (i % 2 == 0).then(|| really_expensive_fn(i))); - /// ``` - /// Use instead: - /// ```rust - /// # fn really_expensive_fn(i: i32) -> i32 { i } - /// # let v = vec![]; - /// _ = v.into_iter().filter(|i| i % 2 == 0).map(|i| really_expensive_fn(i)); - /// ``` - #[clippy::version = "1.72.0"] - pub FILTER_MAP_BOOL_THEN, - style, - "checks for usage of `bool::then` in `Iterator::filter_map`" -} - declare_clippy_lint! { /// ### What it does /// Looks for calls to `RwLock::write` where the lock is only used for reading. @@ -3676,7 +3644,6 @@ impl_lint_pass!(Methods => [ FORMAT_COLLECT, STRING_LIT_CHARS_ANY, ITER_SKIP_ZERO, - FILTER_MAP_BOOL_THEN, READONLY_WRITE_LOCK ]); @@ -3955,7 +3922,6 @@ impl Methods { }, ("filter_map", [arg]) => { unnecessary_filter_map::check(cx, expr, arg, name); - filter_map_bool_then::check(cx, expr, arg, call_span); filter_map_identity::check(cx, expr, arg, span); }, ("find_map", [arg]) => { diff --git a/src/tools/clippy/clippy_utils/src/paths.rs b/src/tools/clippy/clippy_utils/src/paths.rs index 914ea85ac2809..8d96d3cfe50b4 100644 --- a/src/tools/clippy/clippy_utils/src/paths.rs +++ b/src/tools/clippy/clippy_utils/src/paths.rs @@ -163,5 +163,3 @@ pub const OPTION_EXPECT: [&str; 4] = ["core", "option", "Option", "expect"]; pub const FORMATTER: [&str; 3] = ["core", "fmt", "Formatter"]; pub const DEBUG_STRUCT: [&str; 4] = ["core", "fmt", "builders", "DebugStruct"]; pub const ORD_CMP: [&str; 4] = ["core", "cmp", "Ord", "cmp"]; -#[expect(clippy::invalid_paths)] // not sure why it thinks this, it works so -pub const BOOL_THEN: [&str; 4] = ["core", "bool", "", "then"]; diff --git a/src/tools/clippy/tests/ui/filter_map_bool_then.fixed b/src/tools/clippy/tests/ui/filter_map_bool_then.fixed deleted file mode 100644 index 3e72fee4b072a..0000000000000 --- a/src/tools/clippy/tests/ui/filter_map_bool_then.fixed +++ /dev/null @@ -1,44 +0,0 @@ -//@run-rustfix -//@aux-build:proc_macros.rs:proc-macro -#![allow( - clippy::clone_on_copy, - clippy::map_identity, - clippy::unnecessary_lazy_evaluations, - unused -)] -#![warn(clippy::filter_map_bool_then)] - -#[macro_use] -extern crate proc_macros; - -#[derive(Clone, PartialEq)] -struct NonCopy; - -fn main() { - let v = vec![1, 2, 3, 4, 5, 6]; - v.clone().iter().filter(|&i| (i % 2 == 0)).map(|i| i + 1); - v.clone().into_iter().filter(|&i| (i % 2 == 0)).map(|i| i + 1); - v.clone() - .into_iter() - .filter(|&i| (i % 2 == 0)).map(|i| i + 1); - v.clone() - .into_iter() - .filter(|&i| i != 1000) - .filter(|&i| (i % 2 == 0)).map(|i| i + 1); - v.iter() - .copied() - .filter(|&i| i != 1000) - .filter(|&i| (i.clone() % 2 == 0)).map(|i| i + 1); - // Do not lint - let v = vec![NonCopy, NonCopy]; - v.clone().iter().filter_map(|i| (i == &NonCopy).then(|| i)); - external! { - let v = vec![1, 2, 3, 4, 5, 6]; - v.clone().into_iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); - } - with_span! { - span - let v = vec![1, 2, 3, 4, 5, 6]; - v.clone().into_iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); - } -} diff --git a/src/tools/clippy/tests/ui/filter_map_bool_then.rs b/src/tools/clippy/tests/ui/filter_map_bool_then.rs deleted file mode 100644 index 38a04e57de456..0000000000000 --- a/src/tools/clippy/tests/ui/filter_map_bool_then.rs +++ /dev/null @@ -1,44 +0,0 @@ -//@run-rustfix -//@aux-build:proc_macros.rs:proc-macro -#![allow( - clippy::clone_on_copy, - clippy::map_identity, - clippy::unnecessary_lazy_evaluations, - unused -)] -#![warn(clippy::filter_map_bool_then)] - -#[macro_use] -extern crate proc_macros; - -#[derive(Clone, PartialEq)] -struct NonCopy; - -fn main() { - let v = vec![1, 2, 3, 4, 5, 6]; - v.clone().iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); - v.clone().into_iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); - v.clone() - .into_iter() - .filter_map(|i| -> Option<_> { (i % 2 == 0).then(|| i + 1) }); - v.clone() - .into_iter() - .filter(|&i| i != 1000) - .filter_map(|i| (i % 2 == 0).then(|| i + 1)); - v.iter() - .copied() - .filter(|&i| i != 1000) - .filter_map(|i| (i.clone() % 2 == 0).then(|| i + 1)); - // Do not lint - let v = vec![NonCopy, NonCopy]; - v.clone().iter().filter_map(|i| (i == &NonCopy).then(|| i)); - external! { - let v = vec![1, 2, 3, 4, 5, 6]; - v.clone().into_iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); - } - with_span! { - span - let v = vec![1, 2, 3, 4, 5, 6]; - v.clone().into_iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); - } -} diff --git a/src/tools/clippy/tests/ui/filter_map_bool_then.stderr b/src/tools/clippy/tests/ui/filter_map_bool_then.stderr deleted file mode 100644 index b411cd83dfd29..0000000000000 --- a/src/tools/clippy/tests/ui/filter_map_bool_then.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:19:22 - | -LL | v.clone().iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i % 2 == 0)).map(|i| i + 1)` - | - = note: `-D clippy::filter-map-bool-then` implied by `-D warnings` - -error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:20:27 - | -LL | v.clone().into_iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i % 2 == 0)).map(|i| i + 1)` - -error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:23:10 - | -LL | .filter_map(|i| -> Option<_> { (i % 2 == 0).then(|| i + 1) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i % 2 == 0)).map(|i| i + 1)` - -error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:27:10 - | -LL | .filter_map(|i| (i % 2 == 0).then(|| i + 1)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i % 2 == 0)).map(|i| i + 1)` - -error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:31:10 - | -LL | .filter_map(|i| (i.clone() % 2 == 0).then(|| i + 1)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i.clone() % 2 == 0)).map(|i| i + 1)` - -error: aborting due to 5 previous errors -