rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.17k stars 12.8k forks source link

rustdoc: Bad handling of proc_macro's re-exported via use_extern_macros #49553

Closed Nemo157 closed 5 years ago

Nemo157 commented 6 years ago

If you define a proc-macro in one crate, then re-export it from another crate via the use_extern_macros feature the resulting documentation does not link to the macro correctly, and the tooltip has some weird details displayed in it:

link: ../proc_macro_re_export_proc_macro/macro.%7B%7BGlobalMetaData::Krate%7D%7D.html

screen shot 2018-04-01 at 11 27 56 am

QuietMisdreavus commented 6 years ago

Still broken, looks like. Seems we'll need to properly document proc-macros, and handle their re-export, now.

Something that strikes me as odd is that the original crate shows the proc-macro as a function, and it's only when it's re-exported is it seen as a macro:

image

I think we'll need to handle the #[proc_macro_attribute] (and other proc-macro declaration attributes) when displaying these items. Then we'll need to see what happens when we get these as re-exports. I'm not too surprised that it still appears as a re-export, but i am curious what is causing it to mess up the link like that.

QuietMisdreavus commented 6 years ago

Update: It looks like the odd curly-brace segment of the link is gone, but the links are still broken because rustdoc is still treating proc-macros as functions in their source crate. Not sure what fixed that, but it means one less thing to figure out when fixing this for real.

QuietMisdreavus commented 6 years ago

I've opened https://github.com/rust-lang/rust/pull/54577 to make rustdoc properly document proc-macros, but there's a wrinkle that means their re-export is still a little awkward (though it's better than before). I wrote more about it in that PR.