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

Clearer error message for dead assign #56439

Merged
merged 5 commits into from
Dec 16, 2018
Merged

Conversation

JohnGinger
Copy link
Contributor

I'm not that this is the right place for this (if it needs an RFC or not).

I had the problem where I misunderstood the compiler lint message #56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/.

I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons.

I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change.

If this is the wrong place for this sort of thing I'll happily delete/move it.

@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 @petrochenkov (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 2, 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:09494bd3:start=1543765780359699405,finish=1543765781466632479,duration=1106933074
$ 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:09] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:10] tidy error: /checkout/src/librustc/middle/liveness.rs:1661: line longer than 100 chars
[00:03:10] tidy error: /checkout/src/librustc/middle/liveness.rs:1664: line longer than 100 chars
[00:03:11] some tidy checks failed
[00:03:11] 
[00:03:11] 
[00:03:11] 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:11] 
[00:03:11] 
[00:03:11] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:11] Build completed unsuccessfully in 0:00:58
[00:03:11] Build completed unsuccessfully in 0:00:58
[00:03:11] Makefile:79: recipe for target 'tidy' failed
[00:03:11] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:006cf5b0
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sun Dec  2 15:53:01 UTC 2018
---
travis_time:end:02f303cf:start=1543765982192904323,finish=1543765982198075374,duration=5171051
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:00bcb8b7
$ 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:37d76a8b
travis_time:start:37d76a8b
$ 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:0031d646
$ 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

To further clarify what's being linted, the warning should also highlight the value it's talking about, not the variable the value is assigned to

@JohnGinger
Copy link
Contributor Author

@jonas-schievink makes sense - I'm not sure I'd know how to do that though (without making a lot of changes to this file)

