Skip to content

Add #[must_use] message to Iterator and Future #57549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcore/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use task::{Poll, LocalWaker};
///
/// When using a future, you generally won't call `poll` directly, but instead
/// `await!` the value.
#[must_use]
#[must_use = "futures do nothing unless polled"]
pub trait Future {
/// The result of the `Future`.
type Output;
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item=()>) {}
message="`{Self}` is not an iterator"
)]
#[doc(spotlight)]
#[must_use]
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing docs use "iterator adapter", so I think we want to use that spelling instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that "iterator adaptors" is used as #[must_use] message: https://github.com/rust-lang/rust/blob/master/src/libcore/iter/mod.rs#L407

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, that one should probably be changed too, then.

Copy link
Member Author

@taiki-e taiki-e Jan 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Rust code on GitHub, iterator adaptors seems to be used more than iterator adapter.

IMO, this should probably be handled by another PR that like "Unify the name of the iterator adapter".

Copy link
Contributor

@Centril Centril Jan 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference is to just drop "adaptors" in favor of "iterators are lazy and do...", since it's more direct. It seems preferable to unify everything, in whichever direction we move, in this PR.

pub trait Iterator {
/// The type of the elements being iterated over.
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down