Skip to content

de-non_const Iterator trait methods#153708

Open
Lars-Schumann wants to merge 1 commit intorust-lang:mainfrom
Lars-Schumann:de-non_const-iterator-trait-methods
Open

de-non_const Iterator trait methods#153708
Lars-Schumann wants to merge 1 commit intorust-lang:mainfrom
Lars-Schumann:de-non_const-iterator-trait-methods

Conversation

@Lars-Schumann
Copy link

#92476

constifying Iterators methods that don't immediately or transitively need const closures or ugly hacks.

@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. labels Mar 11, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 11, 2026

r? @scottmcm

rustbot has assigned @scottmcm.
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: @scottmcm, libs
  • @scottmcm, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, scottmcm

@Lars-Schumann Lars-Schumann changed the title de-non_const Iterator trait methods de-non_const Iterator trait methods Mar 11, 2026
@Lars-Schumann Lars-Schumann force-pushed the de-non_const-iterator-trait-methods branch from 5e438b4 to 2960e3a Compare March 11, 2026 13:22
@oli-obk oli-obk assigned oli-obk and fee1-dead and unassigned scottmcm Mar 11, 2026
{
default fn spec_advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
for i in 0..n {
// FIXME(const-hack): this should be `for i in 0..n`
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should figure that one out first 😅

Copy link
Author

@Lars-Schumann Lars-Schumann Mar 12, 2026

Choose a reason for hiding this comment

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

As far as const-hacks go, this is very tame, and I didn't want to make this pr too big by constifying the Range Iterator impl as well (if that's even possible right now)

Copy link
Contributor

Choose a reason for hiding this comment

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

yea, def don't do range iterators this in this one, I was wondering if we'd just delay on touching this one. But it is tame, and I do worry that by not doing progress here we end up in a deadlock somewhere with other iterator constifications.

@oli-obk
Copy link
Contributor

oli-obk commented Mar 12, 2026

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 12, 2026

📌 Commit 2960e3a has been approved by oli-obk

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 12, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Mar 12, 2026
…r-trait-methods, r=oli-obk

de-non_const `Iterator` trait methods

rust-lang#92476

constifying Iterators methods that don't immediately or transitively need const closures or ugly hacks.
rust-bors bot pushed a commit that referenced this pull request Mar 12, 2026
Rollup of 11 pull requests

Successful merges:

 - #153726 (Add optional CI job to build the compiler with the parallel frontend)
 - #153763 (Don't add empty target features for target-cpu=native on macOS)
 - #153432 (Fix some comments about dataflow analysis.)
 - #153529 (Fix LegacyKeyValueFormat report from docker build: pr)
 - #153694 (fix(query): Pass Query Key to `value_from_cycle_error`)
 - #153708 (de-non_const `Iterator` trait methods)
 - #153717 (unused_macro_rules switched used and unused comments)
 - #153736 (add test that an incomplete feature emits a warning)
 - #153748 (editorconfig: css uses tabs)
 - #153750 (rustc-dev-guide subtree update)
 - #153762 (actually make the is-fn test test what it says it tests)
@Zalathar
Copy link
Member

@bors try jobs=x86_64-rust-for-linux

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 12, 2026
…hods, r=<try>

de-non_const `Iterator` trait methods


try-job: x86_64-rust-for-linux
@Zalathar
Copy link
Member

On closer inspection the error mentions Iterator, so I’ll assume that this PR Is the most likely cause.

@bors r-

@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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 12, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 12, 2026

This pull request was unapproved.

This PR was contained in a rollup (#153767), which was unapproved.

@JonathanBrouwer
Copy link
Contributor

@bors r-
@bors try jobs=x86_64-rust-for-linux
#153767 (comment)

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 12, 2026
…hods, r=<try>

de-non_const `Iterator` trait methods


try-job: x86_64-rust-for-linux
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 12, 2026

💔 Test for 4b830c9 failed: CI. Failed job:

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-rust-for-linux failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
  RUSTDOC H rust/quote/lib.rs
  RUSTDOC H rust/syn/lib.rs
  RUSTDOC H rust/macros/lib.rs
  RUSTDOC H rust/pin-init/src/lib.rs
##[error]error: internal compiler error: compiler/rustc_middle/src/ty/typeck_results.rs:590:9: node HirId(DefId(0:9602 ~ core[e2d3]::iter::traits::iterator::Iterator::advance_by::{impl#0}).9) (type `I::Item`) cannot be placed in TypeckResults with hir_owner DefId(0:9599 ~ core[e2d3]::iter::traits::iterator::Iterator::advance_by)


thread 'rustc' (57083) panicked at compiler/rustc_middle/src/ty/typeck_results.rs:590:9:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: rustc_middle::ty::typeck_results::invalid_hir_id_for_typeck_results::{closure#0}
   7: rustc_middle::ty::context::tls::with::<rustc_middle::ty::typeck_results::invalid_hir_id_for_typeck_results::{closure#0}, !>::{closure#0}
   8: rustc_middle::ty::context::tls::with_context::<rustc_middle::ty::context::tls::with<rustc_middle::ty::typeck_results::invalid_hir_id_for_typeck_results::{closure#0}, !>::{closure#0}, !>::{closure#0}
   9: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_context<rustc_middle::ty::context::tls::with<rustc_middle::ty::typeck_results::invalid_hir_id_for_typeck_results::{closure#0}, !>::{closure#0}, !>::{closure#0}, !>
  10: rustc_middle::ty::context::tls::with::<rustc_middle::ty::typeck_results::invalid_hir_id_for_typeck_results::{closure#0}, !>
  11: rustc_middle::ty::typeck_results::invalid_hir_id_for_typeck_results
  12: <rustc_middle::ty::typeck_results::TypeckResults>::qpath_res
  13: <rustdoc::html::render::span_map::SpanMapVisitor as rustc_hir::intravisit::Visitor>::visit_qpath
  14: rustc_hir::intravisit::walk_where_predicate::<rustdoc::html::render::span_map::SpanMapVisitor>
  15: rustc_hir::intravisit::walk_generics::<rustdoc::html::render::span_map::SpanMapVisitor>
  16: rustc_hir::intravisit::walk_item::<rustdoc::html::render::span_map::SpanMapVisitor>
  17: rustc_hir::intravisit::walk_stmt::<rustdoc::html::render::span_map::SpanMapVisitor>
  18: rustc_hir::intravisit::walk_expr::<rustdoc::html::render::span_map::SpanMapVisitor>
  19: rustc_hir::intravisit::walk_trait_item::<rustdoc::html::render::span_map::SpanMapVisitor>
  20: rustc_hir::intravisit::walk_item::<rustdoc::html::render::span_map::SpanMapVisitor>
  21: rustc_hir::intravisit::walk_mod::<rustdoc::html::render::span_map::SpanMapVisitor>
  22: rustc_hir::intravisit::walk_mod::<rustdoc::html::render::span_map::SpanMapVisitor>
  23: rustc_hir::intravisit::walk_mod::<rustdoc::html::render::span_map::SpanMapVisitor>
  24: rustc_hir::intravisit::walk_mod::<rustdoc::html::render::span_map::SpanMapVisitor>
  25: <rustdoc::html::render::context::Context>::init
  26: rustdoc::formats::renderer::run_format::<rustdoc::html::render::context::Context, rustdoc::main_args::{closure#2}::{closure#0}::{closure#1}::{closure#0}>
  27: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_interface::passes::create_and_enter_global_ctxt<(), rustdoc::main_args::{closure#2}::{closure#0}>::{closure#2}, ()>::{closure#1}, ()>::{closure#0}, ()>
  28: rustc_interface::passes::create_and_enter_global_ctxt::<(), rustdoc::main_args::{closure#2}::{closure#0}>
  29: rustc_interface::interface::run_compiler::<(), rustdoc::main_args::{closure#2}>::{closure#1}
  30: rustc_span::create_session_globals_then::<(), rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustdoc::main_args::{closure#2}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/checkout/obj/rfl/linux/rustc-ice-2026-03-12T12_24_21-57075.txt` to your bug report

note: rustc 1.96.0-nightly (4b830c956 2026-03-12) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z binary_dep_depinfo=y -C panic=abort -C embed-bitcode=n -C lto=n -C force-unwind-tables=n -C codegen-units=1 -C symbol-mangling-version=v0 -C relocation-model=static -Z function-sections=n -C target-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 -Z cf-protection=branch -C jump-tables=n -C target-cpu=x86-64 -Z tune-cpu=generic -C no-redzone=y -C code-model=kernel -Z function-return=thunk-extern -Z patchable-function-entry=16,16 -C opt-level=2 -C debug-assertions=n -C overflow-checks=y -Z unstable-options -C unsafe-allow-abi-mismatch=fixed-x18

query stack during panic:
end of query stack
error: aborting due to 1 previous error

make[2]: *** [rust/Makefile:200: rustdoc-core] Error 101
make[1]: *** [/checkout/obj/rfl/linux/Makefile:1858: rustdoc] Error 2
make: *** [Makefile:248: __sub-make] Error 2
make: Leaving directory '/checkout/obj/rfl/linux'
  local time: Thu Mar 12 12:24:21 UTC 2026
  network time: Thu, 12 Mar 2026 12:24:21 GMT
****************************************************************************
To find more information about this job, visit the following URL:

For more information how to resolve CI failures of this job, visit this link.

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

Labels

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. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants