-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Links in doc comments to proc_macro_attribute functions cause rustdoc panic #55399
Comments
Same stack trace as #54100. |
@euclio Good find. That one is also a procedural macro, might be appropriate to add a |
Doing a little digging... The first rustdoc code in that stack trace is this part in rust/src/librustdoc/passes/collect_intra_doc_links.rs Lines 432 to 437 in 9690917
The call to rust/src/librustc_resolve/macros.rs Lines 295 to 302 in 9690917
In effect: proc-macros are not available to the crate that defines them. This makes sense in terms of making sure they don't infinitely recurse, but leaves rustdoc out to dry when all it wants is to make sure that the macro in question is a Macros 2.0 macro. I'm waiting on a build right now, but we may be able to skip the call to |
Update: Skipping the call to |
…=GuillaumeGomez rustdoc: fix ICE from loading proc-macro stubs Fixes rust-lang#55399 When trying to resolve a macro, rustdoc first tries to load it from the resolver to see whether it's a Macros 2.0 macro, so it can return that Def before looking for any other kind of macro. However, this becomes a problem when you try to load proc-macros: since you can't use a proc-macro inside its own crate, this lookup also fails when attempting to link to it. However, we have a hint that this lookup will fail: Macros which are actually `ProcMacroStub`s will fail the lookup, so we can use that information to skip loading the macro. Rustdoc will then happily check `resolve.all_macros`, which will return a usable Def that we can link to.
The following code builds successfully but causes a compiler panic when running
cargo doc
:src/lib.rs
Cargo.toml
Compiler error
Toolchain
Changing
function_name
to another name, either in the doc comment or the actual function name (but not both), causescargo doc
to succeed with a warning that the link cannot be resolved, as expected.Using a normal public function in a non-proc_macro library also does not cause a panic, e.g.
The text was updated successfully, but these errors were encountered: