Skip to content
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

#[must_use] on traits in stdlib #56677

Merged
merged 3 commits into from
Dec 15, 2018
Merged

Conversation

aelred
Copy link
Contributor

@aelred aelred commented Dec 10, 2018

Based on #55506.

Adds #[must_use] attribute to traits in the stdlib:

  • Iterator
  • Future
  • FnOnce
  • Fn
  • FnMut

There may be other traits that should have the attribute, but I couldn't find/think of any.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 10, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:139af2a0:start=1544453473013273476,finish=1544453593381890974,duration=120368617498
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---

[00:03:45] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:45] tidy error: /checkout/src/test/compile-fail/must_use-in-stdlib-traits.rs: missing trailing newline
[00:03:46] some tidy checks failed
[00:03:46] 
[00:03:46] 
[00:03:46] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:46] 
[00:03:46] 
[00:03:46] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:46] Build completed unsuccessfully in 0:00:55
[00:03:46] Build completed unsuccessfully in 0:00:55
[00:03:46] make: *** [tidy] Error 1
[00:03:46] Makefile:79: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:08ec004a
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Dec 10 14:57:09 UTC 2018
---
travis_time:end:01b68680:start=1544453829843660041,finish=1544453829848740622,duration=5080581
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:36217a40
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1a83ef09
travis_time:start:1a83ef09
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:013b87d6
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@estebank
Copy link
Contributor

LGTM and should probably be merged as is but I'd like to see a crater run to make sure we're not causing a lot of pain in the ecosystem by introducing these checks :)

@bors try

@bors
Copy link
Contributor

bors commented Dec 10, 2018

⌛ Trying commit 3246f49 with merge aa9aa79...

bors added a commit that referenced this pull request Dec 10, 2018
#[must_use] on traits in stdlib

Based on #55506.

Adds `#[must_use]` attribute to traits in the stdlib:
- `Iterator`
- `Future`
- `FnOnce`
- `Fn`
- `FnMut`

There may be other traits that should have the attribute, but I couldn't find/think of any.
@bors
Copy link
Contributor

bors commented Dec 10, 2018

☀️ Test successful - status-travis
State: approved= try=True

@estebank
Copy link
Contributor

@craterbot run start=master#3a75e80557a103497cffbcab395a2f37061a77ea end=try#aa9aa79c3c583aab59ac9134542d60a780c35e2e mode=check-only

@craterbot
Copy link
Collaborator

👌 Experiment pr-56677 created and queued.
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 10, 2018
@craterbot
Copy link
Collaborator

🚧 Experiment pr-56677 is now running on agent aws-1.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-56677 is completed!
📊 0 regressed and 0 fixed (50551 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Dec 12, 2018
@estebank
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 12, 2018

📌 Commit 3246f49 has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 12, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Dec 12, 2018
#[must_use] on traits in stdlib

Based on rust-lang#55506.

Adds `#[must_use]` attribute to traits in the stdlib:
- `Iterator`
- `Future`
- `FnOnce`
- `Fn`
- `FnMut`

There may be other traits that should have the attribute, but I couldn't find/think of any.
@@ -98,6 +98,7 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item=()>) {}
message="`{Self}` is not an iterator"
)]
#[doc(spotlight)]
#[must_use]
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be:

Suggested change
#[must_use]
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]

(which can be fixed in a follow up PR)

pietroalbini added a commit to pietroalbini/rust that referenced this pull request Dec 13, 2018
#[must_use] on traits in stdlib

Based on rust-lang#55506.

Adds `#[must_use]` attribute to traits in the stdlib:
- `Iterator`
- `Future`
- `FnOnce`
- `Fn`
- `FnMut`

There may be other traits that should have the attribute, but I couldn't find/think of any.
kennytm added a commit to kennytm/rust that referenced this pull request Dec 13, 2018
#[must_use] on traits in stdlib

Based on rust-lang#55506.

Adds `#[must_use]` attribute to traits in the stdlib:
- `Iterator`
- `Future`
- `FnOnce`
- `Fn`
- `FnMut`

There may be other traits that should have the attribute, but I couldn't find/think of any.
kennytm added a commit to kennytm/rust that referenced this pull request Dec 14, 2018
#[must_use] on traits in stdlib

Based on rust-lang#55506.

Adds `#[must_use]` attribute to traits in the stdlib:
- `Iterator`
- `Future`
- `FnOnce`
- `Fn`
- `FnMut`

There may be other traits that should have the attribute, but I couldn't find/think of any.
kennytm added a commit to kennytm/rust that referenced this pull request Dec 14, 2018
#[must_use] on traits in stdlib

Based on rust-lang#55506.

Adds `#[must_use]` attribute to traits in the stdlib:
- `Iterator`
- `Future`
- `FnOnce`
- `Fn`
- `FnMut`

There may be other traits that should have the attribute, but I couldn't find/think of any.
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Dec 14, 2018
#[must_use] on traits in stdlib

Based on rust-lang#55506.

Adds `#[must_use]` attribute to traits in the stdlib:
- `Iterator`
- `Future`
- `FnOnce`
- `Fn`
- `FnMut`

There may be other traits that should have the attribute, but I couldn't find/think of any.
@scottmcm
Copy link
Member

I'm slightly worried about this.

Does this mean that v.drain(5..10); will warn, even though it's completely reasonable to ignore the iterator it produces? Does this mean that anything that returns a Range will warn if it's unused, even when the method is side-effecting?

@sfackler
Copy link
Member

These only apply to trait objects, not concrete types implementing the traits I believe.

pietroalbini added a commit to pietroalbini/rust that referenced this pull request Dec 15, 2018
#[must_use] on traits in stdlib

Based on rust-lang#55506.

Adds `#[must_use]` attribute to traits in the stdlib:
- `Iterator`
- `Future`
- `FnOnce`
- `Fn`
- `FnMut`

There may be other traits that should have the attribute, but I couldn't find/think of any.
bors added a commit that referenced this pull request Dec 15, 2018
Rollup of 7 pull requests

Successful merges:

 - #56677 (#[must_use] on traits in stdlib)
 - #56679 (overhaul external doc attribute diagnostics)
 - #56682 (Update the stdsimd submodule)
 - #56691 (fix install broken link)
 - #56710 (Always set the RDRAND and RDSEED features on SGX)
 - #56713 (Test capacity of ZST vector)
 - #56841 (Add some unit tests to compiletest)

Failed merges:

r? @ghost
@bors bors merged commit 3246f49 into rust-lang:master Dec 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants