Skip to content

Commit 489226e

Browse files
authored
Rollup merge of rust-lang#121680 - GuillaumeGomez:foreign-macro-jump-to-def, r=notriddle
Fix link generation for foreign macro in jump to definition feature The crate name is already added to the link so it shouldn't be added a second time for local foreign macros. r? `@notriddle`
2 parents 17e9709 + 4dd05e6 commit 489226e

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Diff for: src/librustdoc/html/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ fn generate_macro_def_id_path(
575575
ExternalLocation::Local => {
576576
// `root_path` always end with a `/`.
577577
format!(
578-
"{root_path}{crate_name}/{path}",
578+
"{root_path}{path}",
579579
root_path = root_path.unwrap_or(""),
580580
path = path.iter().map(|p| p.as_str()).join("/")
581581
)

Diff for: tests/rustdoc/auxiliary/jump-to-def-macro.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[macro_export]
2+
macro_rules! symbols {
3+
($name:ident = $value:expr) => {
4+
pub const $name: isize = $value;
5+
}
6+
}

Diff for: tests/rustdoc/jump-to-def-macro.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ aux-build:jump-to-def-macro.rs
2+
//@ build-aux-docs
3+
//@ compile-flags: -Zunstable-options --generate-link-to-definition
4+
5+
#![crate_name = "foo"]
6+
7+
// @has 'src/foo/jump-to-def-macro.rs.html'
8+
9+
#[macro_use]
10+
extern crate jump_to_def_macro;
11+
12+
// @has - '//a[@href="../../jump_to_def_macro/macro.symbols.html"]' 'symbols!'
13+
symbols! {
14+
A = 12
15+
}

0 commit comments

Comments
 (0)