rustdoc-json: Rename Path::name to path, and give it the path again. by aDotInTheVoid · Pull Request #135799 · rust-lang/rust (original) (raw)

we cannot change paths.path from absolute path to public facing path because it is required for generating source URLs by rustdoc and other crates.

Sorry, I wasn't clear. What I meant was

For the code:

#![no_std]

pub type Foo = core::str::SplitAsciiWhitespace<'static>;

The json output will be

{ "index": { "0": { "id": 0, "inner": { "type_alias": { "generics": {"params": [], "where_predicates": []}, "type": { "resolved_path": { "args": {"angle_bracketed": {"args": [{"lifetime": "'static"}], "constraints": []}}, "id": 1, "name": "SplitAsciiWhitespace" } } } }, "name": "Foo" }, "2": { "id": 2, "inner": {"module": {"is_crate": true, "is_stripped": false, "items": [0]}}, "name": "mcve" } }, "paths": { "0": {"crate_id": 0, "kind": "type_alias", "path": ["mcve", "Foo"]}, "1": {"crate_id": 1, "kind": "struct", "path": ["core", "str", "iter", "SplitAsciiWhitespace"]} }, "root": 2 }

Here, "path": ["core", "str", "iter", "SplitAsciiWhitespace"] was refered as path.path. I said it because this field is in ItemSummary struct which is constructed from Cache here which is used by HTML backend to get the absolute path i.e. "core", "str", "iter", "SplitAsciiWhitespace" as per above example to get the URL for source file that would be core/str/iter.rs.html and I thought of replacing this path with public facing path that would be core::str::SplitAsciiWhitespace but then thought absolute path could also be important for other libaries (like i am building cargo-wiki) to use this absolute path to generate URL on docs.rs or some other mechanism they might want.

I hope I made it clear but if not please ask me, I might be wrong so please let me know.