rust-lang / rust-lang/rust

Rustdoc with `--output-format json` Impls not showing up in module they're defined in, only on the trait they're implementing

Open
#118,497 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-rustdoc-json C-bug E-needs-mcve T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
Running

	rustup install nightly-${NIGHTLY_VERSION}
	git clone https://github.com/bevyengine/bevy --branch v0.11.2 --depth 1 ./tmp/bevy || true
	cd ./tmp/bevy && RUSTDOCFLAGS="--document-hidden-items --document-private-items  -Zunstable-options  --output-format json" rustup run nightly-${NIGHTLY_VERSION} cargo doc --all-features --workspace 

Tried with: nightly 2023-11-29

Bevy contains a bevy_reflect::impls::glam module which contains a bunch of impls for Reflect and related types, let's take Vec3 and its impl as an example:

Vec3 Reflect impl all mentioned json is inside the bevy_reflect.json file

        "0:4436": {
            "id": "0:4436",
            "crate_id": 0,
            "name": null,
            "span": {
                "filename": "crates/bevy_reflect/src/impls/glam.rs",
                "begin": [
                    70,
                    0
                ],
                "end": [
                    78,
                    1
                ]
            },
            "visibility": "default",
            "docs": null,
            "links": {},
            "attrs": [],
            "deprecation": null,
            "inner": {
                "impl": {
                    "is_unsafe": false,
                    "generics": {
                        "params": [],
                        "where_predicates": [
                            {
                                "bound_predicate": {
                                    "type": {
                                        "primitive": "f32"
                                    },
                                    "bounds": [
                                        {
                                            "trait_bound": {
                                                "trait": {
                                                    "name": "bevy_reflect::FromReflect",
                                                    "id": "0:131:2096",
                                                    "args": {
                                                        "angle_bracketed": {
                                                            "args": [],
                                                            "bindings": []
                                                        }
                                                    }
                                                },
                                                "generic_params": [],
                                                "modifier": "none"
                                            }
                                        }
                                    ],
                                    "generic_params": []
                                }
                            }
                        ]
                    },
                    "provided_trait_methods": [
                        "serializable",
                        "debug",
                        "reflect_partial_eq",
                        "is_dynamic",
                        "reflect_hash"
                    ],
                    "trait": {
                        "name": "Reflect",
                        "id": "0:581:2099",
                        "args": {
                            "angle_bracketed": {
                                "args": [],
                                "bindings": []
                            }
                        }
                    },
                    "for": {
                        "resolved_path": {
                            "name": "Vec3",
                            "id": "52:12378:2126",
                            "args": {
                                "angle_bracketed": {
                                    "args": [],
                                    "bindings": []
                                }
                            }
                        }
                    },
                    "items": [
                        "0:4437:1644",
                        "0:4438:2323",
                        "0:4439:2666",
                        "0:4440:2667",
                        "0:4441:2668",
                        "0:4442:2408",
                        "0:4443:2411",
                        "0:4444:2669",
                        "0:4445:2632",
                        "0:4446:2671",
                        "0:4447:2165",
                        "0:4449:2157",
                        "0:4450:2672",
                        "0:4451:2673",
                        "0:4452:2199",
                        "0:4453:578"
                    ],
                    "negative": false,
                    "synthetic": false,
                    "blanket_impl": null
                }
            }
        },

