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

enforce unused-must-use lint in macros #55569

Merged
merged 3 commits into from
Nov 5, 2018

Conversation

durka
Copy link
Contributor

@durka durka commented Nov 1, 2018

Fixes #55516 by turning on the UNUSED_MUST_USE lint within macros.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(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 Nov 1, 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:0e395bb7:start=1541043311335264226,finish=1541043369831285079,duration=58496020853
$ 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

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)

@petrochenkov
Copy link
Contributor

I'm going to beta-nominate this to minimize the window in which write!(...); can be used without a warning. It's quite common and may cause too many warnings if the fix is applied too late.

@petrochenkov petrochenkov added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 1, 2018
@nagisa nagisa added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Nov 1, 2018
@nagisa
Copy link
Member

nagisa commented Nov 1, 2018

Discussed backport during the T-compiler meeting. Accepted for backport.

@nikomatsakis
Copy link
Contributor

r=me but any idea why travis is upset? Is that spurious?

@nikomatsakis
Copy link
Contributor

r? @alexcrichton I suppose, who proposed this fix. I don't really have an opinion about whether it's right or not (seems a bit .. weird to me .. to isolate this particular lint...)

@alexcrichton
Copy link
Member

r=me, but it looks like CI may be failing? It appears an unused result already snuck in!

@durka
Copy link
Contributor Author

durka commented Nov 2, 2018

Actually relevant part of the log (cc @TimNN):

[00:36:38]    Compiling rustc_resolve v0.0.0 (/checkout/src/librustc_resolve)
[00:36:43] error: unused `std::result::Result` that must be used
[00:36:43]    --> librustc_resolve/resolve_imports.rs:785:17
[00:36:43]     |
[00:36:43] 785 |                 write!(suggestion_choices, "`::{}`", name);
[00:36:43]     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:36:43]     |
[00:36:43]     = note: `-D unused-must-use` implied by `-D warnings`
[00:36:43]     = note: this `Result` may be an `Err` variant, which should be handled
[00:36:43]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:36:43]
[00:36:43] error: unused `std::result::Result` that must be used
[00:36:43]    --> librustc_resolve/resolve_imports.rs:793:17
[00:36:43]     |
[00:36:43] 793 |                 write!(suggestion_choices, "`self::{}`", name);
[00:36:43]     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:36:43]     |
[00:36:43]     = note: this `Result` may be an `Err` variant, which should be handled
[00:36:43]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:36:43]
[00:36:43] error: aborting due to 2 previous errors
[00:36:43]
[00:36:43] error: Could not compile `rustc_resolve`.

@durka
Copy link
Contributor Author

durka commented Nov 2, 2018

Added in #54201 cc @eddyb. It's writing into suggestion_choices which is... a String. So we should probably just unwrap these? Is that allowed in the compiler?

