rust-lang/rust

Intra-doc links doesn't work for proc macros

Manishearth opened this issue · 4 comments

Part of #43466

intra-doc links is incapable of linking to proc macros

You can reproduce this both with and without the pub use

Reproduction

Cargo.toml

[package]
name = "repro"
version = "0.1.0"
edition = "2018"

[dependencies]
the-macro = { path = "the-macro" }

src/lib.rs

//! Please check out the procedural macro:
//!
//! - [Repro]
//! - [Repro][]
//! - [Repro](Repro)
//!
//! - [Repro!]
//! - [Repro!][]
//! - [Repro!](Repro!)
//!
//! - [macro Repro]
//! - [macro Repro][]
//! - [macro Repro](macro@Repro)
//!
//! - [macro Repro!]
//! - [macro Repro!][]
//! - [macro Repro!](macro@Repro!)

pub use the_macro::Repro;

the-macro/Cargo.toml

[package]
name = "the-macro"
version = "0.1.0"
edition = "2018"

[lib]
proc-macro = true

[dependencies]

the-macro/src/lib.rs

use proc_macro::TokenStream;

#[proc_macro_derive(Repro)]
pub fn repro_derive(input: TokenStream) -> TokenStream {
    input
}

Originally posted by @shepmaster in #43466 (comment)

This is probably because macro_resolve() doesn't fall back to resolve_str_path for non-bang macros

Right, I wrote this code in 2017, pre proc macro resolution, and MBEs resolve differently from proc macros.

My guess was right, I have a fix

Got a fix at #73183