Stream: rustdoc

Topic: ✔ Debugging Rustdoc


view this post on Zulip inquisitivecrystal (Aug 01 2021 at 03:53):

Hi! Possibly stupid question: how do I get output from dbg! invocations within rustdoc?

view this post on Zulip inquisitivecrystal (Aug 01 2021 at 04:03):

I got it to work, but it's a bit unpleasant. I have to manually specify the library paths at the moment.

view this post on Zulip inquisitivecrystal (Aug 01 2021 at 04:05):

Ahh, figured it out.

view this post on Zulip inquisitivecrystal (Aug 01 2021 at 04:05):

Sorry to bother y'all!

view this post on Zulip Notification Bot (Aug 01 2021 at 04:05):

inquisitivecrystal has marked this topic as resolved.

view this post on Zulip Noah Lev (Aug 06 2021 at 22:18):

By the way, what was the solution you came up with? I've never managed to get dbg! to work within rustdoc—I always use debug! (which is a logging macro I think provided by tracing).

view this post on Zulip Joshua Nelson (Aug 06 2021 at 23:05):

That's really strange, dbg should work fine

view this post on Zulip Noah Lev (Aug 06 2021 at 23:33):

Hmm, maybe my config.toml is configured such that the output is being swallowed or something...

view this post on Zulip Joshua Nelson (Aug 07 2021 at 05:14):

There should be no possible way to configure that. Dbg writes directly to stderr.

view this post on Zulip GuillaumeGomez (Aug 07 2021 at 11:53):

dbg! only works on debug builds, maybe you're building in release mode?

view this post on Zulip Joshua Nelson (Aug 07 2021 at 13:06):

@GuillaumeGomez that is not the case, it works unconditionally

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

I never saw a dbg! statement when I debugged rustdoc :-/

view this post on Zulip Joshua Nelson (Aug 07 2021 at 13:06):

You're thinking of debug! which is controlled by debug-logging and off by default in release mode

view this post on Zulip Joshua Nelson (Aug 07 2021 at 13:07):

@GuillaumeGomez yes, because they get removed before merging because they log unconditionally

view this post on Zulip GuillaumeGomez (Aug 07 2021 at 13:07):

no I meant when I added myself for tests

view this post on Zulip GuillaumeGomez (Aug 07 2021 at 13:08):

Maybe it's worth checking if I didn't change the local config somehow for rustdoc...

view this post on Zulip Joshua Nelson (Aug 07 2021 at 13:08):

Are you sure the test suite wasn't just hiding the output? dbg! goes through the exact same output as eprintln!

view this post on Zulip Joshua Nelson (Aug 07 2021 at 13:08):

@GuillaumeGomez my whole point is that hiding the output through config.toml shouldn't be possible

view this post on Zulip GuillaumeGomez (Aug 07 2021 at 13:09):

Hum, that might be it. And I was simply thinking that they maybe updated their cargo.toml

view this post on Zulip Noah Lev (Aug 09 2021 at 20:53):

I just tested it, and dbg! does work for me! I'm not sure why it hadn't worked before, but I'm glad it does now.

view this post on Zulip inquisitivecrystal (Aug 14 2021 at 06:57):

I'm sorry, I wish I saw this sooner. The problem I had is that it seems that rustdoc won't rerun if you add a dbg! somewhere, so I had to clean the old doc build to get rustdoc to rerun. Otherwise, it seemed like it was just giving me cached output from a previous run. I don't know if that was the actual problem, but cleaning the old docs seemed like it fixed it.

view this post on Zulip inquisitivecrystal (Aug 14 2021 at 06:57):

I could just be totally wrong though.

view this post on Zulip Joshua Nelson (Aug 14 2021 at 14:27):

That seems possible. I try to avoid cargo altogether when modifying rustdoc, I find it pretty hard to predict when it will rerun the binary

view this post on Zulip Joshua Nelson (Aug 14 2021 at 14:27):

Especially since it doesn't notice when the binary changes on disk


Last updated: Oct 11 2021 at 22:34 UTC