@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:12ca660e:start=1541129290789811539,finish=1541129348751515096,duration=57961703557
$ 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:51:05] .................................................................................................... 100/4984
[00:51:08] .................................................................................................... 200/4984
[00:51:11] ...........................................................................................ii....... 300/4984
[00:51:14] .........................................................................................iii........ 400/4984
[00:51:17] iiiiiiii.iii...........................iii...........................................i...........i.. 500/4984
[00:51:24] .................................................................................................... 700/4984
[00:51:31] ..................................................................i...........i..................... 800/4984
[00:51:34] ....................................................................................iiiii........... 900/4984
[00:51:38] .................................................................................................... 1000/4984
---
[00:52:16] .................................................................................................... 2200/4984
[00:52:21] .................................................................................................... 2300/4984
[00:52:25] .................................................................................................... 2400/4984
[00:52:29] .................................................................................................... 2500/4984
[00:52:32] ...................................................................iiiiiiiii........................ 2600/4984
[00:52:40] ..................ii................................................................................ 2800/4984
[00:52:42] .................................................................................................... 2900/4984
[00:52:47] .................................................................................................... 3000/4984
[00:52:50] .............i...................................................................................... 3100/4984
---
[00:54:48] .................................................................................................... 600/2874
[00:55:03] .................................................................................................... 700/2874
[00:55:14] .................................................................................................... 800/2874
[00:55:23] .................................................................................................... 900/2874
[00:55:37] ............................F..F.................................................................... 1000/2874
[00:55:59] .................................................................................................... 1200/2874
[00:56:08] .................................................................................................... 1300/2874
[00:56:20] .........................................................................i.......................... 1400/2874
[00:56:32] .................................................................................................... 1500/2874
[00:56:32] .................................................................................................... 1500/2874
[00:56:45] ..........................................i......................................................... 1600/2874
[00:57:01] .................................................................................................... 1700/2874
[00:57:13] .........................F.......................................................................... 1800/2874
[00:57:35] .......................................i............................................................ 2000/2874
[00:57:57] .................................................................................................... 2100/2874
[00:58:05] .................................................................................................... 2200/2874
[00:58:21] .ii.....................................................................i....i...................... 2300/2874
[00:58:21] .ii.....................................................................i....i...................... 2300/2874
[00:58:36] ...............i.................................................................................... 2400/2874
[00:58:50] .................................................................................................... 2500/2874
[00:59:15] .................................................................................................... 2600/2874
[00:59:25] .................................................................................................... 2700/2874
[00:59:34] .................................................................................................... 2800/2874
rait/example-calendar.normal/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/example-calendar.normal/auxiliary"
[00:59:45] ------------------------------------------
[00:59:45] 
[00:59:45] ------------------------------------------
[00:59:45] stderr:
[00:59:45] stderr:
[00:59:45] ------------------------------------------
[00:59:45] {"message":"unused `std::result::Result` that must be used","code":{"code":"unused_must_use","explanation":null},"level":"warning","spans":[{"file_name":"<::core::macros::write macros>","byte_start":43,"byte_end":96,"line_start":2,"line_end":2,"column_start":1,"column_end":54,"is_primary":true,"text":[{"text":"$ dst . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/run-pass/impl-trait/example-calendar.rs","byte_start":8168,"byte_end":8187,"line_start":313,"line_end":313,"column_start":13,"column_end":32,"is_primary":false,"text":[{"text":"            write!(s, \"{}\", e);","highlight_start":13,"highlight_end":32}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"write!","def_site_span":{"file_name":"<::core::macros::write macros>","byte_start":0,"byte_end":98,"line_start":1,"line_end":2,"column_start":1,"column_end":56,"is_primary":false,"text":[{"text":"( $ dst : expr , $ ( $ arg : tt ) * ) => (","highlight_start":1,"sed
[00:59:45]    |
[00:59:45]    |
[00:59:45] LL |     write!(&mut w, ""); // should coerce
[00:59:45]    |
[00:59:45]    |
[00:59:45]    = note: this `Result` may be an `Err` variant, which should be handled
[00:59:45] 
[00:59:45] 
[00:59:45] warning: unused `std::result::Result` that must be used
[00:59:45]    |
[00:59:45]    |
[00:59:45] LL |         write!(&mut s, "test");
[00:59:45]    |
[00:59:45]    |
[00:59:45]    = note: this `Result` may be an `Err` variant, which should be handled
[00:59:45] 
[00:59:45] 
[00:59:45] 
[00:59:45] 
[00:59:45] 
[00:59:45] The actual stderr differed from the expected stderr.
[00:59:45] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/macros/colorful-write-macros/colorful-write-macros.stderr
[00:59:45] To update references, rerun the tests and pass the `--bless` flag
[00:59:45] To only update this specific test, also pass `--test-args macros/colorful-write-macros.rs`
[00:59:45] error: 1 errors occurred comparing output.
[00:59:45] status: exit code: 0
[00:59:45] status: exit code: 0
[00:59:45] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/macros/colorful-write-macros.rs" "--target=x86ghlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/run-pass/macros/colorful-write-macros.rs","byte_start":884,"byte_end":917,"line_start":35,"line_end":35,"column_start":5,"column_end":38,"is_primary":false,"text":[{"text":"    write!(&mut w as &mut Write, \"\");","highlight_start":5,"highlight_end":38}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"write!","def_site_span":{"file_name":"<::core::macros::write macros>","byte_start":0,"byte_end":98,"line_start":1,"line_end":2,"column_start":1,"column_end":56,"is_primary":false,"text":[{"text":"( $ dst : expr , $ ( $ arg : tt ) * ) => (","highlight_start":1,"highlight_end":43},{"text":"$ dst . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) )","highlight_start":1,"highlight_end":56}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"this `Result` may be an `Err` variant, which should be handled","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"warning: unused `std::result::Result` that must be used\n  --> /checkout/src/test/run-pass/macros/colorful-write-macros.rs:35:5\n   |\nLL |     write!(&mut w as &mut Write, \"\");\n   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: this `Result` may be an `Err` variant, which should be handled\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[00:59:45] {s/colorful-write-macros.rs:36:5\n   |\nLL |     write!(&mut w, \"\"); // should coerce\n   |     ^^^^^^^^^^^^^^^^^^^\n   |\n   = note: this `Result` may be an `Err` variant, which should be handled\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[00:59:45] {"message":"unused `std::result::Result` that must be used","code":{"code":"unused_must_use","explanation":null},"level":"warning","spans":[{"file_name":"<::core::macros::write macros>","byte_start":43,"byte_end":96,"line_start":2,"line_end":2,"column_start":1,"column_end":54,"is_primary":true,"text":[{"text":"$ dst . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/run-pass/macros/colorful-write-macros.rs","byte_start":1044,"byte_end":1067,"line_start":42,"line_end":42,"column_start":9,"column_end":32,"is_primary":false,"text":[{"text":"        write!(&mut s, \"test\");","highlight_start":9,"highlight_end":32}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"write!","def_site_span":{"file_name":"<::core::macros::write macros>","byte_start":0,"byte_end":98,"line_start":1,"line_end":2,"column_start":1,"column_end":56,"is_primary":false,"text":[{"text":"( $ dst : expr , $ ( $ arg : tt ) * ) => (","highlight_start":1,"highlight_end":43},{"text":"$ dst . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) )","highlight_start":1,"highlight_end":56}],"labe

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)

@alexcrichton
Copy link
Member

Looks like some tests may still be failing?

@durka
Copy link
Contributor Author

durka commented Nov 2, 2018 via email

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Nov 3, 2018

📌 Commit 706a1cc has been approved by alexcrichton

@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 Nov 3, 2018
@eddyb
Copy link
Member

eddyb commented Nov 3, 2018

It's writing into suggestion_choices which is... a String. So we should probably just unwrap these? Is that allowed in the compiler?

Yeah, write!(string, ...) can use unwrap. I wish the error type could be ! in that case, oh well.

@bors
Copy link
Contributor

bors commented Nov 4, 2018

⌛ Testing commit 706a1cc with merge 248745a...

bors added a commit that referenced this pull request Nov 4, 2018
enforce unused-must-use lint in macros

Fixes #55516 by turning on the UNUSED_MUST_USE lint within macros.
@bors
Copy link
Contributor

bors commented Nov 5, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 248745a to master...

@bors bors merged commit 706a1cc into rust-lang:master Nov 5, 2018
bors added a commit that referenced this pull request Nov 7, 2018
[beta] Fixes #46775 -- don't mutate the process's environment in Command::exec

This is a backport of the following PRs:

* #55359
* #55569
* #55304
bors added a commit that referenced this pull request Nov 8, 2018
[beta] Fixes #46775 -- don't mutate the process's environment in Command::exec

This is a backport of the following PRs:

* #55359
* #55569
* #55304
* #55661
@alexcrichton alexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 8, 2018
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.

8 participants