Skip to content

Break query cycles without spawning a separate thread#155927

Open
zetanumbers wants to merge 2 commits intorust-lang:mainfrom
zetanumbers:break_cycle_in_worker
Open

Break query cycles without spawning a separate thread#155927
zetanumbers wants to merge 2 commits intorust-lang:mainfrom
zetanumbers:break_cycle_in_worker

Conversation

@zetanumbers
Copy link
Copy Markdown
Contributor

@zetanumbers zetanumbers commented Apr 28, 2026

This PR removes separate thread for query cycle breaking. Essentially I made sure that behavior right before a block is done before deadlock handler is called.

TODO: explain in a comment that we use CurrentGcx in case worker thread no longer has any tasks to execute and triggers a deadlock handler, which means there's no ImplicitCtxt set to extract tcx from.

While this code is very unpolished at the moment and introduces some test failures due to diagnostics, it's a proof of concept and a place for feedback. I plan to make query cycle handling blocking of all worker threads in order to add something like a WorkerLocal::as_deadlocked to return every worker-local value in future. This is one of the stepping stones to remake query state hash table with QueryJob's into something more worker-thread-local.
Blocked on #155881.

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 28, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 21 candidates

@zetanumbers
Copy link
Copy Markdown
Contributor Author

r? @nnethercote

@rustbot rustbot assigned nnethercote and unassigned jackh726 Apr 28, 2026
@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Executing "/scripts/stage_2_test_set1.sh"
+ /scripts/stage_2_test_set1.sh
PR_CI_JOB set; skipping tidy
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip compiler --skip src
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://static.rust-lang.org/dist/2026-04-14/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.xz
---
---- [ui] tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/closures/2229_closure_analysis/diagnostics/liveness/liveness.stderr`
diff of stderr:

1 warning: value assigned to `c.x` is never read
-   --> $DIR/liveness.rs:46:9
+   --> $DIR/liveness.rs:47:9
3    |
4 LL |         c.x += 1;
5    |         ^^^^^^^^
---
19    |         ^^^^^^

21    = help: maybe it is overwritten before being read?
22 
23 warning: value captured by `c.x` is never read
-   --> $DIR/liveness.rs:28:9
+   --> $DIR/liveness.rs:29:9
25    |
26 LL |         c.x += 1;
27    |         ^^^

29    = help: did you mean to capture by reference instead?
30 
31 warning: value assigned to `c.x` is never read
-   --> $DIR/liveness.rs:28:9
+   --> $DIR/liveness.rs:29:9
33    |
34 LL |         c.x += 1;
35    |         ^^^^^^^^
---
51    |         ^^^^^^

53    = help: maybe it is overwritten before being read?
54 
55 warning: value captured by `c.x` is never read
-   --> $DIR/liveness.rs:20:9
+   --> $DIR/liveness.rs:21:9
57    |
58 LL |         c.x = 1;
59    |         ^^^
---
67    |         ^

69    = help: did you mean to capture by reference instead?
70 
71 warning: value captured by `e.x` is never read
-   --> $DIR/liveness.rs:74:13
+   --> $DIR/liveness.rs:75:13
73    |
74 LL |             e.x = Some("e1");
75    |             ^^^

77    = help: did you mean to capture by reference instead?
78 
79 warning: value assigned to `e.x` is never read
-   --> $DIR/liveness.rs:74:13
+   --> $DIR/liveness.rs:75:13
81    |
82 LL |             e.x = Some("e1");
83    |             ^^^^^^^^^^^^^^^^ this value is reassigned later and never used

86    |             ---------------- `e.x` is overwritten here before the previous value is read
87 
88 warning: value assigned to `e.x` is never read
-   --> $DIR/liveness.rs:76:13
+   --> $DIR/liveness.rs:77:13
90    |
91 LL |             e.x = Some("e2");
92    |             ^^^^^^^^^^^^^^^^

94    = help: maybe it is overwritten before being read?
95 
96 warning: value captured by `b` is never read
---
117    |             ^^^^^^^^^^^^^^

119    = help: maybe it is overwritten before being read?
120 
121 warning: value assigned to `d.x` is never read
-   --> $DIR/liveness.rs:68:13
+   --> $DIR/liveness.rs:69:13
123    |
124 LL |             d.x = Some("d1");
125    |             ^^^^^^^^^^^^^^^^ this value is reassigned later and never used

127    |             ---------------- `d.x` is overwritten here before the previous value is read
128 
129 warning: value assigned to `a` is never read
-   --> $DIR/liveness.rs:70:13
+   --> $DIR/liveness.rs:71:13
131    |
---
To only update this specific test, also pass `--test-args closures/2229_closure_analysis/diagnostics/liveness.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/closures/2229_closure_analysis/diagnostics/liveness" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
warning: value assigned to `c.x` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:47:9
   |