@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:2066a831:start=1543768649367594094,finish=1543768650374595136,duration=1007001042
$ 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:45:52] .................................................................................................... 2600/5107
[00:45:56] .................................................................................................... 2700/5107
[00:45:59] .................................................................................................... 2800/5107
[00:46:02] .................................................................................................... 2900/5107
[00:46:05] ................................F................................................................... 3000/5107
[00:46:09] ...................................F......F..................................i...................... 3100/5107
[00:46:15] ........................................ii..i..ii................................................... 3300/5107
[00:46:18] .................................................................................................... 3400/5107
[00:46:21] .................................................................................................... 3500/5107
[00:46:24] .....................ii............................................................................. 3600/5107
---
[00:47:10] 
[00:47:10] ---- [ui] ui/lint/issue-47390-unused-variable-in-struct-pattern.rs stdout ----
[00:47:10] diff of stderr:
[00:47:10] 
[00:47:10] 44    = note: consider using `_hours_are_suns` instead
[00:47:10] 45 
[00:47:10] 46 warning: value assigned to `hours_are_suns` is never read
[00:47:10]on_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `i_think_continually`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:36:9\n   |\nLL |     let i_think_continually = 2;\n   |         ^^^^^^^^^^^^^^^^^^^ help: consider using `_i_think_continually` instead\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:15:9\n   |\nLL | #![warn(unused)] // UI tests pass `-A unused` (#43896)\n   |         ^^^^^^\n   = note: #[warn(unused_variables)] implied by #[warn(unused)]\n\n"}
[00:47:10] {"message":"unused variable: `mut_unused_var`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1061,"byte_end":1075,"line_start":43,"line_end":43,"column_start":13,"column_end":27,"is_primary":true,"text":[{"text":"    let mut mut_unused_var = 1;","highlight_start":13,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `_mut_unused_var` instead","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1061,"byte_end":1075,"line_start":43,"line_end":43,"column_start":13,"column_end":27,"is_primary":true,"text":[{"text":"    let mut mut_unused_var = 1;","highlight_start":13,"highlight_end":27}],"label":null,"suggested_replacement":"_mut_unused_var","suggestion_aansion":null}],"children":[{"message":"try ignoring the field","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1847,"byte_end":1851,"line_start":78,"line_end":78,"column_start":24,"column_end":28,"is_primary":true,"text":[{"text":"        (Large::Suit { case },) => {}","highlight_start":24,"highlight_end":28}],"label":null,"suggested_replacement":"case: _","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `case`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:78:24\n   |\nLL |         (Large::Suit { case },) => {}\n   |                        ^^^^ help: try ignoring the field: `case: _`\n\n"}
[00:47:10] {"message":"unused variable: `case`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1936,"byte_end":1940,"line_start":83,"line_end":83,"column_start":24,"column_end":28,"is_primary":true,"text":[{"text":"        [Large::Suit { case }] => {}","highlight_start":24,"highlight_end":28}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try ignoring the field","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1936,"byte_end":1940,"line_start":83,"line_end":83,"column_start":24,"column_end":28,"is_primary":true,"text":[{"text":"     nused-variable-in-struct-pattern.rs:88:29\n   |\nLL |         Tuple(Large::Suit { case }, ()) => {}\n   |                             ^^^^ help: try ignoring the field: `case: _`\n\n"}
[00:47:10] {"message":"variable does not need to be mutable","code":{"code":"unused_mut","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1057,"byte_end":1075,"line_start":43,"line_end":43,"column_start":9,"column_end":27,"is_primary":true,"text":[{"text":"    let mut mut_unused_var = 1;","highlight_start":9,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":542,"byte_end":548,"line_start":15,"line_end":15,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"#![warn(unused)] // UI tests pass `-A unused` (#43896)","highlight_start":9,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"#[warn(unused_mut)] implied by #[warn(unused)]","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove this `mut`","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1057,"byte_end":1061,"line_start":43,"line_end":43,"column_start":9,"column_end":13,"is_primary":true,"text":[{"te7:10] +                      (maybe it is overwritten before being read)
[00:47:10] 21    |
[00:47:10] 21    |
[00:47:10] 22 LL | fn f4(mut x: i32) { //~ ERROR: value passed to `x` is never read
[00:47:10] 23    |           ^
[00:47:10] 24 
[00:47:10] 25 error: value assigned to `x` is never read
[00:47:10] 25 error: value assigned to `x` is never read
[00:47:10] +                      (maybe it is overwritten before being read)
[00:47:10] 27    |
[00:47:10] 27    |
[00:47:10] 28 LL |     x = 4; //~ ERROR: value assigned to `x` is never read
[00:47:10] 
[00:47:10] The actual stderr differed from the expected stderr.
[00:47:10] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/liveness/liveness-dead/liveness-dead.stderr
[00:47:10] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/liveness/liveness-dead/liveness-dead.stderr
[00:47:10] To update references, rerun the tests and pass the `--bless` flag
[00:47:10] To only update this specific test, also pass `--test-args liveness/liveness-dead.rs`
[00:47:10] error: 1 errors occurred comparing output.
[00:47:10] status: exit code: 1
[00:47:10] status: exit code: 1
[00:47:10] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/liveness/liveness-dead.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/ui/liveness/liveness-dead/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/ui/liveness/liveness-dead/auxiliary" "-A" "unused"
[00:47:10] stdout:
[00:47:10] ----------rwritten before being read)\n  --> /checkout/src/test/ui/liveness/liveness-dead.rs:30:11\n   |\nLL | fn f4(mut x: i32) { //~ ERROR: value passed to `x` is never read\n   |           ^\n\n"}
[00:47:10] {"message":"value assigned to `x` is never read\n                     (maybe it is overwritten before being read)","code":{"code":"unused_assignments","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/liveness/liveness-dead.rs","byte_start":925,"byte_end":926,"line_start":37,"line_end":37,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    x = 4; //~ ERROR: value assigned to `x` is never read","highlight_start":5,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: value assigned to `x` is never read\n                     (maybe it is overwritten before being read)\n  --> /checkout/src/test/ui/liveness/liveness-dead.rs:37:5\n   |\nLL |     x = 4; //~ ERROR: value assigned to `x` is never read\n   |     ^\n\n"}
[00:47:10] {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors\n\n"}
[00:47:10] ------------------------------------------
[00:47:10] 
[00:47:10] thread '[ui] ui/liveness/liveness-dead.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3282:9
[00:47:10] 
---
[00:47:10] 
[00:47:10] ------------------------------------------
[00:47:10] stderr:
[00:47:10] ------------------------------------------
[00:47:10] {"message":"unreachable statement","code":{"code":"unreachable_code","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/liveness/liveness-unused.rs","byte_start":1974,"byte_end":1990,"line_start":102,"line_end":102,"column_start":9,"column_end":25,"is_primary":true,"text":[{"text":"        drop(*x as i32); //~ WARNING unreachable statement","highlight_start":9,"highlight_end":25}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/liveness/liveness-unused.rs","byte_start":475,"byte_end":481,"line_start":11,"line_end":11,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"#![warn(unused)]","highlight_start":9,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"#[warn(unreachable_code)] implied by #[warn(unused)]","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"warning: unreachable statement\n  --> /checkout/src/test/ui/liveness/liveness-unused.rs:102:9\n   |\nLL |         drop(*x as i32); //~ WARNING unreachable statement\n   |         ^^^^^^^^^^^^^^^^\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/liveness/liveness-unused.rs:11:9\n   |\nLLe) {\n   |       ^ help: consider using `_x` instead\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/liveness/liveness-unused.rs:12:9\n   |\nLL | #![deny(unused_variables)]\n   |         ^^^^^^^^^^^^^^^^\n\n"}
[00:47:10] {"message":"unused variable: `x`","code":{"code":"unused_variables","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/liveness/liveness-unused.rs","byte_start":697,"byte_end":698,"line_start":22,"line_end":22,"column_start":8,"column_end":9,"is_primary":true,"text":[{"text":"fn f1b(x: &mut isize) {","highlight_start":8,"highlight_end":9}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `_x` instead","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/liveness/liveness-unused.rs","byte_start":697,"byte_end":698,"line_start":22,"line_end":22,"column_start":8,"column_end":9,"is_primary":true,"text":[{"text":"fn f1b(x: &mut isize) {","highlight_start":8,"highlight_end":9}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error: unused variable: `x`\n  --> /checkout/src/test/ui/liveness/liveness-unused.rs:22:8\n   |\nLL | fn f1b(x: &mut isize) {\n   |        ^ help: consider using `_x` instead\n\n"}
[00:47:10] {"message":"unused variable: `x`","code":{"code":"unused_variables","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/liveness/liveness-unused.rs","byte_start":820,"byte_end":821,"line_start":30,"line_end":30,"column_start":light_start":9,"highlight_end":10}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error: unused variable: `x`\n  --> /checkout/src/test/ui/liveness/liveness-unused.rs:35:9\n   |\nLL |     let x = 3;\n   |         ^ help: consider using `_x` instead\n\n"}
[00:47:10] {"message":"variable `x` is assigned to, but never used","code":{"code":"unused_variables","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/liveness/liveness-unused.rs","byte_start":955,"byte_end":956,"line_start":40,"line_end":40,"column_start":13,"column_end":14,"is_primary":true,"text":[{"text":"    let mut x = 3;","highlight_start":13,"highlight_end":14}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `_x` instead","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error: variable `x` is assigned to, but never used\n  --> /checkout/src/test/ui/liveness/liveness-unused.rs:40:13\n   |\nLL |     let mut x = 3;\n   |             ^\n   |\n   = note: consider using `_x` instead\n\n"}
[00:47:10] {"message":"value assigned to `x` is never read\n                     (maybe it is overwritten before being read)","code":{"code":"unused_assignments","explanation":null},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/liveness/liveness-unused.rs","byte_start":1025,"byte_end":1026,"line_start":42,"line_end":42,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    x += 4;","highlight_start":5,"hig

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

Perhaps the "overwritten" message can be reported only if the value is actually overwritten, not simply unread? If there's no necessary infra, then the wording change seems okay.
r? @nikomatsakis

@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:09cf9760:start=1543833019891751622,finish=1543833080791020695,duration=60899269073
$ 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:47:17] .................................................................................................... 2600/5107
[00:47:22] .................................................................................................... 2700/5107
[00:47:25] .................................................................................................... 2800/5107
[00:47:28] .................................................................................................... 2900/5107
[00:47:31] ................................F................................................................... 3000/5107
[00:47:38] .................................................................................................... 3200/5107
[00:47:41] ........................................ii..i..ii................................................... 3300/5107
[00:47:45] .................................................................................................... 3400/5107
[00:47:48] .................................................................................................... 3500/5107
---
[00:48:38] 
[00:48:38] ---- [ui] ui/lint/issue-47390-unused-variable-in-struct-pattern.rs stdout ----
[00:48:38] diff of stderr:
[00:48:38] 
[00:48:38] 44    = note: consider using `_hours_are_suns` instead
[00:48:38] 45 
[00:48:38] 46 warning: value assigned to `hours_are_suns` is never read
[00:48:38] +                      (maybe it is overwritten before being read)
[00:48:38] 48    |
[00:48:38] 48    |
[00:48:38] 49 LL |         hours_are_suns = false;
[00:48:38] 
[00:48:38] The actual stderr differed from the expected stderr.
[00:48:38] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lint/issue-47390-unused-variable-in-struct-pattern/issue-47390-unused-variable-in-struct-pattern.stderr
[00:48:38] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lint/issue-47390-unused-variable-in-struct-pattern/issue-47390-unused-variable-in-struct-pattern.stderr
[00:48:38] To update references, rerun the tests and pass the `--bless` flag
[00:48:38] To only update this specific test, also pass `--test-args lint/issue-47390-unused-variable-in-struct-pattern.rs`
[00:48:38] error: 1 errors occurred comparing output.
[00:48:38] status: exit code: 0
[00:48:38] status: exit code: 0
[00:48:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.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/ui/lint/issue-47390-unused-variable-in-struct-pattern/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/ui/lint/issue-47390-unused-variable-in-struct-pattern/auxiliary" "-A" "unused"
[00:48:38] ------------------------------------------
[00:48:38] 
[00:48:38] ------------------------------------------
[00:48:38] stderr:
[00:48:38] stderr:
[00:48:38] ------------------------------------------
[00:48:38] {"message":"unused variable: `i_think_continually`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":868,"byte_end":887,"line_start":36,"line_end":36,"column_start":9,"column_end":28,"is_primary":true,"text":[{"text":"    let i_think_continually = 2;","highlight_start":9,"highlight_end":28}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":542,"byte_end":548,"line_start":15,"line_end":15,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"#![warn(unused)] // UI tests pass `-A unused` (#43896)","highlight_start":9,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"#[warn(unused_variables)] implied by #[warn(unused)]","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"consider using `_i_think_continually` instead","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":868,"byte_end":887,"line_start":36,"line_end":36,"column_start":9,"column_end":28,"is_primary":true,"text":[{"text":"    let i_think_continually = 2;","highlight_start":9,"highlight_end":28}],"label":null,"suggested_replacement":"_i_think_continually","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `i_think_continually`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:36:9\n   |\nLL |     let i_think_continually = 2;\n   |         ^^^^^^^^^^^^^^^^^^^ help: consider using `_i_think_continually` instead\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:15:9\n   |\nLL | #![warn(unused)] // UI tests pass `-A unused` (#43896)\n   |         ^^^^^^\n   = note: #[warn(unused_variables)] implied by #[warn(unused)]\n\n"}
[00:48:38] {"message":"unused variable: `mut_unused_var`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1061,"byte_end":1075,"line_start":43,"line_end":43,"column_start":13,"column_end":27,"is_primary":true,"text":[{"text":"    let mut mut_unused_var = 1;","highlight_start":13,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `_mut_unused_var` instead","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1061,"byte_end":1075,"line_start":43,"line_end":43,"column_start":13,"column_end":27,"is_primary":true,"text":[{"text":"    let mut mut_unused_var = 1;","highlight_start":13,"highlight_end":27}],"label":null,"suggested_replacement":"_mut_unused_var","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `mut_unused_var`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:43:13\n   |\nLL |     let mut mut_unused_var = 1;\n   |             ^^^^^^^^^^^^^^ help: consider using `_mut_unused_var` instead\n\n"}
[00:48:38] {"message":"unused variable: `var`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1095,"byte_end":1098,"line_start":45,"line_end":45,"column_start":14,"column_end":17,"is_primary":true,"text":[{"text":"    let (mut var, unused_var) = (1, 2);","highlight_start":14,"highlight_end":17}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `_var` instead","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1095,"byte_end":1098,"line_start":45,"line_end":45,"column_start":14,"column_end":17,"is_primary":true,"text":[{"text":"    let (mut var, unused_var) = (1, 2);","highlight_start":14,"highlight_end":17}],"label":null,"suggested_replacement":"_var","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `var`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:45:14\n   |\nLL |     let (mut var, unused_var) = (1, 2);\n   |              ^^^ help: consider using `_var` instead\n\n"}
[00:48:38] {"message":"unused variable: `unused_var`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1100,"byte_end":1110,"line_start":45,"line_end":45,"column_start":19,"column_end":29,"is_primary":true,"text":[{"text":"    let (mut var, unused_var) = (1, 2);","highlight_start":19,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `_unused_var` instead","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1100,"byte_end":1110,"line_start":45,"line_end":45,"column_start":19,"column_end":29,"is_primary":true,"text":[{"text":"    let (mut var, unused_var) = (1, 2);","highlight_start":19,"highlight_end":29}],"label":null,"suggested_replacement":"_unused_var","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `unused_var`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:45:19\n   |\nLL |     let (mut var, unused_var) = (1, 2);\n   |                   ^^^^^^^^^^ help: consider using `_unused_var` instead\n\n"}
[00:48:38] {"message":"unused variable: `corridors_of_light`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1148,"byte_end":1166,"line_start":47,"line_end":47,"column_start":26,"column_end":44,"is_primary":true,"text":[{"text":"    if let SoulHistory { corridors_of_light,","highlight_start":26,"highlight_end":44}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try ignoring the field","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1148,"byte_end":1166,"line_start":47,"line_end":47,"column_start":26,"column_end":44,"is_primary":true,"text":[{"text":"    if let SoulHistory { corridors_of_light,","highlight_start":26,"highlight_end":44}],"label":null,"suggested_replacement":"corridors_of_light: _","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `corridors_of_light`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:47:26\n   |\nLL |     if let SoulHistory { corridors_of_light,\n   |                          ^^^^^^^^^^^^^^^^^^ help: try ignoring the field: `corridors_of_light: _`\n\n"}
[00:48:38] {"message":"variable `hours_are_suns` is assigned to, but never used","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1197,"byte_end":1211,"line_start":48,"line_end":48,"column_start":30,"column_end":44,"is_primary":true,"text":[{"text":"                         mut hours_are_suns,","highlight_start":30,"highlight_end":44}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider using `_hours_are_suns` instead","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"warning: variable `hours_are_suns` is assigned to, but never used\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:48:30\n   |\nLL |                          mut hours_are_suns,\n   |                              ^^^^^^^^^^^^^^\n   |\n   = note: consider using `_hours_are_suns` instead\n\n"}
[00:48:38] {"message":"value assigned to `hours_are_suns` is never read\n                     (maybe it is overwritten before being read)","code":{"code":"unused_assignments","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1307,"byte_end":1321,"line_start":50,"line_end":50,"column_start":9,"column_end":23,"is_primary":true,"text":[{"text":"        hours_are_suns = false;","highlight_start":9,"highlight_end":23}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":542,"byte_end":548,"line_start":15,"line_end":15,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"#![warn(unused)] // UI tests pass `-A unused` (#43896)","highlight_start":9,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"#[warn(unused_assignments)] implied by #[warn(unused)]","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"warning: value assigned to `hours_are_suns` is never read\n                     (maybe it is overwritten before being read)\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:50:9\n   |\nLL |         hours_are_suns = false;\n   |         ^^^^^^^^^^^^^^\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:15:9\n   |\nLL | #![warn(unused)] // UI tests pass `-A unused` (#43896)\n   |         ^^^^^^\n   = note: #[warn(unused_assignments)] implied by #[warn(unused)]\n\n"}
[00:48:38] {"message":"unused variable: `fire`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1427,"byte_end":1431,"line_start":54,"line_end":54,"column_start":32,"column_end":36,"is_primary":true,"text":[{"text":"    let LovelyAmbition { lips, fire } = the_spirit;","highlight_start":32,"highlight_end":36}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try ignoring the field","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1427,"byte_end":1431,"line_start":54,"line_end":54,"column_start":32,"column_end":36,"is_primary":true,"text":[{"text":"    let LovelyAmbition { lips, fire } = the_spirit;","highlight_start":32,"highlight_end":36}],"label":null,"suggested_replacement":"fire: _","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `fire`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:54:32\n   |\nLL |     let LovelyAmbition { lips, fire } = the_spirit;\n   |                                ^^^^ help: try ignoring the field: `fire: _`\n\n"}
[00:48:38] {"message":"unused variable: `case`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1586,"byte_end":1590,"line_start":63,"line_end":63,"column_start":23,"column_end":27,"is_primary":true,"text":[{"text":"        Large::Suit { case } => {}","highlight_start":23,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try ignoring the field","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1586,"byte_end":1590,"line_start":63,"line_end":63,"column_start":23,"column_end":27,"is_primary":true,"text":[{"text":"        Large::Suit { case } => {}","highlight_start":23,"highlight_end":27}],"label":null,"suggested_replacement":"case: _","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `case`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:63:23\n   |\nLL |         Large::Suit { case } => {}\n   |                       ^^^^ help: try ignoring the field: `case: _`\n\n"}
[00:48:38] {"message":"unused variable: `case`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1672,"byte_end":1676,"line_start":68,"line_end":68,"column_start":24,"column_end":28,"is_primary":true,"text":[{"text":"        &Large::Suit { case } => {}","highlight_start":24,"highlight_end":28}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try ignoring the field","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1672,"byte_end":1676,"line_start":68,"line_end":68,"column_start":24,"column_end":28,"is_primary":true,"text":[{"text":"        &Large::Suit { case } => {}","highlight_start":24,"highlight_end":28}],"label":null,"suggested_replacement":"case: _","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `case`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:68:24\n   |\nLL |         &Large::Suit { case } => {}\n   |                        ^^^^ help: try ignoring the field: `case: _`\n\n"}
[00:48:38] {"message":"unused variable: `case`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1759,"byte_end":1763,"line_start":73,"line_end":73,"column_start":27,"column_end":31,"is_primary":true,"text":[{"text":"        box Large::Suit { case } => {}","highlight_start":27,"highlight_end":31}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try ignoring the field","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1759,"byte_end":1763,"line_start":73,"line_end":73,"column_start":27,"column_end":31,"is_primary":true,"text":[{"text":"        box Large::Suit { case } => {}","highlight_start":27,"highlight_end":31}],"label":null,"suggested_replacement":"case: _","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `case`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:73:27\n   |\nLL |         box Large::Suit { case } => {}\n   |                           ^^^^ help: try ignoring the field: `case: _`\n\n"}
[00:48:38] {"message":"unused variable: `case`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1847,"byte_end":1851,"line_start":78,"line_end":78,"column_start":24,"column_end":28,"is_primary":true,"text":[{"text":"        (Large::Suit { case },) => {}","highlight_start":24,"highlight_end":28}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try ignoring the field","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1847,"byte_end":1851,"line_start":78,"line_end":78,"column_start":24,"column_end":28,"is_primary":true,"text":[{"text":"        (Large::Suit { case },) => {}","highlight_start":24,"highlight_end":28}],"label":null,"suggested_replacement":"case: _","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `case`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:78:24\n   |\nLL |         (Large::Suit { case },) => {}\n   |                        ^^^^ help: try ignoring the field: `case: _`\n\n"}
[00:48:38] {"message":"unused variable: `case`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1936,"byte_end":1940,"line_start":83,"line_end":83,"column_start":24,"column_end":28,"is_primary":true,"text":[{"text":"        [Large::Suit { case }] => {}","highlight_start":24,"highlight_end":28}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try ignoring the field","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1936,"byte_end":1940,"line_start":83,"line_end":83,"column_start":24,"column_end":28,"is_primary":true,"text":[{"text":"        [Large::Suit { case }] => {}","highlight_start":24,"highlight_end":28}],"label":null,"suggested_replacement":"case: _","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `case`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:83:24\n   |\nLL |         [Large::Suit { case }] => {}\n   |                        ^^^^ help: try ignoring the field: `case: _`\n\n"}
[00:48:38] {"message":"unused variable: `case`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":2045,"byte_end":2049,"line_start":88,"line_end":88,"column_start":29,"column_end":33,"is_primary":true,"text":[{"text":"        Tuple(Large::Suit { case }, ()) => {}","highlight_start":29,"highlight_end":33}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try ignoring the field","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":2045,"byte_end":2049,"line_start":88,"line_end":88,"column_start":29,"column_end":33,"is_primary":true,"text":[{"text":"        Tuple(Large::Suit { case }, ()) => {}","highlight_start":29,"highlight_end":33}],"label":null,"suggested_replacement":"case: _","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `case`\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:88:29\n   |\nLL |         Tuple(Large::Suit { case }, ()) => {}\n   |                             ^^^^ help: try ignoring the field: `case: _`\n\n"}
[00:48:38] {"message":"variable does not need to be mutable","code":{"code":"unused_mut","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1057,"byte_end":1075,"line_start":43,"line_end":43,"column_start":9,"column_end":27,"is_primary":true,"text":[{"text":"    let mut mut_unused_var = 1;","highlight_start":9,"highlight_end":27}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":542,"byte_end":548,"line_start":15,"line_end":15,"column_start":9,"column_end":15,"is_primary":true,"text":[{"text":"#![warn(unused)] // UI tests pass `-A unused` (#43896)","highlight_start":9,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"#[warn(unused_mut)] implied by #[warn(unused)]","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove this `mut`","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1057,"byte_end":1061,"line_start":43,"line_end":43,"column_start":9,"column_end":13,"is_primary":true,"text":[{"text":"    let mut mut_unused_var = 1;","highlight_start":9,"highlight_end":13}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: variable does not need to be mutable\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:43:9\n   |\nLL |     let mut mut_unused_var = 1;\n   |         ----^^^^^^^^^^^^^^\n   |         |\n   |         help: remove this `mut`\n   |\nnote: lint level defined here\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:15:9\n   |\nLL | #![warn(unused)] // UI tests pass `-A unused` (#43896)\n   |         ^^^^^^\n   = note: #[warn(unused_mut)] implied by #[warn(unused)]\n\n"}
[00:48:38] {"message":"variable does not need to be mutable","code":{"code":"unused_mut","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1091,"byte_end":1098,"line_start":45,"line_end":45,"column_start":10,"column_end":17,"is_primary":true,"text":[{"text":"    let (mut var, unused_var) = (1, 2);","highlight_start":10,"highlight_end":17}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"remove this `mut`","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs","byte_start":1091,"byte_end":1095,"line_start":45,"line_end":45,"column_start":10,"column_end":14,"is_primary":true,"text":[{"text":"    let (mut var, unused_var) = (1, 2);","highlight_start":10,"highlight_end":14}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: variable does not need to be mutable\n  --> /checkout/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs:45:10\n   |\nLL |     let (mut var, unused_var) = (1, 2);\n   |          ----^^^\n   |          |\n   |          help: remove this `mut`\n\n"}
[00:48:38] ------------------------------------------
[00:48:38] 
[00:48:38] thread '[ui] ui/lint/issue-47390-unused-variable-in-struct-pattern.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3282:9
[00:48:38] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[00:48:38] test result: FAILED. 5082 passed; 1 failed; 24 ignored; 0 measured; 0 filtered out
[00:48:38] 
[00:48:38] 
[00:48:38] 
[00:48:38] 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/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--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  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--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:48:38] 
[00:48:38] 
[00:48:38] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:48:38] Build completed unsuccessfully in 0:03:52
[00:48:38] Build completed unsuccessfully in 0:03:52
[00:48:38] Makefile:58: recipe for target 'check' failed
[00:48:38] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:133f2bb6
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Dec  3 11:20:09 UTC 2018

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)

} else {
self.ir.tcx.lint_hir(lint::builtin::UNUSED_ASSIGNMENTS, hir_id, sp,
&format!("value assigned to `{}` is never read", name));
&format!("value assigned to `{}` is never read
(maybe it is overwritten before being read)", name));
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, it's a nice idea to make a suggestion like this. It'd be nicer if we could find the overwriting assignment. But i'm reluctant to suggest trying to implement that, since this liveness code is ripe to be rewritten completely.

Still, I think that including the suggestion in a parenthetical makes it less likely to be noticed, and more likely to wrap around on the terminal.

A middle option would be to create a "help". You could change this code from self.ir.tcx.lint_hir(..) to:

let msg = self.ir.tcx.self.struct_span_lint_hir(...)
  .help("maybe it is overwritten before being read?")
  .emit();

and I think things would look better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me.

I could try rewriting the liveness code, but I don't think I know enough about how it works...

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd love to talk you through it =) but it'd obviously be a rather bigger endeavor :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy to try :)

@nikomatsakis
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 11, 2018

📌 Commit c0e3f4b has been approved by nikomatsakis

@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 11, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Dec 11, 2018
Clearer error message for dead assign

I'm not that this is the right place for this (if it needs an RFC or not).

I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/.

I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons.

I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change.

If this is the wrong place for this sort of thing I'll happily delete/move it.
kennytm added a commit to kennytm/rust that referenced this pull request Dec 12, 2018
Clearer error message for dead assign

I'm not that this is the right place for this (if it needs an RFC or not).

I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/.

I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons.

I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change.

If this is the wrong place for this sort of thing I'll happily delete/move it.
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Dec 12, 2018
Clearer error message for dead assign

I'm not that this is the right place for this (if it needs an RFC or not).

I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/.

I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons.

I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change.

If this is the wrong place for this sort of thing I'll happily delete/move it.
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Dec 13, 2018
Clearer error message for dead assign

I'm not that this is the right place for this (if it needs an RFC or not).

I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/.

I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons.

I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change.

If this is the wrong place for this sort of thing I'll happily delete/move it.
kennytm added a commit to kennytm/rust that referenced this pull request Dec 13, 2018
Clearer error message for dead assign

I'm not that this is the right place for this (if it needs an RFC or not).

I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/.

I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons.

I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change.

If this is the wrong place for this sort of thing I'll happily delete/move it.
kennytm added a commit to kennytm/rust that referenced this pull request Dec 14, 2018
Clearer error message for dead assign

I'm not that this is the right place for this (if it needs an RFC or not).

I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/.

I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons.

I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change.

If this is the wrong place for this sort of thing I'll happily delete/move it.
kennytm added a commit to kennytm/rust that referenced this pull request Dec 14, 2018
Clearer error message for dead assign

I'm not that this is the right place for this (if it needs an RFC or not).

I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/.

I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons.

I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change.

If this is the wrong place for this sort of thing I'll happily delete/move it.
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Dec 14, 2018
Clearer error message for dead assign

I'm not that this is the right place for this (if it needs an RFC or not).

I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/.

I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons.

I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change.

If this is the wrong place for this sort of thing I'll happily delete/move it.
Centril added a commit to Centril/rust that referenced this pull request Dec 16, 2018
Clearer error message for dead assign

I'm not that this is the right place for this (if it needs an RFC or not).

I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/.

I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons.

I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change.

If this is the wrong place for this sort of thing I'll happily delete/move it.
bors added a commit that referenced this pull request Dec 16, 2018
Rollup of 20 pull requests

Successful merges:

 - #53506 (Documentation for impl From for AtomicBool and other Atomic types)
 - #56343 (Remove not used mod)
 - #56439 (Clearer error message for dead assign)
 - #56640 (Add FreeBSD unsigned char platforms to std::os::raw)
 - #56648 (Fix BTreeMap UB)
 - #56672 (Document time of back operations of a Linked List)
 - #56706 (Make `const unsafe fn` bodies `unsafe`)
 - #56742 (infer: remove Box from a returned Iterator)
 - #56761 (Suggest using `.display()` when trying to print a `Path`)
 - #56781 (Update LLVM submodule)
 - #56789 (rustc: Add an unstable `simd_select_bitmask` intrinsic)
 - #56790 (Make RValue::Discriminant a normal Shallow read)
 - #56793 (rustdoc: look for comments when scraping attributes/crates from doctests)
 - #56826 (rustc: Add the `cmpxchg16b` target feature on x86/x86_64)
 - #56832 (std: Use `rustc_demangle` from crates.io)
 - #56844 (Improve CSS rule)
 - #56850 (Fixed issue with using `Self` ctor in typedefs)
 - #56855 (Remove u8 cttz hack)
 - #56857 (Fix a small mistake regarding NaNs in a deprecation message)
 - #56858 (Fix doc of `std::fs::canonicalize`)

Failed merges:

 - #56741 (treat ref-to-raw cast like a reborrow: do a special kind of retag)

r? @ghost
@bors bors merged commit c0e3f4b into rust-lang:master Dec 16, 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.

6 participants