rustc-dev-guide icon indicating copy to clipboard operation
rustc-dev-guide copied to clipboard

Add logging in rustc itself that links to the dev-guide

Open jyn514 opened this issue 5 years ago • 5 comments

It would really cool if, among the myriad other logging in rustc, we could also have 'dev-guide logging'. The idea is that you could have RUSTC_LOG=[rustc_dev_guide]=info, which shows logging from all crates that has a rustc_dev_guide span. I'm imagining something like this:

$ RUSTC_LOG=[rustc_dev_guide]=info rustc x.rs
INFO rustc_query_system[rustc_dev_guide] See https://rustc-dev-guide.rust-lang.org/query.html for more information about queries
INFO rustc_metadata[rustc_dev_guide] See https://rustc-dev-guide.rust-lang.org/serialization.html for more information about serialization in rustc

cc @hawkw - do you know if it's currently possible to have a span without a target? I'd hate to have to specify all 50 rustc_* crates by hand. cc @igaray - I think you said you had a partial prototype for this?

jyn514 avatar Nov 10 '20 22:11 jyn514

Why not just have links to the dev guide in the compiler docs? I'm not sure if I see how this would be useful.

camelid avatar Nov 10 '20 23:11 camelid

@camelid that requires you to know ahead of time how to find the compiler docs, and which modules are relevant. This would let you say 'give me all the relevant info' at once.

That said, maybe it's not much better than just browsing through https://rustc-dev-guide.rust-lang.org/ :/

jyn514 avatar Nov 11 '20 00:11 jyn514

Why would someone think to run that command though? It seems much more likely they would just look through the dev-guide or the compiler docs.

camelid avatar Nov 11 '20 00:11 camelid

I think it makes more sense to have a page in the dev-guide that has a table that shows each theoretical part of the compiler (parser, type-checker, optimizer), the location in the source code (e.g., rustc_mir::borrow_check), and the chapter in the dev-guide.

camelid avatar Nov 11 '20 00:11 camelid

@igaray what do you think?

jyn514 avatar Nov 11 '20 00:11 jyn514