LL |         c.x += 1; //~ WARN value assigned to `c.x` is never read
   |         ^^^^^^^^
   |
   = help: maybe it is overwritten before being read?
note: the lint level is defined here
  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:6:9
---

warning: value assigned to `a` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:49:9
   |
LL |         a += 1; //~ WARN value assigned to `a` is never read
   |         ^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value captured by `c.x` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:29:9
   |
LL |         c.x += 1; //~  WARN value captured by `c.x` is never read
   |         ^^^
   |
   = help: did you mean to capture by reference instead?

warning: value assigned to `c.x` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:29:9
   |
LL |         c.x += 1; //~  WARN value captured by `c.x` is never read
   |         ^^^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value captured by `a` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:31:9
   |
LL |         a += 1; //~  WARN value captured by `a` is never read
   |         ^
   |
   = help: did you mean to capture by reference instead?

warning: value assigned to `a` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:31:9
   |
LL |         a += 1; //~  WARN value captured by `a` is never read
   |         ^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value captured by `c.x` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:21:9
   |
LL |         c.x = 1; //~ WARN value captured by `c.x` is never read
   |         ^^^
   |
   = help: did you mean to capture by reference instead?

warning: value captured by `a` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:23:9
   |
LL |         a = 1; //~ WARN value captured by `a` is never read
   |         ^
   |
   = help: did you mean to capture by reference instead?

warning: value captured by `e.x` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:75:13
   |
LL |             e.x = Some("e1"); //~  WARN value captured by `e.x` is never read
   |             ^^^
   |
   = help: did you mean to capture by reference instead?

warning: value assigned to `e.x` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:75:13
   |
LL |             e.x = Some("e1"); //~  WARN value captured by `e.x` is never read
   |             ^^^^^^^^^^^^^^^^ this value is reassigned later and never used
LL |                               //~| WARN value assigned to `e.x` is never read
LL |             e.x = Some("e2"); //~  WARN value assigned to `e.x` is never read
   |             ---------------- `e.x` is overwritten here before the previous value is read

warning: value assigned to `e.x` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:77:13
   |
LL |             e.x = Some("e2"); //~  WARN value assigned to `e.x` is never read
   |             ^^^^^^^^^^^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value captured by `b` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:78:13
   |
LL |             b = Some("e1"); //~  WARN value captured by `b` is never read
   |             ^
   |
   = help: did you mean to capture by reference instead?

warning: value assigned to `b` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:78:13
   |
LL |             b = Some("e1"); //~  WARN value captured by `b` is never read
   |             ^^^^^^^^^^^^^^ this value is reassigned later and never used
LL |                             //~| WARN value assigned to `b` is never read
LL |             b = Some("e2"); //~  WARN value assigned to `b` is never read
   |             -------------- `b` is overwritten here before the previous value is read

warning: value assigned to `b` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:80:13
   |
LL |             b = Some("e2"); //~  WARN value assigned to `b` is never read
   |             ^^^^^^^^^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `d.x` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:69:13
   |
LL |             d.x = Some("d1"); //~ WARN value assigned to `d.x` is never read
   |             ^^^^^^^^^^^^^^^^ this value is reassigned later and never used
LL |             d.x = Some("d2");
   |             ---------------- `d.x` is overwritten here before the previous value is read

