Stream: contributing

Topic: ✔ Formatter Node question


view this post on Zulip Anthony Bullard (Dec 22 2024 at 01:52):

What are these and what is there purpose? And why to parts of a type annotation get turned into a Node sequence where somethings that are NOT literals, get turned into literals? I see this for a type annotation of a record type

NodeSpaces { before: [], item: Sequence(Literal("siblingIds"), [(Sp { default_space: true, comments: [] }, Literal(":")), (Sp { default_space: true, comments: [] }, TypeAnnotation(Apply("", "List", [@318-321 Apply("", "U64", [])])))]), after: [] }

view this post on Zulip Anthony Bullard (Dec 22 2024 at 01:55):

To snakify this requires doing some gnarly threading of the migration flags into logic about turning the RequiredValue (and others) into a Node

view this post on Zulip Anthony Bullard (Dec 22 2024 at 12:28):

Ok, I think the borrow checker has defeated me. Doing what is necessary here seems to require some pretty sizable changes - or I just need more borrow-checker-fu

view this post on Zulip Anthony Bullard (Dec 22 2024 at 12:34):

The problem TLDR:

We have an AST node (a Loc<RequiredValue<TypeAnnotation>>) that right now is being turned into a Node sequence. It is in that Node sequence that I need to snakify the identifier if the migrate flag is on.

I have two options:

  1. Snakify the ident by cloning the original and doing the snakification. But that requires creating a new Buf that will be dropped and that causes a borrowing violation.
  2. Having the snakification happen when we create the Literal Node for the identifier. Same problem - it has to create a new Buf to create the new ident string and their is a dangling value.

I've tried all manners of lifetime combinations (and ellisions) and cloning. I am not going to give up, but if anyone has any pointers I'd be very appreciative

view this post on Zulip Anthony Bullard (Dec 22 2024 at 13:38):

UPDATE: I DEFEATED THE BORROW CHECKER BACK

view this post on Zulip Notification Bot (Dec 23 2024 at 11:55):

Anthony Bullard has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC