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] for associated functions is supposed to actually work #55003

Merged
merged 1 commit into from
Oct 13, 2018

Conversation

zackmdavis
Copy link
Member

In the comments of (closed, defunct) pull request #54884, @Centril noted that must-use annotations didn't work on an associated function (what other communities might call a "static method"). Subsequent logging revealed that in this case we have a Def::Method, whereas the lint pass was only matching on Def::Fn. (One could argue that those def-names are thereby misleading—must-use for self-ful methods have always worked—but documenting or reworking that can be left to another day.)

r? @varkor

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 12, 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.
[00:54:59] .................................................................................................... 2200/4591
[00:55:03] .............i...................................................................................... 2300/4591
[00:55:07] .................................................................................................... 2400/4591
[00:55:10] .................................................................................................... 2500/4591
[00:55:14] ..........................iiiiiiiii................................................................. 2600/4591
[00:55:20] .................................................................................................... 2800/4591
[00:55:24] .................................................................................................... 2900/4591
[00:55:27] ..............................................i..................................................... 3000/4591
[00:55:30] .................................................................................................... 3100/4591
---
travis_time:start:test_codegen
Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:08:31] 
[01:08:31] running 111 tests
[01:08:34] i..ii...iii.......i...i.........i..iii...........i.....i.....ii...i.i.ii..............i...ii..ii.i.. 100/111
[01:08:34] ..iiii.....
[01:08:34] 
[01:08:34]  finished in 3.398
[01:08:34] travis_fold:end:test_codegen

---
[01:17:43] 
[01:17:43] 
[01:17:43] running 403 tests
[01:17:58] .................................................................................................... 100/403
[01:18:08] .....................................................................i........................F..... 200/403
[01:18:19] ...............F.................................................................................... 300/403
[01:18:28] ..................F...................F............................................................. 400/403
[01:18:28] failures:
[01:18:28] 
[01:18:28] ---- rc.rs - rc::Rc<T>::clone (line 865) stdout ----
[01:18:28] ---- rc.rs - rc::Rc<T>::clone (line 865) stdout ----
[01:18:28] error: unused return value of `std::clone::Clone::clone` which must be used
[01:18:28]  --> rc.rs:870:1
[01:18:28]   |
[01:18:28] 8 | Rc::clone(&five);
[01:18:28]   |
[01:18:28] note: lint level defined here
[01:18:28]  --> rc.rs:864:9
[01:18:28]   |
[01:18:28]   |
[01:18:28] 2 | #![deny(warnings)]
[01:18:28]   |         ^^^^^^^^
[01:18:28]   = note: #[deny(unused_must_use)] implied by #[deny(warnings)]
[01:18:28]   = note: cloning is often expensive and is not expected to have side effects
[01:18:28] thread 'rc.rs - rc::Rc<T>::clone (line 865)' panicked at 'couldn't compile the test', librustdoc/test.rs:333:13
[01:18:28] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:18:28] 
[01:18:28] ---- rc.rs - rc::Weak<T>::clone (line 1302) stdout ----
[01:18:28] ---- rc.rs - rc::Weak<T>::clone (line 1302) stdout ----
[01:18:28] error: unused return value of `std::clone::Clone::clone` which must be used
[01:18:28]  --> rc.rs:1307:1
[01:18:28]   |
[01:18:28] 8 | Weak::clone(&weak_five);
[01:18:28]   |
[01:18:28] note: lint level defined here
[01:18:28]  --> rc.rs:1301:9
[01:18:28]   |
[01:18:28]   |
[01:18:28] 2 | #![deny(warnings)]
[01:18:28]   |         ^^^^^^^^
[01:18:28]   = note: #[deny(unused_must_use)] implied by #[deny(warnings)]
[01:18:28]   = note: cloning is often expensive and is not expected to have side effects
[01:18:28] thread 'rc.rs - rc::Weak<T>::clone (line 1302)' panicked at 'couldn't compile the test', librustdoc/test.rs:333:13
[01:18:28] 
[01:18:28] ---- sync.rs - sync::Arc<T>::clone (line 711) stdout ----
[01:18:28] ---- sync.rs - sync::Arc<T>::clone (line 711) stdout ----
[01:18:28] error: unused return value of `std::clone::Clone::clone` which must be used
[01:18:28]  --> sync.rs:716:1
[01:18:28]   |
[01:18:28] 8 | Arc::clone(&five);
[01:18:28]   |
[01:18:28] note: lint level defined here
[01:18:28]  --> sync.rs:710:9
[01:18:28]   |
[01:18:28]   |
[01:18:28] 2 | #![deny(warnings)]
[01:18:28]   |         ^^^^^^^^
[01:18:28]   = note: #[deny(unused_must_use)] implied by #[deny(warnings)]
[01:18:28]   = note: cloning is often expensive and is not expected to have side effects
[01:18:28] thread 'sync.rs - sync::Arc<T>::clone (line 711)' panicked at 'couldn't compile the test', librustdoc/test.rs:333:13
[01:18:28] 
[01:18:28] ---- sync.rs - sync::Weak<T>::clone (line 1133) stdout ----
[01:18:28] ---- sync.rs - sync::Weak<T>::clone (line 1133) stdout ----
[01:18:28] error: unused return value of `std::clone::Clone::clone` which must be used
[01:18:28]  --> sync.rs:1138:1
[01:18:28]   |
[01:18:28] 8 | Weak::clone(&weak_five);
[01:18:28]   |
[01:18:28] note: lint level defined here
[01:18:28]  --> sync.rs:1132:9
[01:18:28]   |
[01:18:28]   |
[01:18:28] 2 | #![deny(warnings)]
[01:18:28]   |         ^^^^^^^^
[01:18:28]   = note: #[deny(unused_must_use)] implied by #[deny(warnings)]
[01:18:28]   = note: cloning is often expensive and is not expected to have side effects
[01:18:28] thread 'sync.rs - sync::Weak<T>::clone (line 1133)' panicked at 'couldn't compile the test', librustdoc/test.rs:333:13
[01:18:28] 
[01:18:28] 
[01:18:28] failures:
---
[01:18:28] 
[01:18:29] error: test failed, to rerun pass '--doc'
[01:18:29] 
[01:18:29] 
[01:18:29] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "alloc" "--" "--quiet"
[01:18:29] 
[01:18:29] 
[01:18:29] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:18:29] Build completed unsuccessfully in 0:28:15
[01:18:29] Build completed unsuccessfully in 0:28:15
[01:18:29] make: *** [check] Error 1
[01:18:29] Makefile:58: recipe for target 'check' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0314f2be
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@zackmdavis
Copy link
Member Author

