Open
Description
This code:
trait Private{}
pub fn takes_dyn_private(_: &dyn Private) {}
Fails to validate with jsondoclint
failures:
---- [rustdoc-json] tests/rustdoc-json/traits/private_dyn.rs stdout ----
error: jsondoclint failed!
status: exit status: 1
command: "/home/gh-aDotInTheVoid/rust/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondoclint" "/home/gh-aDotInTheVoid/rust/build/aarch64-unknown-linux-gnu/test/rustdoc-json/traits/private_dyn/private_dyn.json"
stdout: none
--- stderr -------------------------------
0:3:1771 not in index or paths, but referred to at '$.index["0:4:1772"].inner.function.decl.inputs[0][1].borrowed_ref.type.dyn_trait.traits[0].trait.id'
Error: Errors validating json /home/gh-aDotInTheVoid/rust/build/aarch64-unknown-linux-gnu/test/rustdoc-json/traits/private_dyn/private_dyn.json
------------------------------------------
The function's JSON is right:
"0:4:1772": {
"inner": {
"function": {
"decl": {
"c_variadic": false,
"inputs": [
[
"_",
{
"borrowed_ref": {
"lifetime": null,
"mutable": false,
"type": {
"dyn_trait": {
"lifetime": null,
"traits": [{"trait": {"id": "0:3:1771", "name": "Private"}}]
}
}
}
}
]
],
"output": null
},
"generics": {"where_predicates": []},
"has_body": true,
"header": {"abi": "Rust", "async": false, "const": false, "unsafe": false}
}
},
"name": "takes_dyn_private"
},
but we don't include the trait as it's private.
This is a similar to #113674, where a private (not just unreachable, but private at definition site) item is in the public API.
This does trigger a warning, but is accepted
warning: trait `Private` is more private than the item `takes_dyn_private`
--> src/lib.rs:4:1
|
4 | pub fn takes_dyn_private(_: &dyn Private) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `takes_dyn_private` is reachable at visibility `pub`
|
note: but trait `Private` is only usable at visibility `pub(crate)`
--> src/lib.rs:3:1
|
3 | trait Private{}
| ^^^^^^^^^^^^^
= note: `#[warn(private_interfaces)]` on by default