Skip to content

Rust improvements #516

Closed
Closed

Description

@dvdsgl
  • Fix invalid JSON in header comments
  • Optionally emit top-level marshaling functions
  • Improve header comments
    • Only show how to deserialize JSON (no need to show going back to string)
    • Don't use extra empty lines between statements
    • Use actual top-level type names in sample
  • Optionally omit redundant rename attributes when property name and JSON name match (dense mode)

cc @krk @phrohdoh

Activity

  1. added
    good first issueNot necessarily easy, but doesn't require deep quicktype knowledge
    RustRust Output
    on Feb 13, 2018
  2. phrohdoh commented on Feb 13, 2018

    @phrohdoh

    The invalid JSON mentioned is here and should be let json = r#"{"answer": 42}"#;.

  3. added a commit that references this issue on Feb 13, 2018
  4. dvdsgl commented on Feb 13, 2018

    @dvdsgl
    MemberAuthor

    @phrohdoh would you like to submit a PR to improve the header comments? There are many quick wins there.

  5. Ryman commented on Feb 17, 2018

    @Ryman

    To add:

    • The serialization code part isn't copy-pasteable currently as it imports serde_json but that part actually requires serde_derive. It would work if they copied all of the code though so maybe that's okay, but I imagine some people may not know that they need to import serde_derive in their library code. Playpen example of it compiling with the change
    • It looks like the header comment improvements can be ticked off

    I'd submit a patch for the first point myself but when I cloned the repo and tried running tests without modification they took way too long on my machine (with only the rust fixtures). Unsure if that's a problem with my configuration or not but thought it's worth mentioning.

  6. dvdsgl commented on Feb 17, 2018

    @dvdsgl
    MemberAuthor

    @Ryman FIXTURE=rust npm test will generate and test a couple hundred Rust programs. Do individual tests take longer than expected or the entire test suite or both?

  7. schani commented on Feb 17, 2018

    @schani
    Member

    @dvdsgl Is it possible that we're downloading and re-compiling all Rust dependencies for each test case?

  8. Ryman commented on Feb 17, 2018

    @Ryman

    @Ryman FIXTURE=rust npm test will generate and test a couple hundred Rust programs. Do individual tests take longer than expected or the entire test suite or both?

    It was the entire rust test suit afaik, the first 4 or so tests ran... relatively quick then 20 or so more would take many many minutes more, I don't have access to my laptop where I can run it right now to check though. It definitely felt like it was compiling more than necessary.

  9. dvdsgl commented on Feb 17, 2018

    @dvdsgl
    MemberAuthor

    @Ryman the test slowness is fixed now

  10. Ryman commented on Feb 23, 2018

    @Ryman

    @dvdsgl Hey, sorry for the delay, I looked into the compile times a little and some of your generated types, when passed to serde are creating 40k+ lines of code (post macro expansion, try using cargo-expand if you want to see) with 30k of them being in a single method which rustc chokes badly on in translation (you can see this on a nightly compiler by setting RUSTFLAGS=-Ztime-passes. I had hoped to look into improving the codegen for serde and it seems to be a known problem on the issue tracker but I haven't been successful this week.

    I'd advise that you skip some of your tests such as this one unless you enable some "extra-tests" feature or something which CI would enable, it should make local development nicer :) Or maybe it could just be an error to try to quicktype pathalogical inputs? What do you think?

  11. dvdsgl commented on Feb 23, 2018

    @dvdsgl
    MemberAuthor

    @Ryman yes, thank you for the analysis and we agree that we need to split up some of our test data that needlessly require target languages to emit absurdly large types: #559

  12. schani commented on Aug 1, 2018

    @schani
    Member

    Closing this. But please keep submitting Rust PRs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RustRust Outputgood first issueNot necessarily easy, but doesn't require deep quicktype knowledge

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions