Skip to content

Invalid JSON for ast-json #71086

Closed
Closed
@ehuss

Description

@ehuss
Contributor

The JSON for -Zast-json is broken because the id field for attributes serializes to nothing.

An empty library produces the following:

{"module":{"inner":{"lo":0,"hi":0},"items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":3,"args":null}]},"args":"Empty"}]},"id":,"style":"Outer","span":{"lo":0,"hi":0}}],"id":4,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":5,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":6,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":7,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":8,"args":null}]},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":9,"args":null}]},"args":"Empty"}]},"id":,"style":"Outer","span":{"lo":0,"hi":0}}],"id":10,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[],"span":{"lo":0,"hi":0},"proc_macros":[]}

The important bit "id":, which is clearly not valid JSON.

It looks like the AttrId serialization was removed in #70215.

I'm not sure what a solution is here. I'm guessing AST serialization is used elsewhere, where this field isn't needed. I'm not too familiar with rustc_serialize, so I'm not sure if it has something equivalent to #[serde(skip)].

rustc 1.44.0-nightly (b543afca9 2020-04-05)

cc @petrochenkov

This issue has been assigned to @JOE1994 via this comment.

Activity

added
requires-nightlyThis issue requires a nightly compiler in some way.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Apr 13, 2020
petrochenkov

petrochenkov commented on Apr 16, 2020

@petrochenkov
Contributor

Looks like the encoding/decoding change from #70215 needs to be reverted.
Reverting should be ok because emit_unit and read_nil don't do anything anyway (at least when inlined) during metadata encoding and decoding.

The change is trivial, so marking this as E-easy, but if it's not done until the weekend I'll submit the PR myself.

added
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-help-wantedCall for participation: Help is requested to fix this issue.
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
on Apr 16, 2020
JOE1994

JOE1994 commented on Apr 17, 2020

@JOE1994
Contributor

@rustbot claim

self-assigned this
on Apr 17, 2020
added 3 commits that reference this issue on Apr 20, 2020

Rollup merge of rust-lang#71284 - JOE1994:serialize_id, r=petrochenkov

c4d1bd6

Rollup merge of rust-lang#71284 - JOE1994:serialize_id, r=petrochenkov

9942aa6

Rollup merge of rust-lang#71284 - JOE1994:serialize_id, r=petrochenkov

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @ehuss@jonas-schievink@petrochenkov@JOE1994@rustbot

    Issue actions

      Invalid JSON for ast-json · Issue #71086 · rust-lang/rust