Skip to content

diagnostics: suggest generic_const_args for const ops#156968

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
Dnreikronos:fix/gca-const-item-diagnostic-156729
Jul 11, 2026
Merged

diagnostics: suggest generic_const_args for const ops#156968
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
Dnreikronos:fix/gca-const-item-diagnostic-156729

Conversation

@Dnreikronos

@Dnreikronos Dnreikronos commented May 26, 2026

Copy link
Copy Markdown
Contributor

View all comments

fixes #156729

when const ops hit generic params, like [u8; size_of::<self>()], the diagnostic only points at generic_const_exprs. imo that's a stale nudge now that generic_const_args and type const items are the path we want people trying.

add help for generic_const_args and type const items in the resolve and hir_ty_lowering paths. also skip the old gce suggestion once min_generic_const_args is enabled, and emit both suggestions for the self alias path so the "alternatively" wording doesn't hang there by itself. includes the regression test from the issue. lgtm.

@rustbot

rustbot commented May 26, 2026

Copy link
Copy Markdown
Collaborator

HIR ty lowering was modified

cc @fmease

@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 May 26, 2026
@rustbot

rustbot commented May 26, 2026

Copy link
Copy Markdown
Collaborator

r? @wesleywiser

rustbot has assigned @wesleywiser.
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 73 candidates
  • Random selection from 18 candidates

@Dnreikronos Dnreikronos force-pushed the fix/gca-const-item-diagnostic-156729 branch 4 times, most recently from a43c40b to d890018 Compare May 26, 2026 13:31
@rust-log-analyzer

This comment has been minimized.

@Dnreikronos Dnreikronos force-pushed the fix/gca-const-item-diagnostic-156729 branch from d890018 to f883d0e Compare May 26, 2026 13:38
@rust-bors

This comment has been minimized.

@Dnreikronos Dnreikronos force-pushed the fix/gca-const-item-diagnostic-156729 branch from f883d0e to a9b91d1 Compare June 17, 2026 03:33
@rustbot

This comment has been minimized.

@Dnreikronos

Copy link
Copy Markdown
Contributor Author

@wesleywiser, hi!
does you need something more from my side to help with the review here?

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@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 Jun 25, 2026
@Dnreikronos Dnreikronos force-pushed the fix/gca-const-item-diagnostic-156729 branch from c02ce98 to bf4bad2 Compare June 25, 2026 12:58
@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits PR has merge commits, merge with caution. labels Jun 25, 2026
@Dnreikronos Dnreikronos changed the title Suggest generic_const_args + type const items in const operation diagnostics diagnostics: suggest generic_const_args for const ops Jun 25, 2026
@Dnreikronos

Copy link
Copy Markdown
Contributor Author

@rustbot reroll

@rustbot rustbot assigned petrochenkov and unassigned wesleywiser Jul 6, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

📌 Commit bf4bad2 has been approved by petrochenkov

It is now in the queue for this repository.

@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 Jul 7, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 7, 2026
@rust-bors

rust-bors Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

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

View changes since this unapproval

@Dnreikronos Dnreikronos force-pushed the fix/gca-const-item-diagnostic-156729 branch from bf4bad2 to 7958796 Compare July 7, 2026 15:33
@rustbot

This comment has been minimized.

@Dnreikronos

Dnreikronos commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@JonathanBrouwer @petrochenkov i pushed a fix for the rollup failure from the aarch64-gnu-llvm-21-1 job.

i rebased the pr on current origin/main, which brought in tests/ui/const-generics/mgca/double-inline-const.stderr, then updated that fixture to expect the new generic_const_args + type const help text. that matches the actual stderr from the failed job.

imo this was just a stale ui fixture after the rollup picked up a newer test from main. the compiler output looked right to me, the expected stderr was the part that was out of date.

i also ran git diff --check, which passes. i tried the focused ui test locally, but bootstrap did not finish within 10 min on my machine, so idk if that local run is useful signal.

could one of you re-trigger the failed job / try job for that same builder? i don't have permission to do it from here. ltm if you want anything else changed.

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

This soft conflicts with #158617 which is in the current rollup, please rebase on that after it's merged

…stics

Point users at `#![feature(generic_const_args)]` and `type const` items
when they hit the "generic parameters may not be used in const operations"
error, not just `generic_const_exprs`.
@Dnreikronos Dnreikronos force-pushed the fix/gca-const-item-diagnostic-156729 branch from 7958796 to c394716 Compare July 10, 2026 20:14
@rustbot

rustbot commented Jul 10, 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.

@rust-log-analyzer

This comment has been minimized.

@Dnreikronos Dnreikronos force-pushed the fix/gca-const-item-diagnostic-156729 branch from c394716 to 382f1a0 Compare July 10, 2026 20:51
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 10, 2026
@rust-log-analyzer

