diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-02-28 16:04:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-28 16:04:52 +0100 |
| commit | b609afeaf274f7c8a7b9ce8890834a5acc599e53 (patch) | |
| tree | 745dcd1b2e94b96a50e7cb3b4e3e6bdc06bd12e6 | |
| parent | 796af693add1ce7eb1abaebc1d94ceb1887fa51b (diff) | |
| parent | 4dd05e642403451fbe6b8db8845b2d04f0a14bbd (diff) | |
| download | rust-b609afeaf274f7c8a7b9ce8890834a5acc599e53.tar.gz rust-b609afeaf274f7c8a7b9ce8890834a5acc599e53.zip | |
Rollup merge of #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``
| -rw-r--r-- | src/librustdoc/html/format.rs | 2 | ||||
| -rw-r--r-- | tests/rustdoc/auxiliary/jump-to-def-macro.rs | 6 | ||||
| -rw-r--r-- | tests/rustdoc/jump-to-def-macro.rs | 15 |
3 files changed, 22 insertions, 1 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 973036a4098..afd5eb42d01 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -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("/") ) diff --git a/tests/rustdoc/auxiliary/jump-to-def-macro.rs b/tests/rustdoc/auxiliary/jump-to-def-macro.rs new file mode 100644 index 00000000000..f442b9461e8 --- /dev/null +++ b/tests/rustdoc/auxiliary/jump-to-def-macro.rs @@ -0,0 +1,6 @@ +#[macro_export] +macro_rules! symbols { + ($name:ident = $value:expr) => { + pub const $name: isize = $value; + } +} diff --git a/tests/rustdoc/jump-to-def-macro.rs b/tests/rustdoc/jump-to-def-macro.rs new file mode 100644 index 00000000000..e8e97a442dd --- /dev/null +++ b/tests/rustdoc/jump-to-def-macro.rs @@ -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 +} |