warning: value assigned to `a` is never read
##[warning]  --> /checkout/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs:71:13
   |
LL |             a = Some("d1"); //~ WARN value assigned to `a` is never read
   |             ^^^^^^^^^^^^^^ this value is reassigned later and never used
LL |             a = Some("d2");
   |             -------------- `a` is overwritten here before the previous value is read

warning: 16 warnings emitted
------------------------------------------

---- [ui] tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs stdout end ----
---- [ui] tests/ui/lint/unused/unused-assign-148960.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/lint/unused/unused-assign-148960/unused-assign-148960.stderr`
diff of stderr:

1 error: value assigned to `value` is never read
-   --> $DIR/unused-assign-148960.rs:6:21
+   --> $DIR/unused-assign-148960.rs:7:21
3    |
4 LL |     let mut value = b"0".to_vec();
5    |                     ^^^^^^^^^^^^^ this value is reassigned later and never used

7    |     ----- `value` is overwritten here before the previous value is read
8    |
9 note: the lint level is defined here
---
32 error: value assigned to `p` is never read
-   --> $DIR/unused-assign-148960.rs:24:17
+   --> $DIR/unused-assign-148960.rs:25:17
34    |
35 LL |     let mut p = Point { x: 1, y: 1 };
36    |                 ^^^^^^^^^^^^^^^^^^^^ this value is reassigned later and never used

38    |     ------------------------ `p` is overwritten here before the previous value is read
39 
40 error: variable `foo` is assigned to, but never used
---
To only update this specific test, also pass `--test-args lint/unused/unused-assign-148960.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/lint/unused/unused-assign-148960.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/lint/unused/unused-assign-148960" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: value assigned to `value` is never read
##[error]  --> /checkout/tests/ui/lint/unused/unused-assign-148960.rs:7:21
   |
LL |     let mut value = b"0".to_vec(); //~ ERROR value assigned to `value` is never read
   |                     ^^^^^^^^^^^^^ this value is reassigned later and never used
LL |     value = b"1".to_vec();
   |     ----- `value` is overwritten here before the previous value is read
   |
note: the lint level is defined here
  --> /checkout/tests/ui/lint/unused/unused-assign-148960.rs:3:9
   |
LL | #![deny(unused)]
---

error: value assigned to `p` is never read
##[error]  --> /checkout/tests/ui/lint/unused/unused-assign-148960.rs:25:17
   |
LL |     let mut p = Point { x: 1, y: 1 }; //~ ERROR value assigned to `p` is never read
   |                 ^^^^^^^^^^^^^^^^^^^^ this value is reassigned later and never used
LL |     p = Point { x: 2, y: 2 };
   |     ------------------------ `p` is overwritten here before the previous value is read

error: variable `foo` is assigned to, but never used
##[error]  --> /checkout/tests/ui/lint/unused/unused-assign-148960.rs:39:9
   |
LL |     let mut foo = Foo; //~ ERROR variable `foo` is assigned to, but never used
   |         ^^^^^^^
   |
   = note: consider using `_foo` instead
   = note: `#[deny(unused_variables)]` implied by `#[deny(unused)]`
help: you might have meant to pattern match on the similarly named struct `Foo`
   |
LL -     let mut foo = Foo; //~ ERROR variable `foo` is assigned to, but never used
LL +     let Foo = Foo; //~ ERROR variable `foo` is assigned to, but never used
   |

error: value assigned to `foo` is never read
##[error]  --> /checkout/tests/ui/lint/unused/unused-assign-148960.rs:40:5
   |
