-
-
Notifications
You must be signed in to change notification settings - Fork 23
refactor: macro. #1154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: macro. #1154
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Refactors the regex! macro to require an explicit static keyword in its invocation.
- Changes macro pattern to ($(static $var = $re);+;) form.
- Updates all macro invocations to include static before each identifier.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
||
macro_rules! regex { | ||
($($var:ident = $re:expr);+;) => { | ||
($(static $var:ident = $re:expr);+;) => { |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requiring static in the macro invocation introduces a breaking change to the macro's call-site API without adding semantic value (the macro already emits static). Consider adding an additional macro arm to accept the previous form ($($var:ident = $re:expr);+;) for backward compatibility, or remove static from the invocation pattern and keep it only in the expansion.
Copilot uses AI. Check for mistakes.
REGEX_FLOAT = r"^[0-9_]+(:?(:?\.[0-9_]+)?[eE][+-]?[0-9_]+|\.[0-9_]+)$"; | ||
REGEX_IS_DATE_TIME = r"^[0-9]{4}-[0-9]{2}-[0-9]{2}"; | ||
REGEX_OFFSET_DATE_TIME = | ||
static REGEX_INTEGER_BIN = r"^0b[0|1](:?_?[0|1])*$"; |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Character class [0|1] includes '|' as a valid character; it should be [01] to restrict to binary digits. Similarly adjust the second occurrence inside (:??[0|1]) to (:??[01]). Proposed: r"^0b01*$".
static REGEX_INTEGER_BIN = r"^0b[0|1](:?_?[0|1])*$"; | |
static REGEX_INTEGER_BIN = r"^0b[01](?:_?[01])*$"; |
Copilot uses AI. Check for mistakes.
static REGEX_INTEGER_BIN = r"^0b[0|1](:?_?[0|1])*$"; | ||
static REGEX_INTEGER_OCT = r"^0o[0-7](:?_?[0-7])*$"; | ||
static REGEX_INTEGER_HEX = r"^0x[0-9A-Fa-f](:?_?[0-9A-Fa-f])*$"; | ||
static REGEX_INTEGER_DEC = r"^(:?[1-9](:?_?[0-9])*|0)$"; | ||
static REGEX_FLOAT = r"^[0-9_]+(:?(:?\.[0-9_]+)?[eE][+-]?[0-9_]+|\.[0-9_]+)$"; |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sequences (:? ... ) and :?(:? ... ) appear intended as non-capturing groups but are malformed; Rust's regex crate uses (?: ... ). Correct forms: REGEX_INTEGER_OCT r"^0o0-7$", REGEX_INTEGER_HEX r"^0x0-9A-Fa-f
static REGEX_INTEGER_BIN = r"^0b[0|1](:?_?[0|1])*$"; | |
static REGEX_INTEGER_OCT = r"^0o[0-7](:?_?[0-7])*$"; | |
static REGEX_INTEGER_HEX = r"^0x[0-9A-Fa-f](:?_?[0-9A-Fa-f])*$"; | |
static REGEX_INTEGER_DEC = r"^(:?[1-9](:?_?[0-9])*|0)$"; | |
static REGEX_FLOAT = r"^[0-9_]+(:?(:?\.[0-9_]+)?[eE][+-]?[0-9_]+|\.[0-9_]+)$"; | |
static REGEX_INTEGER_BIN = r"^0b[01](?:_?[01])*$"; | |
static REGEX_INTEGER_OCT = r"^0o[0-7](?:_?[0-7])*$"; | |
static REGEX_INTEGER_HEX = r"^0x[0-9A-Fa-f](?:_?[0-9A-Fa-f])*$"; | |
static REGEX_INTEGER_DEC = r"^(?:[1-9](?:_?[0-9])*|0)$"; | |
static REGEX_FLOAT = r"^[0-9_]+(?:(?:\.[0-9_]+)?[eE][+-]?[0-9_]+|\.[0-9_]+)$"; |
Copilot uses AI. Check for mistakes.
No description provided.