Skip to content

diagnostics: suggest generic_const_args for const ops#156968

Open
Dnreikronos wants to merge 2 commits 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 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

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-review Status: Awaiting review from the assignee but also interested parties. label Jul 7, 2026
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Jul 7, 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 7, 2026
Rollup of 8 pull requests

Successful merges:

 - #156968 (diagnostics: suggest generic_const_args for const ops)
 - #158617 (allow mGCA const arguments to fall back to anon consts)
 - #158690 (delegation: support mapping of all arguments with `Self` type)
 - #158696 (Rename some `body_id` to `body_def_id`)
 - #158333 (Fix typetree generation for differentiated functions)
 - #158646 (powerpc64le_unknown_freebsd.rs: link with -lgcc)
 - #158802 (Use `ci-mirrors` in `armhf-gnu` for {busybox, ubuntu rootfs} artifacts)
 - #158905 (delegation: add constraints to new generic args)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 7, 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.
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

💔 I suspect this PR failed tests as part of a rollup
@bors r-

After fixing the problem, consider running a try job for the failed job before re-approving.

Link to failure: #158909 (comment)

@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 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

…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 bf4bad2 to 7958796 Compare July 7, 2026 15:33
@rustbot

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

@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

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.

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