Skip to content

jsondoclint: False positive error when function return type is type alias #104851

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

Closed
aDotInTheVoid opened this issue Nov 25, 2022 · 2 comments · Fixed by #104879
Closed

jsondoclint: False positive error when function return type is type alias #104851

aDotInTheVoid opened this issue Nov 25, 2022 · 2 comments · Fixed by #104879
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 25, 2022

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

pub type Foo = i32;

pub fn demo() -> Foo {
    42
}

Produces json (abridged)

{
  "crate_version": null,
  "external_crates": {},
  "format_version": 23,
  "includes_private": false,
  "index": {
    "0:0:1568": {
      "id": "0:0:1568",
      "inner": {"is_crate": true, "is_stripped": false, "items": ["0:1:1565", "0:2:1566"]},
      "kind": "module",
      "name": "return_type_alias",
    },
    "0:1:1565": {
      "id": "0:1:1565",
      "inner": {"generics": {"params": [], "where_predicates": []}, "type": {"inner": "i32", "kind": "primitive"}},
      "kind": "typedef",
      "name": "Foo",
    },
    "0:2:1566": {
      "id": "0:2:1566",
      "inner": {
        "decl": {
          "c_variadic": false,
          "inputs": [],
          "output": {
            "inner": {"args": {"angle_bracketed": {"args": [], "bindings": []}}, "id": "0:1:1565", "name": "Foo"},
            "kind": "resolved_path"
          }
        },
        "generics": {"params": [], "where_predicates": []},
        "has_body": true,
        "header": {"abi": "Rust", "async": false, "const": false, "unsafe": false}
      },
      "kind": "function",
      "name": "demo",
      "span": {"begin": [6, 0], "end": [8, 1], "filename": "/home/nixon/dev/rust/rust/src/test/rustdoc-json/fns/return_type_alias.rs"},
      "visibility": "public"
    }
  },
  "paths": {
    "0:0:1568": {"crate_id": 0, "kind": "module", "path": ["return_type_alias"]},
    "0:1:1565": {"crate_id": 0, "kind": "typedef", "path": ["return_type_alias", "Foo"]},
    "0:2:1566": {"crate_id": 0, "kind": "function", "path": ["return_type_alias", "demo"]}
  },
  "root": "0:0:1568"
}

which is correct, but jsondoclint fails for this

---- [rustdoc-json] src/test/rustdoc-json/fns/return_type_alias.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/fns/return_type_alias/return_type_alias.json"
stdout: none
--- stderr -------------------------------
0:1:1565: Expected Struct or Enum or Union but found Typedef
Error: Errors validating json /home/nixon/dev/rust/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-json/fns/return_type_alias/return_type_alias.json
------------------------------------------

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

@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 25, 2022
@aDotInTheVoid
Copy link
Member Author

@rustbot claim

@aDotInTheVoid
Copy link
Member Author

This was found while working on #104064, as it causes jsondoclint to fail for core (in addition to it catching the linked issue)

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 25, 2022
… r=GuillaumeGomez

jsondoclint: Recognise Typedef as valid kind for Type::ResolvedPath

Closes rust-lang#104851

r? ``@GuillaumeGomez``

``@rustbot`` modify labels: +A-testsuite
@bors bors closed this as completed in eac8921 Nov 25, 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