From a914f37409f0ff0cdee37bfc959d77f91f3bcb0c Mon Sep 17 00:00:00 2001 From: Obei Sideg Date: Thu, 16 Feb 2023 22:04:59 +0300 Subject: Add lint against `Iterator::map` receiving a callable that returns `()` --- library/core/src/iter/mod.rs | 1 + library/core/src/iter/traits/iterator.rs | 1 + 2 files changed, 2 insertions(+) (limited to 'library/core/src') diff --git a/library/core/src/iter/mod.rs b/library/core/src/iter/mod.rs index 156b925de77..ae00232c12c 100644 --- a/library/core/src/iter/mod.rs +++ b/library/core/src/iter/mod.rs @@ -278,6 +278,7 @@ //! //! ``` //! # #![allow(unused_must_use)] +//! # #![cfg_attr(not(bootstrap), allow(map_unit_fn))] //! let v = vec![1, 2, 3, 4, 5]; //! v.iter().map(|x| println!("{x}")); //! ``` diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 9e3e13e7004..5d272ec3522 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -777,6 +777,7 @@ pub trait Iterator { /// println!("{x}"); /// } /// ``` + #[rustc_diagnostic_item = "IteratorMap"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn map(self, f: F) -> Map -- cgit 1.4.1-3-g733a5