Skip to content

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

Open
@makspll

Description

@makspll

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-jsonArea: Rustdoc JSON backendC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleT-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