Skip to content

Better handle when trying to iterate on a Range of a type that isn't Step#151036

Merged
rust-bors[bot] merged 7 commits intorust-lang:mainfrom
estebank:issue-151026
Jan 14, 2026
Merged

Better handle when trying to iterate on a Range of a type that isn't Step#151036
rust-bors[bot] merged 7 commits intorust-lang:mainfrom
estebank:issue-151026

Conversation

@estebank
Copy link
Contributor

@estebank estebank commented Jan 12, 2026

Mention when a trait bound corresponds to an unstable trait.

Mention Range when Step bound is unment, and explain that only some std types impl Iterator for Range.

CC #151026

@rustbot
Copy link
Collaborator

rustbot commented Jan 12, 2026

r? @mati865

rustbot has assigned @mati865.
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 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jan 12, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 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.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jan 13, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@mati865 mati865 left a comment

Choose a reason for hiding this comment

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

r=me with tests blessed

View changes since this review

Comment on lines 1 to 9
error[E0277]: `std::ops::Range<T>` is not an iterator
--> missing-bound.rs:2:14
|
2 | for _ in t {}
| ^ the trait `Step` is not implemented for `T`
| ^ not an iterator
|
= note: `Range` only implements `Iterator` for select types in the standard library, particularly integers; to see the full list of types, see the documentation for the unstable `Step` trait
= note: required for `std::ops::Range<T>` to implement `Iterator`
= note: required for `std::ops::Range<T>` to implement `IntoIterator`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This tells me that we're missing a path for displaying the original label as a note, like we do in many other cases. Pre-existing.

| ^^^^^^^^^^^ the trait `Step` is not implemented for `bool`
| ^^^^^^^^^^^ not an iterator
|
= help: the nightly-only, unstable trait `Step` is not implemented for `bool`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the note that I would have expected to see in the other case.

@rust-log-analyzer

This comment has been minimized.

@estebank
Copy link
Contributor Author

@bors r=mati865

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 14, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 14, 2026

📌 Commit 1fe705c has been approved by mati865

It is now in the queue for this repository.

@rust-bors rust-bors bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 14, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 14, 2026
Better handle when trying to iterate on a `Range` of a type that isn't `Step`

Mention when a trait bound corresponds to an unstable trait.

Mention `Range` when `Step` bound is unment, and explain that only some std types impl `Iterator` for `Range`.

CC rust-lang#151026
rust-bors bot pushed a commit that referenced this pull request Jan 14, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #149408 (refactor: remove Ord bound from BinaryHeap::new etc)
 - #150406 (Change some `matches!(.., .. if ..)` with let-chains)
 - #150723 (std: move `errno` and related functions into `sys::io`)
 - #150877 (resolve: Refactor away the side table `decl_parent_modules`)
 - #150902 (Update to_uppercase docs to avoid ß->SS example)
 - #150962 (Remove `FeedConstTy` and provide ty when lowering const arg)
 - #151034 (std: Change UEFI env vars to volatile storage)
 - #151036 (Better handle when trying to iterate on a `Range` of a type that isn't `Step`)
 - #151067 (Avoid should-fail in two ui tests and a codegen-llvm test)
 - #151072 (also handle ENOTTY ioctl errors when checking pidfd -> pid support)
 - #151077 (Recognize potential `impl<const N: usize>` to `impl<N>` mistake)
 - #151096 (Remove `Deref`/`DerefMut` impl for `Providers`.)

Failed merges:

 - #150939 (resolve: Relax some asserts in glob overwriting and add tests)

r? @ghost
rust-bors bot pushed a commit that referenced this pull request Jan 14, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #149408 (refactor: remove Ord bound from BinaryHeap::new etc)
 - #150406 (Change some `matches!(.., .. if ..)` with let-chains)
 - #150723 (std: move `errno` and related functions into `sys::io`)
 - #150877 (resolve: Refactor away the side table `decl_parent_modules`)
 - #150902 (Update to_uppercase docs to avoid ß->SS example)
 - #151034 (std: Change UEFI env vars to volatile storage)
 - #151036 (Better handle when trying to iterate on a `Range` of a type that isn't `Step`)
 - #151067 (Avoid should-fail in two ui tests and a codegen-llvm test)
 - #151072 (also handle ENOTTY ioctl errors when checking pidfd -> pid support)
 - #151077 (Recognize potential `impl<const N: usize>` to `impl<N>` mistake)
 - #151096 (Remove `Deref`/`DerefMut` impl for `Providers`.)

Failed merges:

 - #150939 (resolve: Relax some asserts in glob overwriting and add tests)

r? @ghost
@rust-bors rust-bors bot merged commit cbcd1c3 into rust-lang:main Jan 14, 2026
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 14, 2026
rust-timer added a commit that referenced this pull request Jan 14, 2026
Rollup merge of #151036 - issue-151026, r=mati865

