Skip to content

diagnostics: suggest generic_const_args for const ops#156968

Open
Dnreikronos wants to merge 1 commit into
rust-lang:mainfrom
Dnreikronos:fix/gca-const-item-diagnostic-156729
Open

diagnostics: suggest generic_const_args for const ops#156968
Dnreikronos wants to merge 1 commit into
rust-lang:mainfrom
Dnreikronos:fix/gca-const-item-diagnostic-156729

Conversation

@Dnreikronos

@Dnreikronos Dnreikronos commented May 26, 2026

Copy link
Copy Markdown
Contributor

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

rustbot commented Jun 25, 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.

@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
…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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

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

4 participants