Refactoring Patterns, Improve Metavariables and Update Documents - #102
Conversation
Commit b88c3c9 is discarded
|
Commit b88c3c9 may be picked later |
It's a bit too complex for current syntax, and I'm going to re-implement it in later commits |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors metavariables handling in pattern matching, adds support for const generic parameters, and updates documentation. The key changes include introducing a Const abstraction to handle both MIR constants and parameter constants, improving pattern matching for type constants, and updating the default patterns system.
- Refactored const variable handling to support both MIR constants and parameter constants
- Changed the default lint level for dynamic patterns from
forbidtodeny - Added default pattern collection to eliminate the need for manual
RPL_PATSconfiguration
Reviewed Changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/driver.rs | Added handling for missing RPL_PATS environment variable and os_str_display feature |
| crates/rpl_constraints/src/konst.rs | New Const enum to abstract over MIR constants and parameter constants |
| crates/rpl_meta/src/cli.rs | Added collect_default_patterns() function with embedded pattern definitions |
| crates/rpl_interface/src/callbacks.rs | Updated to use default patterns when RPL_PATS is not provided |
| crates/rpl_match/src/ty.rs | Refactored const variable matching to handle parameter constants |
| tests/ui/ | Updated test expectations to reflect lint level changes |
Comments suppressed due to low confidence (2)
crates/rpl_constraints/src/predicates/multiple_consts.rs:19
- The function silently returns false when constants cannot be evaluated as scalar integers, but logs a warning. This could mask real issues where the predicate should fail more explicitly.
} else {
src/driver.rs:227
- [nitpick] The error message uses
var.display()which may not provide the most helpful output for debugging non-Unicode environment variables.
Err(env::VarError::NotUnicode(var)) => {
| macro_rules! default_pattern { | ||
| ($path:literal) => { | ||
| ( | ||
| PathBuf::from(concat!("/rpl/docs/patterns-pest/", $path)), |
There was a problem hiding this comment.
The hardcoded absolute path "/rpl/docs/patterns-pest/" will not work correctly in different environments or installations. This should use a relative path or be configurable.
| None | ||
| } | ||
| }, | ||
| (_, _) => None, |
There was a problem hiding this comment.
[nitpick] The catch-all pattern (_, _) in try_cmp_as makes it unclear what specific combinations are not handled. Consider using explicit patterns for better maintainability.
| (_, _) => None, | |
| (Self::MIR(_), Self::Param(_)) => None, // MIR and Param cannot be compared | |
| (Self::Param(_), Self::MIR(_)) => None, // Param and MIR cannot be compared | |
| (Self::MIR(_), _) => None, // MIR and other variants cannot be compared | |
| (Self::Param(_), _) => None, // Param and other variants cannot be compared | |
| (_, _) => None, // Catch-all for any other combinations |
No description provided.