(Travis pointed out that this affected some doctests in liballoc!)

@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.
[00:51:02] .................................................................................................... 2200/4593
[00:51:07] ..............i..................................................................................... 2300/4593
[00:51:10] .................................................................................................... 2400/4593
[00:51:14] .................................................................................................... 2500/4593
[00:51:18] ...........................iiiiiiiii................................................................ 2600/4593
[00:51:24] .................................................................................................... 2800/4593
[00:51:28] .................................................................................................... 2900/4593
[00:51:31] .................................................i.................................................. 3000/4593
[00:51:34] .................................................................................................... 3100/4593
---
[00:55:39] .................................................................................................... 1800/2868
[00:55:49] ..................................................................i................................. 1900/2868
[00:56:01] ....................................i............................................................... 2000/2868
[00:56:21] .................................................................................................... 2100/2868
[00:56:28] ...................................................................F..............................ii 2200/2868
[00:56:58] ............i....................................................................................... 2400/2868
[00:57:13] .................................................................................................... 2500/2868
[00:57:37] .................................................................................................... 2600/2868
[00:57:47] .................................................................................................... 2700/2868
[00:57:47] .................................................................................................... 2700/2868
[00:57:56] .................................................................................................... 2800/2868
[00:58:05] ....................................................................
[00:58:05] failures:
[00:58:05] 
[00:58:05] ---- [run-pass] run-pass/resolve-pseudo-shadowing.rs stdout ----
[00:58:05] normalized stderr:
[00:58:05] warning: unused return value of `std::clone::Clone::clone` which must be used
[00:58:05]    |
[00:58:05]    |
[00:58:05] LL |         <() as std::clone::Clone>::clone(&());
[00:58:05]    |
[00:58:05]    = note: #[warn(unused_must_use)] on by default
[00:58:05]    = note: #[warn(unused_must_use)] on by default
[00:58:05]    = note: cloning is often expensive and is not expected to have side effects
[00:58:05] 
[00:58:05] 
[00:58:05] 
[00:58:05] The actual stderr differed from the expected stderr.

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)

In the comments of (closed, defunct) pull request rust-lang#54884, Mazdak
"Centril" Farrokhzad noted that must-use annotations didn't work on an
associated function (what other communities might call a "static
method"). Subsequent logging revealed that in this case we have a
`Def::Method`, whereas the lint pass was only matching on
`Def::Fn`. (One could argue that those def-names are thereby
misleading—must-use for self-ful methods have always worked—but
documenting or reworking that can be left to another day.)
@varkor
Copy link
Member

varkor commented Oct 13, 2018

One could argue that those def-names are thereby misleading—must-use for self-ful methods have always worked

That is quite confusing. It'd be good to address this later, I agree.

@bors r+

@bors
Copy link
Contributor

bors commented Oct 13, 2018

📌 Commit ab91a6b has been approved by varkor

@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 Oct 13, 2018
@bors
Copy link
Contributor

bors commented Oct 13, 2018

⌛ Testing commit ab91a6b with merge 8f19cad...

bors added a commit that referenced this pull request Oct 13, 2018
`#[must_use]` for associated functions is supposed to actually work

In the comments of (closed, defunct) pull request #54884, @Centril [noted that](#54884 (comment)) must-use annotations didn't work on an associated function (what other communities might call a "static method"). Subsequent logging revealed that in this case we have a `Def::Method`, whereas the lint pass was only matching on `Def::Fn`. (One could argue that those def-names are thereby misleading—must-use for `self`-ful methods have always worked—but documenting or reworking that can be left to another day.)

r? @varkor
@bors
Copy link
Contributor

bors commented Oct 13, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: varkor
Pushing 8f19cad to master...

@bors bors merged commit ab91a6b into rust-lang:master Oct 13, 2018
@zackmdavis zackmdavis deleted the must_use_assoc_fn branch October 14, 2018 19:00
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.

4 participants