---
14 warning: unused variable: `s`
-   --> $DIR/liveness-consts.rs:35:24
+   --> $DIR/liveness-consts.rs:36:24
16    |
17 LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8;  { let z = 18; 100 }] {
18    |                        ^ help: if this is intentional, prefix it with an underscore: `_s`

19 
20 warning: unused variable: `z`
-   --> $DIR/liveness-consts.rs:35:55
+   --> $DIR/liveness-consts.rs:36:55
22    |
23 LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8;  { let z = 18; 100 }] {
24    |                                                       ^ help: if this is intentional, prefix it with an underscore: `_z`

25 
26 warning: variable `a` is assigned to, but never used
-   --> $DIR/liveness-consts.rs:7:9
+   --> $DIR/liveness-consts.rs:8:9
---
65 warning: value assigned to `t` is never read
-   --> $DIR/liveness-consts.rs:44:9
+   --> $DIR/liveness-consts.rs:45:9
67    |
68 LL |         t = t + t;
69    |         ^^^^^^^^^

71    = help: maybe it is overwritten before being read?
72 
73 warning: unused variable: `w`
---
To only update this specific test, also pass `--test-args liveness/liveness-consts.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/liveness/liveness-consts.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/liveness/liveness-consts" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
warning: unused variable: `e`
##[warning]  --> /checkout/tests/ui/liveness/liveness-consts.rs:27:13
   |
LL |         let e = 1; //~ WARN unused variable: `e`
   |             ^ help: if this is intentional, prefix it with an underscore: `_e`
   |
note: the lint level is defined here
  --> /checkout/tests/ui/liveness/liveness-consts.rs:3:9
   |
LL | #![warn(unused)]
   |         ^^^^^^
   = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`

warning: unused variable: `s`
##[warning]  --> /checkout/tests/ui/liveness/liveness-consts.rs:36:24
   |
LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8;  { let z = 18; 100 }] {
   |                        ^ help: if this is intentional, prefix it with an underscore: `_s`

warning: unused variable: `z`
##[warning]  --> /checkout/tests/ui/liveness/liveness-consts.rs:36:55
   |
LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8;  { let z = 18; 100 }] {
   |                                                       ^ help: if this is intentional, prefix it with an underscore: `_z`

warning: variable `a` is assigned to, but never used
##[warning]  --> /checkout/tests/ui/liveness/liveness-consts.rs:8:9
   |
LL |     let mut a = 0;
---

warning: value assigned to `b` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-consts.rs:19:17
   |
LL |     let mut b = 1; //~ WARN value assigned to `b` is never read
   |                 ^ this value is reassigned later and never used
LL |     b += 1; //~ WARN value assigned to `b` is never read
   |     ------ `b` is overwritten here before the previous value is read

warning: value assigned to `b` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-consts.rs:20:5
   |
LL |     b += 1; //~ WARN value assigned to `b` is never read
   |     ^^^^^^ this value is reassigned later and never used
LL |     b = 42;
   |     ------ `b` is overwritten here before the previous value is read

warning: unused variable: `z`
##[warning]  --> /checkout/tests/ui/liveness/liveness-consts.rs:63:13
   |
LL |         let z = 42; //~ WARN unused variable: `z`
   |             ^ help: if this is intentional, prefix it with an underscore: `_z`

warning: value assigned to `t` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-consts.rs:45:9
   |
LL |         t = t + t; //~ WARN value assigned to `t` is never read
   |         ^^^^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: unused variable: `w`
##[warning]  --> /checkout/tests/ui/liveness/liveness-consts.rs:52:13
   |
LL |         let w = 10; //~ WARN unused variable: `w`
   |             ^ help: if this is intentional, prefix it with an underscore: `_w`

warning: 10 warnings emitted
------------------------------------------

---- [ui] tests/ui/liveness/liveness-consts.rs stdout end ----
---
144 warning: value captured by `z` is never read
-   --> $DIR/liveness-upvars.rs:105:17
+   --> $DIR/liveness-upvars.rs:106:17
146    |
147 LL |                 z = T::default();
148    |                 ^

150    = help: did you mean to capture by reference instead?
151 
152 warning: value assigned to `z` is never read
-   --> $DIR/liveness-upvars.rs:105:17
+   --> $DIR/liveness-upvars.rs:106:17
154    |
155 LL |                 z = T::default();
156    |                 ^^^^^^^^^^^^^^^^

158    = help: maybe it is overwritten before being read?
159 
160 warning: unused variable: `z`
-   --> $DIR/liveness-upvars.rs:101:9
+   --> $DIR/liveness-upvars.rs:102:9
162    |
163 LL |     let mut z = T::default();
164    |         ^^^^^ help: if this is intentional, prefix it with an underscore: `_z`

166    = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
167 
168 warning: value captured by `state` is never read
-   --> $DIR/liveness-upvars.rs:131:9
---
To only update this specific test, also pass `--test-args liveness/liveness-upvars.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/liveness/liveness-upvars.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/liveness/liveness-upvars" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
stdout: none
--- stderr -------------------------------
warning: value captured by `last` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:11:9
   |
LL |         last = Some(s); //~  WARN value captured by `last` is never read
   |         ^^^^
   |
   = help: did you mean to capture by reference instead?
note: the lint level is defined here
  --> /checkout/tests/ui/liveness/liveness-upvars.rs:5:9
---

warning: value assigned to `last` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:11:9
   |
LL |         last = Some(s); //~  WARN value captured by `last` is never read
   |         ^^^^^^^^^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value captured by `sum` is never read
---

warning: value assigned to `c` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:70:9
   |
LL |         c += 1; //~  WARN value assigned to `c` is never read
   |         ^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `c` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:64:9
   |
LL |         c += 1; //~  WARN value assigned to `c` is never read
   |         ^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value captured by `c` is never read
---

warning: value captured by `c` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:39:9
   |
LL |         c = 1; //~ WARN value captured by `c` is never read
   |         ^
   |
   = help: did you mean to capture by reference instead?

warning: value captured by `c` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:35:9
   |
LL |         c = 1; //~ WARN value captured by `c` is never read
   |         ^
   |
   = help: did you mean to capture by reference instead?

warning: value captured by `e` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:83:13
   |
LL |             e = Some("e1"); //~  WARN value captured by `e` is never read
   |             ^
   |
   = help: did you mean to capture by reference instead?

warning: value assigned to `e` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:83:13
   |
LL |             e = Some("e1"); //~  WARN value captured by `e` is never read
   |             ^^^^^^^^^^^^^^ this value is reassigned later and never used
LL |                             //~| WARN value assigned to `e` is never read
LL |             e = Some("e2"); //~  WARN value assigned to `e` is never read
   |             -------------- `e` is overwritten here before the previous value is read

warning: value assigned to `e` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:85:13
   |
LL |             e = Some("e2"); //~  WARN value assigned to `e` is never read
   |             ^^^^^^^^^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `d` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:79:13
   |
LL |             d = Some("d1"); //~ WARN value assigned to `d` is never read
   |             ^^^^^^^^^^^^^^ this value is reassigned later and never used
LL |             d = Some("d2");
   |             -------------- `d` is overwritten here before the previous value is read

warning: value assigned to `v` is never read
---

warning: value captured by `z` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:106:17
   |
LL |                 z = T::default(); //~  WARN value captured by `z` is never read
   |                 ^
   |
   = help: did you mean to capture by reference instead?

warning: value assigned to `z` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:106:17
   |
LL |                 z = T::default(); //~  WARN value captured by `z` is never read
   |                 ^^^^^^^^^^^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: unused variable: `z`
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:102:9
   |
LL |     let mut z = T::default(); //~ WARN unused variable: `z`
   |         ^^^^^ help: if this is intentional, prefix it with an underscore: `_z`
   |
   = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`

warning: value captured by `state` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:132:9
---

warning: value assigned to `s` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:144:9
   |
LL |         s = 1; //~ WARN value assigned to `s` is never read
   |         ^^^^^ this value is reassigned later and never used
LL |         yield (s = 2);
   |               ------- `s` is overwritten here before the previous value is read

warning: value assigned to `s` is never read
##[warning]  --> /checkout/tests/ui/liveness/liveness-upvars.rs:146:9
   |
LL |         s = yield (); //~ WARN value assigned to `s` is never read
   |         ^^^^^^^^^^^^ this value is reassigned later and never used
LL |         s = 3;
   |         ----- `s` is overwritten here before the previous value is read

warning: 25 warnings emitted

@Zoxc Zoxc mentioned this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants