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

Fix dead code lint for functions using impl Trait #54810

Merged
merged 7 commits into from
Oct 7, 2018

Conversation

jonas-schievink
Copy link
Contributor

Fixes #54754

This is a minimal fix that doesn't add any new queries or touches unnecessary code. Please nominate for beta backport if wanted.

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 4, 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:52:40] ...............................................................................................i.... 2200/4550
[00:52:44] .................................................................................................... 2300/4550
[00:52:48] .................................................................................................... 2400/4550
[00:52:52] .................................................................................................... 2500/4550
[00:52:55] .......iiiiiiiii.................................................................................... 2600/4550
[00:53:01] .................................................................................................... 2800/4550
[00:53:05] .................................................................................................... 2900/4550
[00:53:08] ..........................i......................................................................... 3000/4550
[00:53:11] ......................................................................................i.i..ii....... 3100/4550
---
Check compiletest suite=run-pass mode=run-pass (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[00:53:58] 
[00:53:58] running 2872 tests
[00:54:09] .................................................................................................... 100/2872
[00:54:20] .............................................................F...............i...................... 200/2872
[00:54:38] .................................................................................................... 400/2872
[00:54:46] .................................................................................................... 500/2872
[00:54:57] .................................................................................................... 600/2872
[00:55:11] .................................................................................................... 700/2872
[00:55:11] .................................................................................................... 700/2872
[00:55:22] .................................................................................................... 800/2872
[00:55:31] .................................................................................................... 900/2872
[00:55:44] .....................FFF............................................................................ 1000/2872
[00:56:05] .................................................................................................... 1200/2872
[00:56:14] .................................................................................................... 1300/2872
[00:56:26] ...........................................................................i........................ 1400/2872
[00:56:37] .................................................................................................... 1500/2872
[00:56:37] .................................................................................................... 1500/2872
[00:56:48] ............................................i..........F............................................ 1600/2872
[00:57:16] .................................................................................................... 1800/2872
[00:57:26] .....................................................................i.............................. 1900/2872
[00:57:38] .......................................i............................................................ 2000/2872
[00:58:00] .................................................................................................... 2100/2872
[00:58:00] .................................................................................................... 2100/2872
[00:58:07] .................................................................................................... 2200/2872
[00:58:24] .ii.....................................................................i....i...................... 2300/2872
[00:58:37] ...............i.................................................................................... 2400/2872
[00:58:51] .................................................................................................... 2500/2872
[00:59:17] ....................................................F............................................... 2600/2872
[00:59:35] .................................................................................................... 2800/2872
[00:59:46] ........................................................................
[00:59:46] failures:
[00:59:46] 
[00:59:46] 
[00:59:46] ---- [run-pass] run-pass/async-await.rs stdout ----
[00:59:46] normalized stderr:
[00:59:46] warning: struct is never constructed: `Foo`
[00:59:46]   --> $DIR/async-await.rs:122:1
[00:59:46]    |
[00:59:46] LL | struct Foo;
[00:59:46]    |
[00:59:46]    = note: #[warn(dead_code)] on by default
[00:59:46] 
[00:59:46] warning: method is never used: `async_method`
[00:59:46] warning: method is never used: `async_method`
[00:59:46]   --> $DIR/async-await.rs:129:5
[00:59:46]    |
[00:59:46] LL |     async fn async_method(x: u8) -> u8 {
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] The actual stderr differed from the expected stderr.
[00:59:46] Actual stderr saved to /  = note: #[warn(dead_code)] on by default
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] The actual stderr differed from the expected stderr.
[00:59:46] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/impl-trait/existential-minimal/existential-minimal.stderr
[00:59:46] To update references, rerun the tests and pass the `--bless` flag
[00:59:46] To only update this specific test, also pass `--test-args impl-trait/existential-minimal.rs`
[00:59:46] error: 1 errors occurred comparing output.
[00:59:46] status: exit code: 0
[00:59:46] status: exit code: 0
[00:59:46] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/impl-trait/existential-minimal.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/impl-trait/existential-minimal/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/impl-trait/existential-minimal/auxiliary"
[00:59:46] ------------------------------------------
[00:59:46] 
[00:59:46] ------------------------------------------
[00:59:46] stderr:
[00:59:46] stderr:
[00:59:46] ------------------------------------------
[00:59:46] {"message":"function is never used: `foo`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/run-pass/impl-trait/existential-minimal.rs","byte_start":494,"byte_end":526,"line_start":15,"line_end":15,"c^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:59:46]    = note: #[warn(dead_code)] on by default
[00:59:46] 
[00:59:46] warning: struct is never constructed: `Bar`
[00:59:46]   --> $DIR/issue-49376.rs:20:1
[00:59:46]   --> $DIR/issue-49376.rs:20:1
[00:59:46]    |
[00:59:46] LL | struct Bar {}
[00:59:46] 
[00:59:46] warning: function is never used: `foo`
[00:59:46]   --> $DIR/issue-49376.rs:24:1
[00:59:46]    |
[00:59:46]    |
[00:59:46] LL | fn foo() -> impl Foo {
[00:59:46] 
[00:59:46] warning: function is never used: `test_impl_ops`
[00:59:46]   --> $DIR/issue-49376.rs:28:1
[00:59:46]    |
[00:59:46]    |
[00:59:46] LL | fn test_impl_ops() -> impl Add + Sub + Mul + Div { 1 }
[00:59:46] 
[00:59:46] warning: function is never used: `test_impl_assign_ops`
[00:59:46]   --> $DIR/issue-49376.rs:29:1
[00:59:46]    |
[00:59:46]    |
[00:59:46] LL | fn test_impl_assign_ops() -> impl AddAssign + SubAssign + MulAssign + DivAssign { 1 }
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] The actual stderr differed from the expected stderr.
[00:59:46] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/impl-trait/issue-49376/issue-49376.stderr
[00:59:46] To update references, rerun the tests and pass the `--bless` flag
[00:59:46] To only update this specific test, also pass `--test-args impl-trait/issue-49376.rs`
[00:59:46] error: 1 errors occurred comparing output.
[00:59:46] status: exit code: 0
[00:59:46] status: exit code: 0
[00:59:46] comma_code)] on by default\n\n"}
[00:59:46] {"message":"struct is never constructed: `Bar`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/run-pass/impl-trait/issue-49376.rs","byte_start":639,"byte_end":649,"line_start":20,"line_end":20,"column_start":1,"column_end":11,"is_primary":true,"text":[{"text":"struct Bar {}","highlight_start":1,"highlight_end":11}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: struct is never constructed: `Bar`\n  --> /checkout/src/test/run-pass/impl-trait/issue-49376.rs:20:1\n   |\nLL | struct Bar {}\n   | ^^^^^^^^^^\n\n"}
[00:59:46] {"message":"function is never used: `foo`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/run-pass/impl-trait/issue-49376.rs","byte_start":697,"byte_end":717,"line_start":24,"line_end":24,"column_start":1,"column_end":21,"is_primary":true,"text":[{"text":"fn foo() -> impl Foo {","highlight_start":1,"highlight_end":21}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: function is never used: `foo`\n  --> /checkout/src/test/run-pass/impl-trait/issue-49376.rs:24:1\n   |\nLL | fn foo() -> impl Foo {\n   | ^^^^^^^^^^^^^^^^^^^^\n\n"}
[00:59:46] {"message":"function is never used: `test_impl_ops`","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/run-pass/impl-trait/issue-49376.rs","byte_start":734,"byte_end":782,"line_start":28,"line_end":28,"co:46] 
[00:59:46] ---- [run-pass] run-pass/issues/issue-49556.rs stdout ----
[00:59:46] warning: function is never used: `iter`
[00:59:46]   --> $DIR/issue-49556.rs:12:1
[00:59:46]    |
[00:59:46]    |
[00:59:46] LL | fn iter<'a>(data: &'a [usize]) -> impl Iterator<Item = usize> + 'a {
[00:59:46]    |
[00:59:46]    = note: #[warn(dead_code)] on by default
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] The actual stderr differed from the expected stderr.
[00:59:46] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issues/issue-49556/issue-49556.stderr
[00:59:46] To update references, rerun the tests and pass the `--bless` flag
[00:59:46] To only update this specific test, also pass `--test-args issues/issue-49556.rs`
[00:59:46] error: 1 errors occurred comparing output.
[00:59:46] status: exit code: 0
[00:59:46] status: exit code: 0
[00:59:46] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/issues/issue-49556.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issues/issue-49556/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issues/issue-49556/auxiliary"
[00:59:46] ------------------------------------------
[00:59:46] 
[00:59:46] 
[00:59:46] ------------------------------------s":[{"file_name":"/checkout/src/test/run-pass/traits/conservative_impl_trait.rs","byte_start":490,"byte_end":537,"line_start":14,"line_end":14,"column_start":1,"column_end":48,"is_primary":true,"text":[{"text":"fn batches(n: &u32) -> impl Iterator<Item=&u32> {","highlight_start":1,"highlight_end":48}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"#[warn(dead_code)] on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"warning: function is never used: `batches`\n  --> /checkout/src/test/run-pass/traits/conservative_impl_trait.rs:14:1\n   |\nLL | fn batches(n: &u32) -> impl Iterator<Item=&u32> {\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: #[warn(dead_code)] on by default\n\n"}
[00:59:46] ------------------------------------------
[00:59:46] 
[00:59:46] thread '[run-pass] run-pass/traits/conservative_impl_trait.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3267:9
[00:59:46] 
---
[00:59:46] test result: FAILED. 2856 passed; 6 failed; 10 ignored; 0 measured; 0 filtered out
[00:59:46] 
[00:59:46] 
[00:59:46] 
[00:59:46] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/run-pass" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-pass" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "5.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:59:46] 
[00:59:46] 
[00:59:46] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:59:46] Build completed unsuccessfully in 0:11:50
[00:59:46] Build completed unsuccessfully in 0:11:50
[00:59:46] Makefile:58: recipe for target 'check' failed
[00:59:46] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:02fa2c9c
$ 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)

@oli-obk oli-obk added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 4, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Oct 4, 2018

You need to update a bunch of other tests' stderr files, too.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 4, 2018

r? @oli-obk

@jonas-schievink
Copy link
Contributor Author

@oli-obk Ah I see. I wasn't able to run the full test suite because I messed up the LLVM build. Should be fixed now, though.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 4, 2018

Hmm... These are all run-pass tests. We should probably ensure that the functions are called or move the functions to ui // compile-pass tests.

If that's ok with you I'd like to have this done in this PR where we see all the newly occurring warnings (or the lack thereof after the functions are actually called)

@jonas-schievink
Copy link
Contributor Author

@oli-obk Is this what you had in mind? Looks like there's only 1 case where the unused function should have been called, I've moved all other tests to ui and made them compile-pass tests.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 4, 2018

Perfect. Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Oct 4, 2018

📌 Commit e24f4d5 has been approved by oli-obk

@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 4, 2018
@pnkfelix
Copy link
Member

pnkfelix commented Oct 4, 2018

discussed at T-compiler weekly meeting. approved for beta backport.

@pnkfelix pnkfelix added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Oct 4, 2018
@bors
Copy link
Contributor

bors commented Oct 7, 2018

⌛ Testing commit e24f4d5 with merge 04c1af0c18813daeb32d0585b1e8eccdd4b48cd2...

@bors
Copy link
Contributor

bors commented Oct 7, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 7, 2018
@rust-highfive
Copy link
Collaborator

The job dist-i686-freebsd 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:028f1f54:start=1538895062676803553,finish=1538895062686899642,duration=10096089
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:10a809cc
$ 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:22f3ed84
travis_time:start:22f3ed84
$ 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:1a8e777f
$ 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)

@jonas-schievink
Copy link
Contributor Author

Actual error:

[01:07:28] thread 'main' panicked at 'failed to download openssl source: exit code: 6', bootstrap/native.rs:621:17

(spurious)

Also, is that builder building LLVM twice?

@nagisa
Copy link
Member

nagisa commented Oct 7, 2018

@bors retry

as requested on IRC.

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

bors commented Oct 7, 2018

⌛ Testing commit e24f4d5 with merge b2d6ea9...

bors added a commit that referenced this pull request Oct 7, 2018
Fix dead code lint for functions using impl Trait

Fixes #54754

This is a minimal fix that doesn't add any new queries or touches unnecessary code. Please nominate for beta backport if wanted.
@bors
Copy link
Contributor

bors commented Oct 7, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: oli-obk
Pushing b2d6ea9 to master...

@bors bors merged commit e24f4d5 into rust-lang:master Oct 7, 2018
@pietroalbini pietroalbini removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 8, 2018
bors added a commit that referenced this pull request Oct 8, 2018
[beta] Rollup backports

Merged and approved:

* #54851: Fix a regression in 1.30 by reverting #53564
* #54865: Backport 1.29.2 release notes to master
* #54810: Fix dead code lint for functions using impl Trait

r? @ghost
bors added a commit that referenced this pull request Oct 9, 2018
[beta] Rollup backports

Merged and approved:

* #54851: Fix a regression in 1.30 by reverting #53564
* #54865: Backport 1.29.2 release notes to master
* #54810: Fix dead code lint for functions using impl Trait

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. 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.

No warning for unused function using impl Trait on beta and nightly
8 participants