Which is referenced only in a single place i.e. the trait:

        "0:581:2099": {
            "id": "0:581:2099",
            "crate_id": 0,
            "name": "Reflect",
            "span": {
                "filename": "crates/bevy_reflect/src/reflect.rs",
                "begin": [
                    75,
                    0
                ],
                "end": [
                    242,
                    1
                ]
            },
            "visibility": "public",
            "docs": "The core trait of [`bevy_reflect`], used for accessing and modifying data dynamically.\n\nIt's recommended to use the [derive macro] rather than manually implementing this trait.\nDoing so will automatically implement many other useful traits for reflection,\nincluding one of the appropriate subtraits: [`Struct`], [`TupleStruct`] or [`Enum`].\n\nSee the [crate-level documentation] to see how this trait and its subtraits can be used.\n\n[`bevy_reflect`]: crate\n[derive macro]: bevy_reflect_derive::Reflect\n[crate-level documentation]: crate",
            "links": {
                "`Struct`": "0:643:2103",
                "crate": "0:0:2140",
                "bevy_reflect_derive::Reflect": "20:729:2099",
                "`TupleStruct`": "0:886:2104",
                "`Enum`": "0:1723:2401"
            },
            "attrs": [],
            "deprecation": null,
            "inner": {
                "trait": {
                    "is_auto": false,
                    "is_unsafe": false,
                    "items": [
                        "0:582:1644",
                        "0:583:2323",
                        "0:584:2666",
                        "0:585:2667",
                        "0:586:2668",
                        "0:587:2408",
                        "0:588:2411",
                        "0:589:2669",
                        "0:590:2165",
                        "0:591:2671",
                        "0:592:2157",
                        "0:593:2672",
                        "0:594:2673",
                        "0:595:2632",
                        "0:596:2430",
                        "0:597:2199",
                        "0:598:578",
                        "0:599:3365",
                        "0:600:2676"
                    ],
                    "generics": {
                        "params": [],
                        "where_predicates": []
                    },
                    "bounds": [
                        {
                            "trait_bound": {
                                "trait": {
                                    "name": "DynamicTypePath",
                                    "id": "0:1016:3270",
                                    "args": {
                                        "angle_bracketed": {
                                            "args": [],
                                            "bindings": []
                                        }
                                    }
                                },
                                "generic_params": [],
                                "modifier": "none"
                            }
                        },
                        {
                            "trait_bound": {
                                "trait": {
                                    "name": "Any",
                                    "id": "2:3447:71",
                                    "args": {
                                        "angle_bracketed": {
                                            "args": [],
                                            "bindings": []
                                        }
                                    }
                                },
                                "generic_params": [],
                                "modifier": "none"
                            }
                        },
                        {
                            "trait_bound": {
                                "trait": {
                                    "name": "Send",
                                    "id": "2:2814:249",
                                    "args": {
                                        "angle_bracketed": {
                                            "args": [],
                                            "bindings": []
                                        }
                                    }
                                },
                                "generic_params": [],
                                "modifier": "none"
                            }
                        },
                        {
                            "trait_bound": {
                                "trait": {
                                    "name": "Sync",
                                    "id": "2:2831:259",
                                    "args": {
                                        "angle_bracketed": {
                                            "args": [],
                                            "bindings": []
                                        }
                                    }
                                },
                                "generic_params": [],
                                "modifier": "none"
                            }
                        }
                    ],
                    "implementations": [
                        "0:4612",
                        "0:5096",
                        "0:6973",
                        "0:6489",
                        "0:6728",
                        "0:1466",
                        "0:5465",
                        "0:6518",
                        "0:3487",
                        "0:5776",
                        "0:6693",
                        "0:5426",
                        "0:5396",
                        "0:5662",
                        "0:4152",
                        "0:2977",
                        "0:1693",
                        "0:4788",
                        "0:6344",
                        "0:6763",
                        "0:1436",
                        "0:6148",
                        "0:5510",
                        "0:4524",
                        "0:5700",
                        "0:7008",
                        "0:207",
                        "0:6658",
                        "0:2855",
                        "0:5141",
                        "0:1531",
                        "0:5009",
                        "0:3205",
                        "0:6306",
                        "0:4833",
                        "0:6080",
                        "0:5270",
                        "0:2717",
                        "0:6798",
                        "0:5335",
                        "0:1560",
                        "0:2757",
                        "0:2913",
                        "0:1592",
                        "0:5366",
                        "0:3593",
                        "0:6458",
                        "0:51",
                        "0:1376",
                        "0:6004",
                        "0:5966",
                        "0:7258",
                        "0:4701",
                        "0:6903",
                        "0:4105",
                        "0:4344",
                        "0:6553",
                        "0:6382",
                        "0:5738",
                        "0:3387",
                        "0:7175",
                        "0:6114",
                        "0:4569",
                        "0:4393",
                        "0:7519",
                        "0:6228",
                        "0:4480",
                        "0:5852",
                        "0:2803",
                        "0:3293",
                        "0:6938",
                        "0:5624",
                        "0:6588",
                        "0:725",
                        "0:1270",
                        "0:5227",
                        "0:7049",
                        "0:5814",
                        "0:843",
                        "0:6042",
                        "0:5548",
                        "0:5890",
                        "0:4656",
                        "0:6268",
                        "0:4436",
                        "0:327",
                        "0:953",
                        "0:4964",
                        "0:5052",
                        "0:3123",
                        "0:4296",
                        "0:4249",
                        "0:5184",
                        "0:6623",
                        "0:6868",
                        "0:7107",
                        "0:5928",
                        "0:4200",
                        "0:6420",
                        "0:5586",
                        "0:6183",
                        "0:6833",
                        "0:5304",
                        "0:4920",
                        "0:4876",
                        "0:4744",
                        "0:3047"
                    ]
                }
            }
        },

But the actual module these impls come from, has no items inside it at all:

        "0:1211:1777": {
            "id": "0:1211:1777",
            "crate_id": 0,
            "name": "glam",
            "span": {
                "filename": "crates/bevy_reflect/src/impls/glam.rs",
                "begin": [
                    1,
                    0
                ],
                "end": [
                    275,
                    52
                ]
            },
            "visibility": {
                "restricted": {
                    "parent": "0:1210:2088",
                    "path": "::impls"
                }
            },
            "docs": null,
            "links": {},
            "attrs": [
                "#[cfg(feature = \"glam\")]"
            ],
            "deprecation": null,
            "inner": {
                "module": {
                    "is_crate": false,
                    "items": [],
                    "is_stripped": false
                }
            }

Expected behaviour:
I would have expected the impls to be mentioned in BOTH the module items and the trait impls

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided nightly rustdoc command against Bevy v0.11.2. Compare the JSON entries for crates/bevy_reflect/src/impls/glam.rs and crates/bevy_reflect/src/reflect.rs, then trace rustdoc's module and implementation handling; done means the impl is represented in the module where it is defined as well as on the implemented trait.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.