This comment has been minimized.

@Dnreikronos Dnreikronos force-pushed the fix/gca-const-item-diagnostic-156729 branch from 382f1a0 to 9211a89 Compare July 10, 2026 22:04
@Dnreikronos

Copy link
Copy Markdown
Contributor Author

This soft conflicts with #158617 which is in the current rollup, please rebase on that after it's merged

Hi, @JonathanBrouwer!
Can you re-validate, please?

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors r=petrochenkov rollup=iffy
Iffy because this is likely to soft-conflict

@rust-bors

rust-bors Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 9211a89 has been approved by petrochenkov

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 Jul 11, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 11, 2026
…gnostic-156729, r=petrochenkov

diagnostics: suggest generic_const_args for const ops

fixes rust-lang#156729

when const ops hit generic params, like `[u8; size_of::<self>()]`, the diagnostic only points at `generic_const_exprs`. imo that's a stale nudge now that `generic_const_args` and `type const` items are the path we want people trying.

add help for `generic_const_args` and `type const` items in the resolve and hir_ty_lowering paths. also skip the old gce suggestion once `min_generic_const_args` is enabled, and emit both suggestions for the `self` alias path so the "alternatively" wording doesn't hang there by itself. includes the regression test from the issue. lgtm.
rust-bors Bot pushed a commit that referenced this pull request Jul 11, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #159126 (Fix PR number in bootstrap's change tracker)
 - #156968 (diagnostics: suggest generic_const_args for const ops)
 - #159012 (Shrink mir::Statement to 40 bytes)
 - #158182 (std: use `OnceLock` for SGX argument storage)
 - #159114 (Add regression test for $-prefixed fragment specifier in repetition)
 - #159060 (Look for the cdb architecture that corresponds to the target triple)
 - #159089 (riscv: update c-variadic test for LLVM changes)
 - #159093 (pretty-print: use inline asm's actual macro name)
rust-bors Bot pushed a commit that referenced this pull request Jul 11, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #159126 (Fix PR number in bootstrap's change tracker)
 - #156968 (diagnostics: suggest generic_const_args for const ops)
 - #159012 (Shrink mir::Statement to 40 bytes)
 - #158182 (std: use `OnceLock` for SGX argument storage)
 - #159114 (Add regression test for $-prefixed fragment specifier in repetition)
 - #159060 (Look for the cdb architecture that corresponds to the target triple)
 - #159089 (riscv: update c-variadic test for LLVM changes)
 - #159093 (pretty-print: use inline asm's actual macro name)
rust-bors Bot pushed a commit that referenced this pull request Jul 11, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #159126 (Fix PR number in bootstrap's change tracker)
 - #155811 (Include AtomicU128/AtomicI128 in docs for any target)
 - #156968 (diagnostics: suggest generic_const_args for const ops)
 - #159012 (Shrink mir::Statement to 40 bytes)
 - #156618 (rustdoc: test ignoring rustc lints in CLI)
 - #158182 (std: use `OnceLock` for SGX argument storage)
 - #159114 (Add regression test for $-prefixed fragment specifier in repetition)
 - #158523 (Fix feature gate for `repr(simd)`)
 - #158876 (Fix multiple logic bugs in `Arc::make_mut`)
 - #158928 (std: fix Xous UDP send_to length mismatch and truncation)
 - #159060 (Look for the cdb architecture that corresponds to the target triple)
 - #159089 (riscv: update c-variadic test for LLVM changes)
 - #159093 (pretty-print: use inline asm's actual macro name)
 - #159122 (doc: use ptr::addr in offset_from docs)

Failed merges:

 - #158732 (Apply MCP 1003 and move diagnostics.rs into its own module)
@rust-bors rust-bors Bot merged commit aa8cf33 into rust-lang:main Jul 11, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 11, 2026
rust-timer added a commit that referenced this pull request Jul 11, 2026
Rollup merge of #156968 - Dnreikronos:fix/gca-const-item-diagnostic-156729, r=petrochenkov

diagnostics: suggest generic_const_args for const ops

fixes #156729

when const ops hit generic params, like `[u8; size_of::<self>()]`, the diagnostic only points at `generic_const_exprs`. imo that's a stale nudge now that `generic_const_args` and `type const` items are the path we want people trying.

add help for `generic_const_args` and `type const` items in the resolve and hir_ty_lowering paths. also skip the old gce suggestion once `min_generic_const_args` is enabled, and emit both suggestions for the `self` alias path so the "alternatively" wording doesn't hang there by itself. includes the regression test from the issue. lgtm.
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.

GCA: diagnostic does not suggest creating a const item to replace generic expression

6 participants