Stream: rustdoc

Topic: Difference between HIR and the rustdoc IR


view this post on Zulip cjgillot (Dec 24 2020 at 10:44):

@Joshua Nelson : I saw you submitted several PRs which reduce the amount of data in the rustdoc IR.
Sorry if this is a silly question: why doesn't rustdoc use the HIR directly?

view this post on Zulip GuillaumeGomez (Dec 24 2020 at 12:22):

We need data to be formatted (or "cleaned" haha) to then be able to render the docs. We need to do it on top of HIR. However, we are now removing more and more of those cleanups to move it where we need them instead of doing it for everything by default. I hope that answers your question?

view this post on Zulip Joshua Nelson (Dec 24 2020 at 13:43):

@cjgillot IMO it should just use the HIR

view this post on Zulip Joshua Nelson (Dec 24 2020 at 13:43):

But most of this was written in 2013 by one guy and people just wanted something that worked

view this post on Zulip Joshua Nelson (Dec 24 2020 at 13:44):

But yeah if you look at the doctree PRs most of them are getting rid of the IR in favor of using hir directly

view this post on Zulip Noah Lev (Dec 24 2020 at 23:44):

Joshua Nelson said:

But most of this was written in 2013 by one guy and people just wanted something that worked

Looks like this PR was where rustdoc was introduced: #1360. Just over 9 years ago, and only 200 lines of code! Rust looked so different back then.

view this post on Zulip Noah Lev (Dec 24 2020 at 23:45):

This is how imports and type definitions looked:

use std;
use rustc;

import option;
import option::{some, none};
import rustc::syntax::ast;
import rustc::syntax::codemap;
import rustc::syntax::parse::parser;
import rustc::syntax::print::pprust;
import rustc::syntax::visit;
import std::io;
import std::map;

type rustdoc = {
    ps: pprust::ps,
    w: io::writer
};

type fndoc = {
    brief: str,
    desc: option::t<str>,
    return: option::t<str>,
    args: map::hashmap<str, str>
};

view this post on Zulip Joshua Nelson (Dec 24 2020 at 23:48):

that's the original rustdoc

view this post on Zulip Joshua Nelson (Dec 24 2020 at 23:49):

the current rustdoc was originally called 'rustdoc_ng' https://github.com/rust-lang/rust/pull/9402

view this post on Zulip Noah Lev (Dec 24 2020 at 23:50):

Ah, really? I was using GitHub to navigate the history of src/librustdoc/lib.rs, so I might have made a mistake and missed that.

view this post on Zulip Joshua Nelson (Dec 24 2020 at 23:50):

github doesn't follow file renames

view this post on Zulip Noah Lev (Dec 24 2020 at 23:50):

Yes, I was manually going to the end of the history and then finding the file it was renamed from and continuing on.

view this post on Zulip Joshua Nelson (Dec 24 2020 at 23:50):

here's the original commit: https://github.com/rust-lang/rust/commit/268f3f0ff5d80544ca21d565354eae6d3e29fb91

view this post on Zulip Joshua Nelson (Dec 24 2020 at 23:51):

ah ok I found the issue - lib.rs exists in both rustdoc_ng and the original

view this post on Zulip Joshua Nelson (Dec 24 2020 at 23:51):

if you follow core.rs instead it works

view this post on Zulip Noah Lev (Dec 24 2020 at 23:51):

Ah, the old squiggly Box :)


Last updated: Oct 11 2021 at 22:34 UTC