Skip to content
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

jsondoclint: False Positive when useing enum variants #104942

Closed
aDotInTheVoid opened this issue Nov 26, 2022 · 0 comments · Fixed by #104943
Closed

jsondoclint: False Positive when useing enum variants #104942

aDotInTheVoid opened this issue Nov 26, 2022 · 0 comments · Fixed by #104943
Assignees
Labels
A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@aDotInTheVoid
Copy link
Member

aDotInTheVoid commented Nov 26, 2022

jsondoclint currently believes that the item kind's that can appear behind a use are the same as the items that can appear in a mod.

This isn't true, eg

#![feature(no_core)]
#![no_core]

pub enum AlwaysNone {
    None,
}

pub use AlwaysNone::None;

Produces (abridged)

{
  "index": {
    "0:0:1566": {
      "id": "0:0:1566",
      "inner": {"is_crate": true, "is_stripped": false, "items": ["0:1:1565", "0:4"]},
      "kind": "module",
      "name": "use_variant"
    },
    "0:1:1565": {
      "id": "0:1:1565",
      "inner": {"generics": {"params": [], "where_predicates": []}, "impls": [], "variants": ["0:2:173"], "variants_stripped": false},
      "kind": "enum",
      "name": "AlwaysNone"
    },
    "0:2:173": {
      "id": "0:2:173",
      "inner": {"variant_inner": null, "variant_kind": "plain"},
      "kind": "variant",
      "name": "None"
    },
    "0:4": {
      "id": "0:4",
      "inner": {"glob": false, "id": "0:2:173", "name": "None", "source": "AlwaysNone::None"},
      "kind": "import",
      "name": null
    }
  },
  "root": "0:0:1566"
}

Causing error

---- [rustdoc-json] src/test/rustdoc-json/enums/use_variant.rs stdout ----

error: jsondoclint failed!
status: exit status: 1
command: "/home/nixon/dev/rust/rust/build/x86_64-unknown-linux-gnu/stage0-tools-bin/jsondoclint" "/home/nixon/dev/rust/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/enums/use_variant/use_variant.json"
stdout: none
--- stderr -------------------------------
0:2:173: Expected Module inner item but found Variant (found at ["$.index[\"0:1:1565\"].inner.variants[0]", "$.index[\"0:2:173\"].id", "$.index[\"0:4\"].inner.id"])
Error: Errors validating json /home/nixon/dev/rust/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/enums/use_variant/use_variant.json
------------------------------------------

A similar case occors for glob importing enums

#![feature(no_core)]
#![no_core]

pub enum Color {
    Red,
    Green,
    Blue,
}

pub use Color::*;
{
  "crate_version": null,
  "external_crates": {},
  "format_version": 23,
  "includes_private": false,
  "index": {
    "0:0:1569": {
      "id": "0:0:1569",
      "inner": {"is_crate": true, "is_stripped": false, "items": ["0:1:1565", "0:8"]},
      "kind": "module",
      "name": "use_glob",
      "visibility": "public"
    },
    "0:1:1565": {
      "id": "0:1:1565",
      "inner": {
        "variants": ["0:2:1566", "0:4:1567", "0:6:1568"]
      },
      "kind": "enum",
      "name": "Color",
      "visibility": "public"
    },
    "0:2:1566": {
      "id": "0:2:1566",
      "inner": {"variant_inner": null, "variant_kind": "plain"},
      "kind": "variant",
      "name": "Red",
      "visibility": "default"
    },
    "0:4:1567": {
      "id": "0:4:1567",
      "inner": {"variant_inner": null, "variant_kind": "plain"},
      "kind": "variant",
      "name": "Green",
      "visibility": "default"
    },
    "0:6:1568": {
      "id": "0:6:1568",
      "inner": {"variant_inner": null, "variant_kind": "plain"},
      "kind": "variant",
      "name": "Blue",
      "visibility": "default"
    },
    "0:8": {
      "id": "0:8",
      "inner": {"glob": true, "id": "0:1:1565", "name": "Color", "source": "Color"},
      "kind": "import",
      "name": null,
      "visibility": "public"
    }
  },
  "root": "0:0:1569"
}

errors with

---- [rustdoc-json] src/test/rustdoc-json/enums/use_glob.rs stdout ----

error: jsondoclint failed!
status: exit status: 1
command: "/home/nixon/dev/rust/rust/build/x86_64-unknown-linux-gnu/stage0-tools-bin/jsondoclint" "/home/nixon/dev/rust/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/enums/use_glob/use_glob.json"
stdout: none
--- stderr -------------------------------
0:1:1565: Expected Module but found Enum
Error: Errors validating json /home/nixon/dev/rust/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/enums/use_glob/use_glob.json
------------------------------------------

@rustbot modify labels: +A-rustdoc-json +A-testsuite +T-rustdoc

@rustbot claim

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 26, 2022
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Nov 26, 2022
…, r=GuillaumeGomez

jsondoclint: Handle using enum variants and glob using enums.

More work on jsondoclint for `core.json`

Closes rust-lang#104942

r? `@GuillaumeGomez`

`@rustbot` modify labels: +A-testsuite
@bors bors closed this as completed in ed0f097 Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants