Skip to content

Conversation

@Daniel-B-Smith
Copy link

@Daniel-B-Smith Daniel-B-Smith commented Jan 6, 2026

When a trait parameter depends upon Sized, the error message only referred to the full trait itself and didn't mention Sized. This makes the failure to implement Sized explicit. It also notes when the Sized trait bound is explicit or implicit.

Fixes #150576

@rustbot rustbot added 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 Jan 6, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 6, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
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

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

When a trait parameter depends upon Sized, the error message only
referred to the full trait itself and didn't mention Sized. This makes
the failure to implement Sized explicit. It also notes when the Sized
trait bound is explicit or implicit.
@rustbot
Copy link
Collaborator

rustbot commented Jan 7, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot
Copy link
Collaborator

rustbot commented Jan 7, 2026

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/rust.git main
    $ git push --force-with-lease
    

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 7, 2026
@Daniel-B-Smith
Copy link
Author

Reverting to draft while I fix the tests. My apologies for the noise.

@Daniel-B-Smith Daniel-B-Smith marked this pull request as draft January 7, 2026 16:33
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 7, 2026
@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
diff of stderr:

17   --> $DIR/slice-issue-87994.rs:3:12
18    |
19 LL |   for _ in v[1..] {
-    |            ^^^^^^ the trait `IntoIterator` is not implemented for `[i32]`
+    |            ^^^^^^ the trait `Sized` is not implemented for `[i32]`
21    |
22    = note: the trait bound `[i32]: IntoIterator` is not satisfied
23    = note: required for `[i32]` to implement `IntoIterator`

-    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
25 help: consider borrowing here
26    |
27 LL |   for _ in &v[1..] {

48   --> $DIR/slice-issue-87994.rs:11:13
49    |
50 LL |   for i2 in v2[1..] {
-    |             ^^^^^^^ the trait `IntoIterator` is not implemented for `[K]`
+    |             ^^^^^^^ the trait `Sized` is not implemented for `[K]`
52    |
53    = note: the trait bound `[K]: IntoIterator` is not satisfied
54    = note: required for `[K]` to implement `IntoIterator`

-    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
56 help: consider borrowing here
57    |
58 LL |   for i2 in &v2[1..] {


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args suggestions/slice-issue-87994.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/suggestions/slice-issue-87994.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/suggestions/slice-issue-87994" "-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[E0277]: `[i32]` is not an iterator
##[error]  --> /checkout/tests/ui/suggestions/slice-issue-87994.rs:3:12
   |
LL |   for _ in v[1..] {
   |            ^^^^^^ the trait `IntoIterator` is not implemented for `[i32]`
   |
   = note: the trait bound `[i32]: IntoIterator` is not satisfied
   = note: required for `[i32]` to implement `IntoIterator`
help: consider borrowing here
   |
LL |   for _ in &v[1..] {
   |            +
LL |   for _ in &mut v[1..] {
   |            ++++

error[E0277]: `[i32]` is not an iterator
##[error]  --> /checkout/tests/ui/suggestions/slice-issue-87994.rs:3:12
   |
LL |   for _ in v[1..] {
   |            ^^^^^^ the trait `Sized` is not implemented for `[i32]`
   |
   = note: the trait bound `[i32]: IntoIterator` is not satisfied
   = note: required for `[i32]` to implement `IntoIterator`
help: consider borrowing here
   |
LL |   for _ in &v[1..] {
   |            +
LL |   for _ in &mut v[1..] {
   |            ++++

error[E0277]: `[K]` is not an iterator
##[error]  --> /checkout/tests/ui/suggestions/slice-issue-87994.rs:11:13
   |
LL |   for i2 in v2[1..] {
   |             ^^^^^^^ the trait `IntoIterator` is not implemented for `[K]`
   |
   = note: the trait bound `[K]: IntoIterator` is not satisfied
   = note: required for `[K]` to implement `IntoIterator`
help: consider borrowing here
   |
LL |   for i2 in &v2[1..] {
   |             +
LL |   for i2 in &mut v2[1..] {
   |             ++++

error[E0277]: `[K]` is not an iterator
##[error]  --> /checkout/tests/ui/suggestions/slice-issue-87994.rs:11:13
   |
LL |   for i2 in v2[1..] {
   |             ^^^^^^^ the trait `Sized` is not implemented for `[K]`
   |
   = note: the trait bound `[K]: IntoIterator` is not satisfied
   = note: required for `[K]` to implement `IntoIterator`
help: consider borrowing here
   |
LL |   for i2 in &v2[1..] {
   |             +
LL |   for i2 in &mut v2[1..] {
   |             ++++

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0277`.
---
To only update this specific test, also pass `--test-args traits/dyn-iterator-deref-in-for-loop.rs`

error in revision `current`: 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/traits/dyn-iterator-deref-in-for-loop.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" "--cfg" "current" "--check-cfg" "cfg(test,FALSE,current,next)" "--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/traits/dyn-iterator-deref-in-for-loop.current" "-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[E0277]: `dyn Iterator<Item = &'a mut u8>` is not an iterator
##[error]  --> /checkout/tests/ui/traits/dyn-iterator-deref-in-for-loop.rs:9:17
   |
---
------------------------------------------

---- [ui] tests/ui/traits/dyn-iterator-deref-in-for-loop.rs#current stdout end ----
---- [ui] tests/ui/traits/dyn-iterator-deref-in-for-loop.rs#next stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/traits/dyn-iterator-deref-in-for-loop.next/dyn-iterator-deref-in-for-loop.next.stderr`
diff of stderr:

2   --> $DIR/dyn-iterator-deref-in-for-loop.rs:9:17
3    |
4 LL |     for item in *things {
---
To only update this specific test, also pass `--test-args traits/dyn-iterator-deref-in-for-loop.rs`

error in revision `next`: 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/traits/dyn-iterator-deref-in-for-loop.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" "--cfg" "next" "--check-cfg" "cfg(test,FALSE,current,next)" "--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/traits/dyn-iterator-deref-in-for-loop.next" "-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" "-Znext-solver"
stdout: none
--- stderr -------------------------------
error[E0277]: `dyn Iterator<Item = &'a mut u8>` is not an iterator
##[error]  --> /checkout/tests/ui/traits/dyn-iterator-deref-in-for-loop.rs:9:17
   |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

Unsatisfied implicit trait bound is not made explicit in E0277

4 participants