Skip to content

Rollup of 3 pull requests#154030

Closed
Zalathar wants to merge 6 commits intorust-lang:mainfrom
Zalathar:rollup-STlnAhI
Closed

Rollup of 3 pull requests#154030
Zalathar wants to merge 6 commits intorust-lang:mainfrom
Zalathar:rollup-STlnAhI

Conversation

@Zalathar
Copy link
Member

Successful merges:

r? @ghost

Create a similar rollup

estebank and others added 6 commits March 16, 2026 18:43
When encountering an inference error where a return type must be known, like when calling `Iterator::sum::<T>()` without specifying `T`, look for all `T` that would satisfy `Sum<S>`. If only one, suggest it.

```
error[E0283]: type annotations needed
  --> $DIR/cannot-infer-iterator-sum-return-type.rs:4:9
   |
LL |     let sum = v
   |         ^^^
...
LL |         .sum(); // `sum::<T>` needs `T` to be specified
   |          --- type must be known at this point
   |
   = note: cannot satisfy `_: Sum<i32>`
help: the trait `Sum` is implemented for `i32`
  --> $SRC_DIR/core/src/iter/traits/accum.rs:LL:COL
  ::: $SRC_DIR/core/src/iter/traits/accum.rs:LL:COL
   |
   = note: in this macro invocation
note: required by a bound in `std::iter::Iterator::sum`
  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
   = note: this error originates in the macro `integer_sum_product` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider giving `sum` an explicit type, where the type for type parameter `S` is specified
   |
LL |     let sum: i32 = v
   |            +++++
```
Code that previously used `QueryStackFrame` now uses `TaggedQueryKey` directly.

Code that previously used `Spanned<QueryStackFrame>` now uses
`QueryStackFrame`, which includes a span.
These types have been unused since polymorphization was removed in
<rust-lang#133883>.
When single impl can satisfy inference error, suggest type

When encountering an inference error where a return type must be known, like when calling `Iterator::sum::<T>()` without specifying `T`, look for all `T` that would satisfy `Sum<S>`. If only one, suggest it.

```
error[E0283]: type annotations needed
  --> $DIR/cannot-infer-iterator-sum-return-type.rs:4:9
   |
LL |     let sum = v
   |         ^^^
...
LL |         .sum(); // `sum::<T>` needs `T` to be specified
   |          --- type must be known at this point
   |
   = note: cannot satisfy `_: Sum<i32>`
help: the trait `Sum` is implemented for `i32`
  --> $SRC_DIR/core/src/iter/traits/accum.rs:LL:COL
  ::: $SRC_DIR/core/src/iter/traits/accum.rs:LL:COL
   |
   = note: in this macro invocation
note: required by a bound in `std::iter::Iterator::sum`
  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
   = note: this error originates in the macro `integer_sum_product` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider giving `sum` an explicit type, where the type for type parameter `S` is specified
   |
LL |     let sum: i32 = v
   |            +++++
```

Fix rust-lang#100802.
Move query-stack-frame spans into `QueryStackFrame`

- Follow-up to rust-lang#153907 (comment).
---

Code that previously used `QueryStackFrame` now uses `TaggedQueryKey` directly.

Code that previously used `Spanned<QueryStackFrame>` now uses `QueryStackFrame`, which includes a span.

This ends up bringing QueryStackFrame closer to the expectations of the code that actually consumes query cycles, and also avoids the awkward and misleading `respan` calls and `node` field accesses that had been required by `Spanned`.

r? nnethercote
Remove unused types `UnusedGenericParams` and `FiniteBitSet`

- These types have been unused since polymorphization was removed in <rust-lang#133883>.
@rust-bors rust-bors bot added the rollup A PR which is a rollup label Mar 18, 2026
@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 Mar 18, 2026
@Zalathar
Copy link
Member Author

Rollup of everything.

@bors r+ rollup=never p=5

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 18, 2026

📌 Commit 5825bed has been approved by Zalathar

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Mar 18, 2026
@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 18, 2026
Rollup of 3 pull requests

Successful merges:

 - #153727 (When single impl can satisfy inference error, suggest type)
 - #153998 (Move query-stack-frame spans into `QueryStackFrame`)
 - #154026 (Remove unused types `UnusedGenericParams` and `FiniteBitSet`)
@rust-bors rust-bors bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 18, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 18, 2026

