about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorObei Sideg <obei.sideg@gmail.com>2023-02-16 22:04:59 +0300
committerObei Sideg <obei.sideg@gmail.com>2023-02-23 13:57:06 +0300
commita914f37409f0ff0cdee37bfc959d77f91f3bcb0c (patch)
treedaab9a0ea95f8cd923ac5ebe5339afddc3048c91 /library
parent8b1dbf728add722d4db894b9b986ec24e1cdb0a1 (diff)
downloadrust-a914f37409f0ff0cdee37bfc959d77f91f3bcb0c.tar.gz
rust-a914f37409f0ff0cdee37bfc959d77f91f3bcb0c.zip
Add lint against `Iterator::map` receiving a callable that returns `()`
Diffstat (limited to 'library')
-rw-r--r--library/core/src/iter/mod.rs1
-rw-r--r--library/core/src/iter/traits/iterator.rs1
2 files changed, 2 insertions, 0 deletions
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<B, F>(self, f: F) -> Map<Self, F>