Skip to content

Conversation

@enthropy7
Copy link
Contributor

@enthropy7 enthropy7 commented Jan 3, 2026

fixes #150614

we enforce the same restriction on #[type_const] const items that already exists for const generic parameters - when generic_const_parameter_types feature gate is not enabled, the type of a #[type_const] item cannot reference generic parameters. implementation follows the same pattern used for const generic parameters. we check if the item has the #[type_const] attribute and if the feature gate is disabled, then we apply RibKind::ConstParamTy restrictions when visiting the type, which prevents the use of generic parameters.

check is added in three places:

  • Free const items (ItemKind::Const)
  • Trait associated consts (AssocItemKind::Const in traits)
  • Impl associated consts (AssocItemKind::Const in impls)

added tests for new feature, hope i get this task right :>

r? @BoxyUwU

@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 Jan 3, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 3, 2026

BoxyUwU is currently at their maximum review capacity.
They may take a while to respond.

@enthropy7 enthropy7 force-pushed the main branch 2 times, most recently from ede7804 to e35c432 Compare January 3, 2026 13:54
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@enthropy7
Copy link
Contributor Author

CI checks failed few times cause i forget to fix another tests that was here before new behavior. now everything is ok, i force pushed correct commits to keep it clear 🥇

Copy link
Member

@BoxyUwU BoxyUwU left a comment

Choose a reason for hiding this comment

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

thanks! the logic looks correct, just a few small comments about the tests and then this can be merged

View changes since this review

@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 4, 2026

@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 Jan 4, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 4, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rust-log-analyzer

This comment has been minimized.

@enthropy7 enthropy7 force-pushed the main branch 3 times, most recently from a98a54a to 88c4a95 Compare January 4, 2026 02:16
@enthropy7 enthropy7 force-pushed the main branch 2 times, most recently from 7e2175e to a12675b Compare January 4, 2026 02:48
Copy link
Member

@BoxyUwU BoxyUwU left a comment

Choose a reason for hiding this comment

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

Cool! Thank you :)

I'll approve this once CI passes

View changes since this review

@rust-log-analyzer

This comment has been minimized.

@enthropy7
Copy link
Contributor Author

Cool! Thank you :)

I'll approve this once CI passes

View changes since this review

thanks! it was nice to cooperate, I will continue to look where I can be useful. now im waiting for CI with you, cause last one failed (stderr classic), but now i solved it

@rust-log-analyzer

This comment has been minimized.

@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 4, 2026

@bors r+ rollup

thanks :)

@bors
Copy link
Collaborator

bors commented Jan 4, 2026

📌 Commit 46bb414 has been approved by BoxyUwU

It is now in the queue for this repository.

@bors bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 4, 2026
bors added a commit that referenced this pull request Jan 4, 2026
Rollup of 7 pull requests

Successful merges:

 - #150201 (compiletest: Support revisions in debuginfo (read: debugger) tests)
 - #150642 (mutex.rs: remove needless-maybe-unsized bounds)
 - #150643 (vec in-place-drop: avoid creating an intermediate slice)
 - #150650 (Forbid generic parameters in types of #[type_const] items)
 - #150658 (Clarify panic conditions in `Iterator::last`)
 - #150659 (Add missing translator resources for interface parse_cfg and parse_check_cfg)
 - #150666 (Fix ambig-unambig-ty-and-consts link)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 05dce48 into rust-lang:main Jan 4, 2026
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 4, 2026
rust-timer added a commit that referenced this pull request Jan 4, 2026
Rollup merge of #150650 - enthropy7:main, r=BoxyUwU

Forbid generic parameters in types of #[type_const] items

fixes #150614

we enforce the same restriction on `#[type_const]` const items that already exists for const generic parameters - when `generic_const_parameter_types` feature gate is not enabled, the type of a `#[type_const]` item cannot reference generic parameters.  implementation follows the same pattern used for const generic parameters. we check if the item has the `#[type_const]` attribute and if the feature gate is disabled, then we apply `RibKind::ConstParamTy` restrictions when visiting the type, which prevents the use of generic parameters.

check is added in three places:
- Free const items (`ItemKind::Const`)
- Trait associated consts (`AssocItemKind::Const` in traits)
- Impl associated consts (`AssocItemKind::Const` in impls)

added tests for new feature, hope i get this task right :>

r? `@BoxyUwU`
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.

MGCA: forbid generic parameters from being in used in the types of type_const items

5 participants