Conversation
|
damn.. this is problematic with reserved identifiers.. |
7805dcc to
cee0924
Compare
| // Special handling for reserved identifiers prefix. | ||
| let mut field_name = def.field_name.to_string(); | ||
| if field_name.starts_with("r#") { | ||
| field_name = field_name.strip_prefix("r#").unwrap().to_string(); | ||
| } | ||
| syn::parse_str::<Ident>(&format!("__{}", field_name.to_uppercase())).unwrap() |
There was a problem hiding this comment.
Can this duplicated logic be moved to a separate function and called here and in 556?
| | | ||
| = note: the method was found for | ||
| - `PartialTestAllowed<upper, false, c, b, false>` | ||
| - `PartialTestAllowed<__UPPER, false, __C, __B, false>` |
There was a problem hiding this comment.
The original approach was explicitly to try and keep the output in the diagnostics as close to the user's code as possible, so changing their casing is unfortunate. We must address the issue with clashing with field names, of course, but we could handle that by exclusively changing value and nothing else, right? And at that point we'd have to check that the transformation target (lets say, VALUE) doesn't already exist as another const param...
There was a problem hiding this comment.
that would be a solution, but I think the diagnostics are still sufficient to know what the issue is. I can still do the special case solution. alternatively: what do you think about renaming the value field itself to __value or __private_value?
|
I now provided an alternative PR in #131 which renames the generated field names to |
Fixes #126