💔 Test for 8698863 failed: CI. Failed job:

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] tests/ui/inference/cannot-infer-iterator-sum-return-type.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/inference/cannot-infer-iterator-sum-return-type/cannot-infer-iterator-sum-return-type.stderr`
diff of stderr:

7 LL |         .sum(); // `sum::<T>` needs `T` to be specified
8    |          --- type must be known at this point
9    |
-    = note: cannot satisfy `_: Sum<i32>`
+    = note: the type must implement `Sum<i32>`
11 help: the trait `Sum` is implemented for `i32`
12   --> $SRC_DIR/core/src/iter/traits/accum.rs:LL:COL
---
To only update this specific test, also pass `--test-args inference/cannot-infer-iterator-sum-return-type.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/x86_64-unknown-linux-gnu/stage1/bin/rustc" "/checkout/tests/ui/inference/cannot-infer-iterator-sum-return-type.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/x86_64-unknown-linux-gnu/stage1" "--target=x86_64-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/x86_64-unknown-linux-gnu/test/ui/inference/cannot-infer-iterator-sum-return-type" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0283]: type annotations needed
##[error]  --> /checkout/tests/ui/inference/cannot-infer-iterator-sum-return-type.rs:4:9
   |
LL |     let sum = v //~ ERROR: type annotations needed
   |         ^^^
...
LL |         .sum(); // `sum::<T>` needs `T` to be specified
   |          --- type must be known at this point
   |
   = note: the type must implement `Sum<i32>`
help: the trait `Sum` is implemented for `i32`
  --> /rustc/FAKE_PREFIX/library/core/src/iter/traits/accum.rs:48:8
  ::: /rustc/FAKE_PREFIX/library/core/src/iter/traits/accum.rs:204:0
   |
   = note: in this macro invocation
note: required by a bound in `std::iter::Iterator::sum`
  --> /rustc/FAKE_PREFIX/library/core/src/iter/traits/iterator.rs:3669:4
   = note: this error originates in the macro `integer_sum_product` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider giving `sum` an explicit type, where the type for type parameter `S` is specified
   |
LL |     let sum: i32 = v //~ ERROR: type annotations needed
   |            +++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0283`.

@rust-bors rust-bors bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 18, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 18, 2026

PR #153727, which is a member of this rollup, was unapproved.

@Zalathar Zalathar closed this Mar 18, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 18, 2026
@Zalathar Zalathar deleted the rollup-STlnAhI branch March 18, 2026 04:09
@rust-log-analyzer
Copy link
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)
##[endgroup]
Executing "/scripts/stage_2_test_set1.sh"
+ /scripts/stage_2_test_set1.sh
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip compiler --skip src
PR_CI_JOB set; skipping tidy
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
---
---- [ui] tests/ui/inference/cannot-infer-iterator-sum-return-type.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/inference/cannot-infer-iterator-sum-return-type/cannot-infer-iterator-sum-return-type.stderr`
diff of stderr:

7 LL |         .sum(); // `sum::<T>` needs `T` to be specified
8    |          --- type must be known at this point
9    |
-    = note: cannot satisfy `_: Sum<i32>`
+    = note: the type must implement `Sum<i32>`
11 help: the trait `Sum` is implemented for `i32`
12   --> $SRC_DIR/core/src/iter/traits/accum.rs:LL:COL
---
To only update this specific test, also pass `--test-args inference/cannot-infer-iterator-sum-return-type.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/inference/cannot-infer-iterator-sum-return-type.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/inference/cannot-infer-iterator-sum-return-type" "-A" "unused" "-W" "unused_attributes" "-A" "internal_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[E0283]: type annotations needed
##[error]  --> /checkout/tests/ui/inference/cannot-infer-iterator-sum-return-type.rs:4:9
   |
LL |     let sum = v //~ ERROR: type annotations needed
   |         ^^^
...
LL |         .sum(); // `sum::<T>` needs `T` to be specified
   |          --- type must be known at this point
   |
   = note: the type must implement `Sum<i32>`
help: the trait `Sum` is implemented for `i32`
  --> /rustc/FAKE_PREFIX/library/core/src/iter/traits/accum.rs:48:8
  ::: /rustc/FAKE_PREFIX/library/core/src/iter/traits/accum.rs:204:0
   |
   = note: in this macro invocation
note: required by a bound in `std::iter::Iterator::sum`
  --> /rustc/FAKE_PREFIX/library/core/src/iter/traits/iterator.rs:3669:4
   = note: this error originates in the macro `integer_sum_product` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider giving `sum` an explicit type, where the type for type parameter `S` is specified
   |
LL |     let sum: i32 = v //~ ERROR: type annotations needed
   |            +++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0283`.

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) rollup A PR which is a rollup 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.

4 participants