about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix Chapman <aelred717@gmail.com>2018-12-10 14:45:26 +0000
committerFelix Chapman <aelred717@gmail.com>2018-12-10 14:45:26 +0000
commitecc4ca54a4c7b1c436c466357877336c1df781cd (patch)
treefc1152a312945022c21650a4f8937d3c15ccc466
parenta336228760389b5ef01390f1c90a029dc44a0dc1 (diff)
Add #[must_use] attribute to stdlib traits
-rw-r--r--src/libcore/future/future.rs1
-rw-r--r--src/libcore/iter/iterator.rs1
-rw-r--r--src/libcore/ops/function.rs3
3 files changed, 5 insertions, 0 deletions
diff --git a/src/libcore/future/future.rs b/src/libcore/future/future.rs
index 0c870f9e404..5dee1d6dd3a 100644
--- a/src/libcore/future/future.rs
+++ b/src/libcore/future/future.rs
@@ -33,6 +33,7 @@ use task::{Poll, LocalWaker};
 ///
 /// When using a future, you generally won't call `poll` directly, but instead
 /// `await!` the value.
+#[must_use]
 pub trait Future {
     /// The result of the `Future`.
     type Output;
diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs
index 92a4aed4e27..c0b83a6868b 100644
--- a/src/libcore/iter/iterator.rs
+++ b/src/libcore/iter/iterator.rs
@@ -98,6 +98,7 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item=()>) {}
     message="`{Self}` is not an iterator"
 )]
 #[doc(spotlight)]
+#[must_use]
 pub trait Iterator {
     /// The type of the elements being iterated over.
     #[stable(feature = "rust1", since = "1.0.0")]
diff --git a/src/libcore/ops/function.rs b/src/libcore/ops/function.rs
index d1be724c326..3b356b9a1e7 100644
--- a/src/libcore/ops/function.rs
+++ b/src/libcore/ops/function.rs
@@ -72,6 +72,7 @@
     label="expected an `Fn<{Args}>` closure, found `{Self}`",
 )]
 #[fundamental] // so that regex can rely that `&str: !FnMut`
+#[must_use]
 pub trait Fn<Args> : FnMut<Args> {
     /// Performs the call operation.
     #[unstable(feature = "fn_traits", issue = "29625")]
@@ -150,6 +151,7 @@ pub trait Fn<Args> : FnMut<Args> {
     label="expected an `FnMut<{Args}>` closure, found `{Self}`",
 )]
 #[fundamental] // so that regex can rely that `&str: !FnMut`
+#[must_use]
 pub trait FnMut<Args> : FnOnce<Args> {
     /// Performs the call operation.
     #[unstable(feature = "fn_traits", issue = "29625")]
@@ -228,6 +230,7 @@ pub trait FnMut<Args> : FnOnce<Args> {
     label="expected an `FnOnce<{Args}>` closure, found `{Self}`",
 )]
 #[fundamental] // so that regex can rely that `&str: !FnMut`
+#[must_use]
 pub trait FnOnce<Args> {
     /// The returned type after the call operator is used.
     #[stable(feature = "fn_once_output", since = "1.12.0")]