Skip to content

Commit ecc4ca5

Browse files
committed
Add #[must_use] attribute to stdlib traits
1 parent a336228 commit ecc4ca5

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

src/libcore/future/future.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use task::{Poll, LocalWaker};
3333
///
3434
/// When using a future, you generally won't call `poll` directly, but instead
3535
/// `await!` the value.
36+
#[must_use]
3637
pub trait Future {
3738
/// The result of the `Future`.
3839
type Output;

src/libcore/iter/iterator.rs

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item=()>) {}
9898
message="`{Self}` is not an iterator"
9999
)]
100100
#[doc(spotlight)]
101+
#[must_use]
101102
pub trait Iterator {
102103
/// The type of the elements being iterated over.
103104
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/ops/function.rs

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
label="expected an `Fn<{Args}>` closure, found `{Self}`",
7373
)]
7474
#[fundamental] // so that regex can rely that `&str: !FnMut`
75+
#[must_use]
7576
pub trait Fn<Args> : FnMut<Args> {
7677
/// Performs the call operation.
7778
#[unstable(feature = "fn_traits", issue = "29625")]
@@ -150,6 +151,7 @@ pub trait Fn<Args> : FnMut<Args> {
150151
label="expected an `FnMut<{Args}>` closure, found `{Self}`",
151152
)]
152153
#[fundamental] // so that regex can rely that `&str: !FnMut`
154+
#[must_use]
153155
pub trait FnMut<Args> : FnOnce<Args> {
154156
/// Performs the call operation.
155157
#[unstable(feature = "fn_traits", issue = "29625")]
@@ -228,6 +230,7 @@ pub trait FnMut<Args> : FnOnce<Args> {
228230
label="expected an `FnOnce<{Args}>` closure, found `{Self}`",
229231
)]
230232
#[fundamental] // so that regex can rely that `&str: !FnMut`
233+
#[must_use]
231234
pub trait FnOnce<Args> {
232235
/// The returned type after the call operator is used.
233236
#[stable(feature = "fn_once_output", since = "1.12.0")]

0 commit comments

Comments
 (0)