-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Chore: Add witness hint for enum_tuple_variant_field_missing
lint
#1214
Chore: Add witness hint for enum_tuple_variant_field_missing
lint
#1214
Conversation
+ Added witness hint for enum_tuple_variant_field_missing + Added new query for baseline_field_names for extra witness data
Ah, I reviewed the PRs in backwards order so I answered some of these questions in #1216. Sorry about that! I'd recommend calling the field
Our schema also often has good docs for tricky areas:
Overall, the PR looks great and just has the same polishing opportunities as #1216, so I'll let you do one more pass on it before merging. Thanks for putting it together! |
Just as in #1216, Edit: just saw your message here, will address that in a moment. |
Adds a custom handlebars block helper called `repeat`. The goal of this helper is to allow one to iterate a value `n` number of times. The syntax of `repeat` is similar to that of the built-in `each` helper. It assigns to the local block variables `@index`, `@first`, and `@last`. `@index` is a number, `@first` and `@last` are booleans. ## Example The following example handlebars template assumes the existence of an outputted value called `field_count`, which is a `Number` type representing the number of fields on an enum variant (for example). ``` "path_to_enum::ExampleEnum::ExampleVariant({{#repeat field_count }}_{{#unless @last }}, {{/unless}}{{/times}})" ``` This template string would produce the following output string for an input tuple enum with 3 fields: ``` "path_to_enum::ExampleEnum::ExampleVariant(_, _, _)" ``` ## Commit Notes + Adds a #repeat block helper, similar to the built-in #each helper ## Comments This PR is to support the progress of #1212, #1214, and #1216. I'm creating this because as far as I am aware, there is not currently a way to iterate based on a Number in the existing set of handlebars helpers. Let me know if there's any improvements I can make to this! --------- Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
Adds a `to_string` custom handlebars helper. ## Comments There's not much to show for this one, it just converts a Number or Bool to a String Value. This isn't useful most of the time, as templating converts a variable to a string anyways. It's main use case is for comparing a number and a string. This is currently needed in #1214 and #1216, as although we can now iterate using the `repeat` helper, it produces Number Values, while `field_name`, which `@index` is compared against, is a String Value, which will always fail the `eq` test. This helper exists to resolve that issue. --------- Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
…ed` lint (#1216) Adds a witness hint for the `enum_tuple_variant_field_marked_deprecated` lint. ## Example `enum_tuple_variant_field_marked_deprecated` outputs the following witness hint for one of the `./test_crates/enum_tuple_variant_field_marked_deprecated/` tests. ```rust match value { enum_tuple_variant_field_marked_deprecated::TupleVariantEnum::TupleVariant (_, to_be_deprecated, _) => (), _ => (), } ``` This compiles on both versions, but demonstrates the issue with the deprecated field, and would emit an error if compiled. ## Commit Notes + Added witness hint for `enum_tuple_variant_field_marked_deprecated` + Added new parts to query for `enum_tuple_variant_field_marked_deprecated` to fetch relevant data for the witness ## Comments Once again, similar to #1214 I wasn't 100% sure on what to call the bound variable (`to_be_deprecated`) when destructuring the tuple, but I think this mostly works. Let me know if you think the name should get changed!
+ Added field_count + Removed baseline_field_names + Added repeat helper + Removed each helper + Added to_string helper + Replaced destructure with witness
Really just tying up a lot of loose ends today, this one should be good to go too I think! |
Adds a witness hint for the
enum_tuple_variant_field_missing
lint.Example
enum_tuple_variant_field_missing
outputs the following witness hint for the./test_crates/enum_tuple_variant_field_missing/
test.This compiles on the old version, but not on the new due to the now missing field in the tuple destructuring.
Commit Notes
enum_tuple_variant_field_missing
baseline_field_names
for extra witness dataComments
I could use some feedback on this one. I wasn't sure what to call the problem field, so I just called it
destructure
. Let me know if there would be a better name to call it, if anything at all. Second, in the tests there was something relating to#[doc(hidden)]
, which I wasn't too sure about if it was something I had to worry about or not. If someone could enlighten me on that, it would be appreciated.