Stream: rustdoc

Topic: doc(primitive)


view this post on Zulip Joshua Nelson (Jul 06 2021 at 01:01):

ahhhhh why is doc(primitive) stable

view this post on Zulip Joshua Nelson (Jul 06 2021 at 01:01):

this is literally useless to everyone except the standard library

view this post on Zulip Joshua Nelson (Jul 06 2021 at 01:02):

all the way back to 1.0 :(

view this post on Zulip Joshua Nelson (Jul 06 2021 at 02:51):

omg I think I found why primitives always link to doc.rust-lang.org even when they shouldn't

view this post on Zulip Joshua Nelson (Jul 06 2021 at 02:52):

fn links() in clean/types.rs completely skips the call to href() for primitives

view this post on Zulip Joshua Nelson (Jul 06 2021 at 02:53):

I think fixing https://github.com/rust-lang/rust/issues/73423 will also fix https://github.com/rust-lang/rust/issues/79630 and https://github.com/rust-lang/rust/issues/83083 at the same time

view this post on Zulip Joshua Nelson (Jul 06 2021 at 02:56):

hmm ok so let me think about this

view this post on Zulip Joshua Nelson (Jul 06 2021 at 02:56):

rustdoc's idea of "primitive" is strictly more general than the compiler's

view this post on Zulip Joshua Nelson (Jul 06 2021 at 02:56):

so most primitives have a DefId, but not all

view this post on Zulip Joshua Nelson (Jul 06 2021 at 02:57):

I wonder if PrimitiveType should use the DefId of the module used with doc(primitive) instead?

view this post on Zulip Joshua Nelson (Jul 06 2021 at 02:58):

aghh I keep causing myself bugs https://github.com/rust-lang/rust/pull/86737 caused rustdoc to be documented without --document-private-items

view this post on Zulip Joshua Nelson (Jul 06 2021 at 02:59):

https://github.com/rust-lang/rust/issues/86900

view this post on Zulip Joshua Nelson (Jul 06 2021 at 03:01):

ok perfect yes I can iterate through krate.primitives to find the DefId of the module where it's documented

view this post on Zulip Joshua Nelson (Jul 06 2021 at 03:01):

whew what a mess

view this post on Zulip Joshua Nelson (Jul 06 2021 at 03:16):

Joshua Nelson said:

whew what a mess

no kidding

            // FIXME: this is both quadratic, expensive, and called a whole bunch.
            // Instead, the cache should populate `primitive_locations` early (right now it only calls populate after this pass).
            // FIXME: it's just embarassing how much work this redoes
            Res::Primitive(prim) => {
                let mut externs = cx.tcx.crates(()).into_iter().map(|crate_num| ExternalCrate { crate_num }).collect();
                externs.sort_unstable();
                for &e in externs.iter().rev() {
                    for &(def_id, other_prim) in &e.primitives(tcx) {
                        if prim == other_prim {
                            return Some(def_id);
                        }
                    }
                }
                let primitives = ExternalCrate { crate_num: LOCAL_CRATE }.primitives(cx.tcx);
                for (def_id, other_prim) in primitives {
                    if prim == other_prim {
                        return Some(def_id);
                    }
                }
                None
            }

view this post on Zulip Joshua Nelson (Jul 06 2021 at 03:33):

omg there's just bug after bug, href() doesn't work for doc(primitive) modules because they're private

view this post on Zulip Joshua Nelson (Jul 06 2021 at 03:42):

... and also because it doesn't record them in paths or external_paths

view this post on Zulip Joshua Nelson (Jul 06 2021 at 03:42):

sometimes I really want to throw out rustdoc and rewrite it from scratch I swear

view this post on Zulip GuillaumeGomez (Jul 06 2021 at 08:21):

Oh boy. You found more bugs XD. Rewriting rustdoc from scrath would certainly be more work than slowly fixing bugs haha

view this post on Zulip GuillaumeGomez (Jul 06 2021 at 12:40):

If that can make you feel better, I found bugs in reexported items visibility :)

view this post on Zulip Joshua Nelson (Jul 06 2021 at 12:50):

@GuillaumeGomez you mean https://github.com/rust-lang/rust/issues/64762 ? Or something else?

view this post on Zulip GuillaumeGomez (Jul 06 2021 at 13:01):

No, something else. Still from https://github.com/rust-lang/rust/pull/86841. When you use pub(crate) or equivalents, they don't show up even if you use --document-private-items. So I fixed that, then I realized they took the visibility of the item from its location and not from its reexport, so I fixed that as well

view this post on Zulip GuillaumeGomez (Jul 06 2021 at 13:01):

I'm updating the tests currently

view this post on Zulip GuillaumeGomez (Jul 06 2021 at 13:01):

luckily it didn't require much changes...

view this post on Zulip GuillaumeGomez (Jul 06 2021 at 13:13):

Oh and we had an inconsistency with the display of visibility for typedefs

view this post on Zulip GuillaumeGomez (Jul 06 2021 at 13:13):

This PR is a rabbit hole XD

view this post on Zulip Joshua Nelson (Jul 11 2021 at 02:44):

apparently this is currently broken because my hack comes up with the core::str_prim module and the cache.populate call comes up with std::str_prim

view this post on Zulip Joshua Nelson (Jul 11 2021 at 02:44):

maybe I should just feed cache through

view this post on Zulip Joshua Nelson (Jul 11 2021 at 06:09):

so I don't forget: I have this working in https://github.com/rust-lang/rust/compare/master...jyn514:primitive-docs, I need to clean it up and see the results of https://github.com/rust-lang/rust/pull/87050

view this post on Zulip Joshua Nelson (Jul 12 2021 at 00:49):

https://github.com/rust-lang/rust/pull/87073

view this post on Zulip Joshua Nelson (Jul 12 2021 at 00:53):

whew that was crazy

view this post on Zulip Joshua Nelson (Jul 12 2021 at 00:53):

I think this is enough rust for me this weekend lol

view this post on Zulip Joshua Nelson (Jul 12 2021 at 00:56):

cc @Taylor Yu [they/she] , you seemed interested :)

view this post on Zulip Taylor Yu [they/she] (Jul 12 2021 at 03:49):

wow that is amazing!

view this post on Zulip Joshua Nelson (Jul 12 2021 at 04:06):

Thank you! It took ages haha

view this post on Zulip Joshua Nelson (Jul 13 2021 at 23:22):

most cursed x.py invocation I've used in a while
x test src/tools/linkchecker --stage 2 --keep-stage-std 0 --keep-stage-std 1


Last updated: Oct 11 2021 at 22:34 UTC