Narrow const macro DeclRef exclusion to only variables#1391
Open
fw-immunant wants to merge 1 commit intomasterfrom
Open
Narrow const macro DeclRef exclusion to only variables#1391fw-immunant wants to merge 1 commit intomasterfrom
DeclRef exclusion to only variables#1391fw-immunant wants to merge 1 commit intomasterfrom
Conversation
for example, mentioning enum constants should be accepted in const contexts
eb21b12 to
102f436
Compare
kkysen
reviewed
Oct 3, 2025
| self.ast_context.display_loc(src_loc), | ||
| "Cannot yet refer to declarations in a const expr", | ||
| )); | ||
| if let CDeclKind::Variable { .. } = decl { |
Contributor
There was a problem hiding this comment.
I didn't do this initially because I wasn't sure about other declarations within a function and how that interacted with global scope, so I wanted to err on the safer side, since this is supposed to be temporary.
| return LATE_INIT_VAR; | ||
| } | ||
|
|
||
| enum foo { Variant1, }; |
Contributor
There was a problem hiding this comment.
How does this work if this is defined within a function, the macro is defined outside of it, and used within it?
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.
Mentioning enum variants, etc. in const contexts doesn't have the same scoping problems as variables. This change narrows the exception to const macro translation for
DeclRefs and makes it more distinct from what #1386 covers.