Skip to content

Suggest type next to visibility for const items#157382

Open
reddevilmidzy wants to merge 1 commit into
rust-lang:mainfrom
reddevilmidzy:pub-type-const
Open

Suggest type next to visibility for const items#157382
reddevilmidzy wants to merge 1 commit into
rust-lang:mainfrom
reddevilmidzy:pub-type-const

Conversation

@reddevilmidzy

Copy link
Copy Markdown
Member

resolve: #157368

Adjusts the type const suggestion to preserve visibility ordering, so pub const is suggested as pub type const instead of type pub const.

@rustbot

rustbot commented Jun 3, 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 Jun 3, 2026
@rustbot

rustbot commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

r? @petrochenkov

rustbot has assigned @petrochenkov.
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 17 candidates

@petrochenkov

Copy link
Copy Markdown
Contributor

r? compiler

@rustbot rustbot assigned Kivooeo and unassigned petrochenkov Jun 3, 2026
@Kivooeo

Kivooeo commented Jun 3, 2026

Copy link
Copy Markdown
Member

Hey, thanks for a PR, I'm a bit busy this week. I will try to review within next 3 days

@rust-log-analyzer

This comment has been minimized.

@Unique-Usman

Copy link
Copy Markdown
Contributor

I went through the pr, looks good. There is already an alternative test if it is an external crate(non-local) at tests/ui/const-generics/mgca/non-local-const-without-type_const.rs, so, not needed for this pr since it exist.

@estebank

estebank commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

There is some code duplication between the branches, but that's ok. One thing that'd be nice to have is a check for whether the feature is enabled in order to add a note explaining that this change only would work on nightly (like we do in the errors when using a feature that isn't enabled).

Other than that, r=me.

@Kivooeo Kivooeo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change this match to something like this

View changes since this review

Comment thread compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
@Kivooeo

Kivooeo commented Jun 9, 2026

Copy link
Copy Markdown
Member

@rustbot author

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Jun 9, 2026
@reddevilmidzy

Copy link
Copy Markdown
Member Author

There is some code duplication between the branches, but that's ok. One thing that'd be nice to have is a check for whether the feature is enabled in order to add a note explaining that this change only would work on nightly (like we do in the errors when using a feature that isn't enabled).

Other than that, r=me.

Am I understanding correctly that you mean we should add this note only when min_generic_const_args is disabled?

If that's my understanding, then for this test case, when MGCA is not enabled, the code compiles successfully instead of emitting an error with a suggestion to use type const.

@reddevilmidzy

Copy link
Copy Markdown
Member Author

thank you for the review :)
@rustbot ready

@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 Jun 9, 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.

Suggestion reorders visibility incorrectly for type const items

7 participants