Skip to content

Commit

Permalink
Rollup merge of rust-lang#121680 - GuillaumeGomez:foreign-macro-jump-…
Browse files Browse the repository at this point in the history
…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``
  • Loading branch information
matthiaskrgr authored Feb 27, 2024
2 parents 9b84cbf + 4dd05e6 commit a45045d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ fn generate_macro_def_id_path(
ExternalLocation::Local => {
// `root_path` always end with a `/`.
format!(
"{root_path}{crate_name}/{path}",
"{root_path}{path}",
root_path = root_path.unwrap_or(""),
path = path.iter().map(|p| p.as_str()).join("/")
)
Expand Down
6 changes: 6 additions & 0 deletions tests/rustdoc/auxiliary/jump-to-def-macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[macro_export]
macro_rules! symbols {
($name:ident = $value:expr) => {
pub const $name: isize = $value;
}
}
15 changes: 15 additions & 0 deletions tests/rustdoc/jump-to-def-macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ aux-build:jump-to-def-macro.rs
//@ build-aux-docs
//@ compile-flags: -Zunstable-options --generate-link-to-definition

#![crate_name = "foo"]

// @has 'src/foo/jump-to-def-macro.rs.html'

#[macro_use]
extern crate jump_to_def_macro;

// @has - '//a[@href="../../jump_to_def_macro/macro.symbols.html"]' 'symbols!'
symbols! {
A = 12
}

0 comments on commit a45045d

Please sign in to comment.