-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Permit include!(…) in pattern position for completeness's sake #146372
Copy link
Copy link
Open
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.P-lowLow priorityLow priorityT-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.P-lowLow priorityLow priorityT-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
At the time of writing, built-in attr
includeis not permitted to expand into a pattern context (its expander doesn't overridemake_pat):For nothing but "completeness" (item, expr, pat trifecta) and for consistency with
include_strandinclude_bytesI propose that we permit them in this position.include's expander would then parse a PatternNoTopGuard (as defined in RFC 3637), i.e., top-level or-patterns are permitted (and guards aren't – ignoringguard_patternsfor now). Meaninglet include!("file");withfilecontainingfalse | truewould be permitted despitelet false | true;not being valid (requiring parentheses) since the macro expansion would act as invisible delimiters. Leading vert / bar would be permitted as well, naturally.Lastly, don't strip shebang or frontmatter (meaning they'll lead to an error since the pattern parser won't accept it). Edit: Well, it depends on the outcome of #146377.