rustdoc-json: `impl dyn Trait` gets discarded
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
For the following code:
pub trait T1 {
fn number(&self) -> i32;
}
impl dyn T1 {
pub fn number_plus_one(&self) {
self.number() + 1
}
}
generates
{
"format_version": 36,
"includes_private": false,
"index": {
"0": {
"attrs": [],
"crate_id": 0,
"deprecation": null,
"docs": null,
"id": 0,
"inner": {"function": { ... }},
"name": "number",
"visibility": "default"
},
"1": {
"attrs": [],
"crate_id": 0,
"deprecation": null,
"docs": null,
"id": 1,
"inner": {
"trait": {
"bounds": [],
"generics": {"params": [], "where_predicates": []},
"implementations": [],
"is_auto": false,
"is_dyn_compatible": true,
"is_unsafe": false,
"items": [0]
}
},
"name": "T1",
"visibility": "public"
},
"2": {
"attrs": [],
"crate_id": 0,
"deprecation": null,
"docs": null,
"id": 2,
"inner": {"module": {"is_crate": true, "is_stripped": false, "items": [1]}},
"name": "on_dyn_trait",
"visibility": "public"
}
},
"root": 2
}
(full).
There's nothing included for the number_plus_one method, but there should be.
The HTML backend get this right, so the releavent info is availible in clean:
I'm not sure what's the best way to store this is in the format: Putting it into the implementations field seems wrong, as impl dyn T1 isn't an implementation of T1, but an implementation on dyn T1. I'd love to hear people's thoughts on this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the rustdoc JSON backend with the HTML backend and inspecting the clean data available for impl dyn Trait. Determine how an inherent impl on a dyn trait should be represented in the format, then verify that number_plus_one appears in generated JSON without incorrectly treating the impl as a trait implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100