-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustdoc-json: Don't ignore impls for primitive types #88234
Conversation
60cf60c
to
4654c95
Compare
Looking back it's unclear to me what problem this is solving. |
|
4654c95
to
19f87f6
Compare
#87073 has been merged, so this is no longer blocked :) |
850b851
to
5177fe7
Compare
I found a weird behavior with By running #![feature(doc_primitive)]
#[doc(primitive = "char")]
mod char {}
{
"id": "0:0",
"crate_id": 0,
"name": "foo",
"span": {
"filename": "src/lib.rs",
"begin": [
1,
0
],
"end": [
3,
11
]
},
"visibility": "public",
"docs": null,
"links": {},
"attrs": [
"#![feature(doc_primitive)]"
],
"deprecation": null,
"kind": "module",
"inner": {
"is_crate": true,
"items": [
"0:3" // I assume this refers to `char` module but it's private
]
}
} while |
aaad690
to
ce9ab9e
Compare
Added |
This comment has been minimized.
This comment has been minimized.
ce9ab9e
to
f81c3fd
Compare
|
||
#![feature(doc_primitive)] | ||
#[doc(primitive = "usize")] | ||
mod usize {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also test the behavior when the primitive is only defined in libstd, not the current crate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests to check crate_id
of methods of usize
does not match to local crate's. We cannot check if they come from libstd because the std
module item is not in the index, but hope it suffices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests to check crate_id of methods of usize does not match to local crate's.
In that case, this mod usize
is doing nothing and should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc(primitive)
requires an item to be defined right after itself, so we need this meaningless mod usize
like we do in library/std/src/primitive_docs.rs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, my point is that doc(primitive)
is doing nothing. If it's using the methods in libstd then whether the docs come from this crate or libstd doesn't matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'm not sure this is the right approach at all - the original problem was that documenting libcore wouldn't show the primitive impls, right? but we don't want to show them on all crates unconditionally, only crates where the primitive is documented.
Sure, that seems useful. How were primitives being handled before? I'm surprised it didn't ICE trying to document the primitives in libstd. |
Definitions of primitive types themselves were not indexed, unlike those of user-defined ADTs. Impls for primitive types were not indexed, too (They'll be indexed after this patch). |
f81c3fd
to
2f4af7b
Compare
Ok. Shouldn't those definitions be indexed too? It seems strange to show only the impls and not the primitives themselves. |
IIRC |
@hkmatsumoto right, but primitives aren't documented through lang_items. They're documented through |
2f4af7b
to
cb7c821
Compare
cb7c821
to
e18a8ef
Compare
With this code: #![feature(doc_primitive)]
#[doc(primitive = "usize")]
mod foo {}
{
"id": "0:0",
"crate_id": 0,
"name": "primitive",
"span": {
"filename": "src/lib.rs",
"begin": [
1,
0
],
"end": [
4,
11
]
},
"visibility": "public",
"docs": null,
"links": {},
"attrs": [
"#![feature(doc_primitive)]"
],
"deprecation": null,
"kind": "module",
"inner": {
"is_crate": true,
"items": [
"0:3"
]
}
}
{
"id": "0:3",
"crate_id": 0,
"name": "usize",
"span": {
"filename": "src/lib.rs",
"begin": [
4,
0
],
"end": [
4,
10
]
},
"visibility": "crate",
"docs": null,
"links": {},
"attrs": [
"#[doc(primitive = \"usize\")]"
],
"deprecation": null,
"kind": "primitive_type",
"inner": "usize"
} The modules are showing up. |
@bors r+ |
📌 Commit e18a8ef has been approved by |
…tive, r=jyn514 rustdoc-json: Don't ignore impls for primitive types Fix the issue discussed at [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.E2.9C.94.20Json.20output.20lacks.20some.20item.20which.20are.20supposed.20to.20be.20there) r? `@jyn514`
…arth Rollup of 12 pull requests Successful merges: - rust-lang#87631 (os current_exe using same approach as linux to get always the full ab…) - rust-lang#88234 (rustdoc-json: Don't ignore impls for primitive types) - rust-lang#88651 (Use the 64b inner:monotonize() implementation not the 128b one for aarch64) - rust-lang#88816 (Rustdoc migrate to table so the gui can handle >2k constants) - rust-lang#89244 (refactor: VecDeques PairSlices fields to private) - rust-lang#89364 (rustdoc-json: Encode json files with UTF-8) - rust-lang#89423 (Fix ICE caused by non_exaustive_omitted_patterns struct lint) - rust-lang#89426 (bootstrap: add config option for nix patching) - rust-lang#89462 (haiku thread affinity build fix) - rust-lang#89482 (Follow the diagnostic output style guide) - rust-lang#89504 (Don't suggest replacing region with 'static in NLL) - rust-lang#89535 (fix busted JavaScript in error index generator) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fix the issue discussed at Zulip
r? @jyn514