Skip to content

Syntactically invalid JSON from -Z ast-json #54880

Closed as not planned
Closed as not planned
@dtolnay

Description

@dtolnay

The JSON emitted for the following AST is not legal JSON.

struct Struct;
trait Trait {}

macro_rules! impl_trait_for {
    ($s:ident) => {
        impl Trait for $s {}
    };
}

impl_trait_for!(Struct);

To reproduce:

rustc repro.rs -Z ast-json | rg ',]'

With indentation added, part of the JSON output looks like this. The problem is with the last , in this snippet.

{
  "variant": "Token",
  "fields": [
    {
      "lo": 104,
      "hi": 106
    },
    {
      "variant": "Interpolated",
      "fields": [
        [
          {
            "variant": "NtIdent",
            "fields": [
              "Struct",
              false
            ]
          },
        ]
      ]
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions