MGCA: require #[type_const] on free consts too#152129
Open
khyperia wants to merge 1 commit intorust-lang:mainfrom
Open
MGCA: require #[type_const] on free consts too#152129khyperia wants to merge 1 commit intorust-lang:mainfrom
khyperia wants to merge 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
HIR ty lowering was modified cc @fmease |
2802eb1 to
63e1045
Compare
BoxyUwU
reviewed
Feb 5, 2026
| } else { | ||
| None | ||
| }; | ||
| self.lower_resolved_assoc_const_path( |
Member
There was a problem hiding this comment.
Ah interesting, I'd have thought you'd have needed to update AssocConst too but lower_resolved_assoc_const_path already handles it. That's fun
BoxyUwU
reviewed
Feb 5, 2026
63e1045 to
0db0759
Compare
BoxyUwU
reviewed
Feb 5, 2026
| def_id: DefId, | ||
| span: Span, | ||
| ) -> Result<(), ErrorGuaranteed> { | ||
| if find_attr!(self.tcx().get_all_attrs(def_id), AttributeKind::TypeConst(_)) { |
Member
There was a problem hiding this comment.
Suggested change
| if find_attr!(self.tcx().get_all_attrs(def_id), AttributeKind::TypeConst(_)) { | |
| if self.tcx().is_type_const(def_id) { |
should work instead and be a bit shorter/nicer :3
BoxyUwU
reviewed
Feb 5, 2026
| note: the declaration must be marked with `#[type_const]` | ||
| --> $DIR/unmarked-free-const.rs:6:1 | ||
| | | ||
| LL | const N: usize = 4; |
Member
There was a problem hiding this comment.
pointing to the definition site of the non-type const is rly nice :3 thanks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When investigating another issue, I discovered that following ICEs (the
const_of_itemquery doesn't support non-type_const-marked constants and does aspan_delayed_bug):My initial thought of "only require
#[type_const]on places that stable doesn't currently accept" ran into the issue of this compiling on stable today:Figuring out which specific cases are not currently accepted by stable is quite hairy.
Upon discussion with @BoxyUwU, she suggested that all consts, including free consts, should require
#[type_const]to be able to be referred to. This is what this PR does.The change totests/ui/const-generics/generic_const_exprs/non-local-const.rsis unfortunate, reverting the fix in #143106 no longer fails the test. Any suggestions to test it more appropriately would be most welcome!edit: never mind, figured out how compiletests work :) - verified that the new test setup correctly ICEs when that PR's fix is reverted.
r? @BoxyUwU