Better handle when trying to iterate on a `Range` of a type that isn't `Step`

Mention when a trait bound corresponds to an unstable trait.

Mention `Range` when `Step` bound is unment, and explain that only some std types impl `Iterator` for `Range`.

CC #151026
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 15, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#149408 (refactor: remove Ord bound from BinaryHeap::new etc)
 - rust-lang/rust#150406 (Change some `matches!(.., .. if ..)` with let-chains)
 - rust-lang/rust#150723 (std: move `errno` and related functions into `sys::io`)
 - rust-lang/rust#150877 (resolve: Refactor away the side table `decl_parent_modules`)
 - rust-lang/rust#150902 (Update to_uppercase docs to avoid ß->SS example)
 - rust-lang/rust#151034 (std: Change UEFI env vars to volatile storage)
 - rust-lang/rust#151036 (Better handle when trying to iterate on a `Range` of a type that isn't `Step`)
 - rust-lang/rust#151067 (Avoid should-fail in two ui tests and a codegen-llvm test)
 - rust-lang/rust#151072 (also handle ENOTTY ioctl errors when checking pidfd -> pid support)
 - rust-lang/rust#151077 (Recognize potential `impl<const N: usize>` to `impl<N>` mistake)
 - rust-lang/rust#151096 (Remove `Deref`/`DerefMut` impl for `Providers`.)

Failed merges:

 - rust-lang/rust#150939 (resolve: Relax some asserts in glob overwriting and add tests)

r? @ghost
@Zalathar
Copy link
Member

I noticed that this PR has the side-effect of causing all compiler-internal traits to be reported as unstable, which is technically true but unhelpful when working on the compiler itself:

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 16, 2026
Suppress unstable-trait notes under `-Zforce-unstable-if-unmarked`

- Fixes rust-lang#152692.
---

rust-lang#151036 adds extra diagnostic text (“the nightly-only, unstable trait”) to note when a not-implemented trait is unstable.

However, that extra text is usually unhelpful when building a crate graph with `-Zforce-unstable-if-unmarked` (such as the compiler or stdlib), because *any* trait not explicitly marked stable will be treated as unstable.

(For typical compiler contributors using the stage0 compiler, this fix won't take effect until the next bootstrap beta bump.)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 16, 2026
Suppress unstable-trait notes under `-Zforce-unstable-if-unmarked`

- Fixes rust-lang#152692.
---

rust-lang#151036 adds extra diagnostic text (“the nightly-only, unstable trait”) to note when a not-implemented trait is unstable.

However, that extra text is usually unhelpful when building a crate graph with `-Zforce-unstable-if-unmarked` (such as the compiler or stdlib), because *any* trait not explicitly marked stable will be treated as unstable.

(For typical compiler contributors using the stage0 compiler, this fix won't take effect until the next bootstrap beta bump.)
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 17, 2026
Suppress unstable-trait notes under `-Zforce-unstable-if-unmarked`

- Fixes rust-lang#152692.
---

rust-lang#151036 adds extra diagnostic text (“the nightly-only, unstable trait”) to note when a not-implemented trait is unstable.

However, that extra text is usually unhelpful when building a crate graph with `-Zforce-unstable-if-unmarked` (such as the compiler or stdlib), because *any* trait not explicitly marked stable will be treated as unstable.

(For typical compiler contributors using the stage0 compiler, this fix won't take effect until the next bootstrap beta bump.)
rust-timer added a commit that referenced this pull request Feb 17, 2026
Rollup merge of #152698 - Zalathar:zforce, r=jieyouxu

Suppress unstable-trait notes under `-Zforce-unstable-if-unmarked`

- Fixes #152692.
---

#151036 adds extra diagnostic text (“the nightly-only, unstable trait”) to note when a not-implemented trait is unstable.

However, that extra text is usually unhelpful when building a crate graph with `-Zforce-unstable-if-unmarked` (such as the compiler or stdlib), because *any* trait not explicitly marked stable will be treated as unstable.

(For typical compiler contributors using the stage0 compiler, this fix won't take effect until the next bootstrap beta bump.)
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Feb 18, 2026
Suppress unstable-trait notes under `-Zforce-unstable-if-unmarked`

- Fixes rust-lang/rust#152692.
---

rust-lang/rust#151036 adds extra diagnostic text (“the nightly-only, unstable trait”) to note when a not-implemented trait is unstable.

However, that extra text is usually unhelpful when building a crate graph with `-Zforce-unstable-if-unmarked` (such as the compiler or stdlib), because *any* trait not explicitly marked stable will be treated as unstable.

(For typical compiler contributors using the stage0 compiler, this fix won't take effect until the next bootstrap beta bump.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments