Skip to content

comptime fn error: suggest wrapping in const block - #163772

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mejrs:comptime_error
Oct 8, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mejrs:comptime_error

Conversation

@mejrs

@mejrs mejrs commented Oct 4, 2026

Copy link
Copy Markdown
Member

It won't always be correct, since all values captured by a const block must also be determined at compile time, but it should usually work or be a step in the right direction

@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 Oct 4, 2026
@rustbot

rustbot commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

r? @nnethercote

rustbot has assigned @nnethercote.
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 77 candidates
  • Random selection from 16 candidates

@rustbot

This comment has been minimized.

@nnethercote

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 18ecbb5 has been approved by nnethercote

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 Oct 6, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 6, 2026
comptime fn error: suggest wrapping in const block

It won't always be correct, since all values captured by a const block must also be determined at compile time, but it should usually work or be a step in the right direction
rust-bors Bot pushed a commit that referenced this pull request Oct 6, 2026
Rollup of 3 pull requests

Successful merges:

 - #163809 (Adjust the adjustment to wasi TLS to no longer adjust)
 - #163348 (perf:cache FFI safety results in improper_ctypes lint)
 - #163772 (comptime fn error: suggest wrapping in const block)
@jhpratt

jhpratt commented Oct 6, 2026

Copy link
Copy Markdown
Member

@bors r- #163858 (comment)

To only update this specific test, also pass `--test-args attributes/doc_examples/rustc_comptime.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/attributes/doc_examples/rustc_comptime.rs" "-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/attributes/doc_examples/rustc_comptime" "-Znext-solver=coherence" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2015" "--crate-type" "lib" "-Z" "ui-testing=no"
stdout: none
--- stderr -------------------------------
error: comptime functions can only be called at compile time
##[error]  --> /checkout/tests/ui/attributes/doc_examples/rustc_comptime.rs:10:5
   |

@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 Oct 6, 2026
@rust-bors

rust-bors Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

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

View changes since this unapproval

It won't always be correct, since all values captured by a const block must also be determined at compile time, but it should usually work or be a step in the right direction
@rustbot

rustbot commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

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.

@mejrs

mejrs commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

@bors r=nnethercote

@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 13703b5 has been tentatively approved by nnethercote

It will be put into the queue for this repository once PR CI succeeds.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 8, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 8, 2026
comptime fn error: suggest wrapping in const block

It won't always be correct, since all values captured by a const block must also be determined at compile time, but it should usually work or be a step in the right direction
rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #163462 (Fix COFF renaming of decorated (stdcall/fastcall/vectorcall) exports)
 - #163855 (Include enclosing item's context on const errors)
 - #163861 (Run LLDB debuginfo tests on `x86_64-mingw`)
 - #161201 (Speed up tidy again)
 - #163538 (Add `rustc::missing_generic_type_visitable` lint)
 - #163617 (mips: make `Complex<T>` ABI match GCC)
 - #163772 (comptime fn error: suggest wrapping in const block)
 - #163832 (reject non-async coroutine closures as async callables)
 - #163958 (only make `RustaceansAreAwesome` satisfy trait clauses)
 - #163974 (Condense AdtDef lang item checks into one match)
 - #163979 (Add `bf16` to arm features)
 - #163989 (Revert "compiletest: stream output of executor process when --no-capture is set")

Failed merges:

 - #163972 (const-eval: ICE when we hit a non-const fn)
rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - #156112 (Distinguish `repr(C)` ZSTs from others in ABI computation)
 - #157941 (Deny partial `-Z stack-protector` by default in all editions)
 - #163462 (Fix COFF renaming of decorated (stdcall/fastcall/vectorcall) exports)
 - #163855 (Include enclosing item's context on const errors)
 - #163861 (Run LLDB debuginfo tests on `x86_64-mingw`)
 - #163913 ( Silence redundant failed obligations on the same statement)
 - #161201 (Speed up tidy again)
 - #163380 (Tweak "name not found" resolution error when it happens from within a derive expansion)
 - #163538 (Add `rustc::missing_generic_type_visitable` lint)
 - #163617 (mips: make `Complex<T>` ABI match GCC)
 - #163772 (comptime fn error: suggest wrapping in const block)
 - #163813 (use pre-borrowck typing env for early MIR validation)
 - #163924 (replace instances of NonNull::new(&mut x).expect("...") with NonNull::from_mut)
 - #163958 (only make `RustaceansAreAwesome` satisfy trait clauses)
 - #163960 (vexos: clear .bss from assembly)
 - #163974 (Condense AdtDef lang item checks into one match)
 - #163979 (Add `bf16` to arm features)
 - #163989 (Revert "compiletest: stream output of executor process when --no-capture is set")
 - #163995 (m68k-unknown-none-elf: Remove code model)

Failed merges:

 - #163832 (reject non-async coroutine closures as async callables)
 - #163972 (const-eval: ICE when we hit a non-const fn)
@rust-bors
rust-bors Bot merged commit f90de16 into rust-lang:main Oct 8, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 8, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
Rollup merge of #163772 - mejrs:comptime_error, r=nnethercote

comptime fn error: suggest wrapping in const block

It won't always be correct, since all values captured by a const block must also be determined at compile time, but it should usually work or be a step in the right direction
programskillforverification pushed a commit to programskillforverification/miri that referenced this pull request Oct 9, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#156112 (Distinguish `repr(C)` ZSTs from others in ABI computation)
 - rust-lang/rust#157941 (Deny partial `-Z stack-protector` by default in all editions)
 - rust-lang/rust#163462 (Fix COFF renaming of decorated (stdcall/fastcall/vectorcall) exports)
 - rust-lang/rust#163855 (Include enclosing item's context on const errors)
 - rust-lang/rust#163861 (Run LLDB debuginfo tests on `x86_64-mingw`)
 - rust-lang/rust#163913 ( Silence redundant failed obligations on the same statement)
 - rust-lang/rust#161201 (Speed up tidy again)
 - rust-lang/rust#163380 (Tweak "name not found" resolution error when it happens from within a derive expansion)
 - rust-lang/rust#163538 (Add `rustc::missing_generic_type_visitable` lint)
 - rust-lang/rust#163617 (mips: make `Complex<T>` ABI match GCC)
 - rust-lang/rust#163772 (comptime fn error: suggest wrapping in const block)
 - rust-lang/rust#163813 (use pre-borrowck typing env for early MIR validation)
 - rust-lang/rust#163924 (replace instances of NonNull::new(&mut x).expect("...") with NonNull::from_mut)
 - rust-lang/rust#163958 (only make `RustaceansAreAwesome` satisfy trait clauses)
 - rust-lang/rust#163960 (vexos: clear .bss from assembly)
 - rust-lang/rust#163974 (Condense AdtDef lang item checks into one match)
 - rust-lang/rust#163979 (Add `bf16` to arm features)
 - rust-lang/rust#163989 (Revert "compiletest: stream output of executor process when --no-capture is set")
 - rust-lang/rust#163995 (m68k-unknown-none-elf: Remove code model)

Failed merges:

 - rust-lang/rust#163832 (reject non-async coroutine closures as async callables)
 - rust-lang/rust#163972 (const-eval: ICE when we hit a non-const fn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants