Skip to content

Suggest gca! for path const args that use generic params - #165035

Open
yashaggarwal85d wants to merge 1 commit into
rust-lang:mainfrom
yashaggarwal85d:fix-gca-macro-suggestion
Open

yashaggarwal85d wants to merge 1 commit into
rust-lang:mainfrom
yashaggarwal85d:fix-gca-macro-suggestion

Conversation

@yashaggarwal85d

@yashaggarwal85d yashaggarwal85d commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #164999

When a const arg is just a path like Self::N and the gca features are on, the error now suggests wrapping it in gca! instead of telling you to make a type const item:

help: consider wrapping `Self::N` in the `gca!` macro
  |
8 -     fn foo() -> [u8; Self::N];
8 +     fn foo() -> [u8; gca!(Self::N)];

It only fires when both gca_min_const_items and gca_const_items are enabled (with just the min feature the wrapped form still errors), and it skips const { .. } blocks, non-path expressions, macro spans, and inherent assoc consts, since gca! doesn't help there yet. Those keep the old help.

@rustbot

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

rustbot commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

r? @JonathanBrouwer

rustbot has assigned @JonathanBrouwer.
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 20 candidates

@yashaggarwal85d

Copy link
Copy Markdown
Contributor Author

FYI, used LLM for writing tests.

@JonathanBrouwer

Copy link
Copy Markdown
Member

r? @khyperia
I'm not sure how useful this suggestion is given that the gca! syntax is probably temporary

@rustbot rustbot assigned khyperia and unassigned JonathanBrouwer Oct 27, 2026
@estebank

Copy link
Copy Markdown
Contributor

@JonathanBrouwer that is true, but if there will be any syntax, a suggestion will be needed and the filtering logic will likely be the same, just with different output. I find that spending a little bit of effort to improde diagnostics for nightly features helps set the tone for their maintainers to continue improving them and makes the stabilization rollout smoother because there needs to be less of a mad scramble to improve diagnostics right before or right after.

@JonathanBrouwer

Copy link
Copy Markdown
Member

That makes sense, thanks for sharing!
I'll still defer to Ashley as she can better judge of when exactly we should suggest gca!

This branch has not been deployed

No deployments
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: Better structured suggestion if the gca! macro is missed off

5 participants