Skip to content

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

Closed
@aDotInTheVoid

Description

@aDotInTheVoid
#![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

Metadata

Metadata

Assignees

Labels

A-rustdoc-jsonArea: Rustdoc JSON backendA-testsuiteArea: The testsuite used to check the correctness of rustcT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions