diff --git a/tests/rustdoc/jump-to-def/assoc-items.rs b/tests/rustdoc/jump-to-def/assoc-items.rs index 01beb8dd7618..a434fa7e6053 100644 --- a/tests/rustdoc/jump-to-def/assoc-items.rs +++ b/tests/rustdoc/jump-to-def/assoc-items.rs @@ -26,8 +26,9 @@ impl C { pub fn wat() {} } -//@ has - '//a[@href="{{channel}}/core/fmt/macros/macro.Debug.html"]' 'Debug' -//@ has - '//a[@href="{{channel}}/core/cmp/macro.PartialEq.html"]' 'PartialEq' +// These two links must not change and in particular must contain `/derive.`! +//@ has - '//a[@href="{{channel}}/core/fmt/macros/derive.Debug.html"]' 'Debug' +//@ has - '//a[@href="{{channel}}/core/cmp/derive.PartialEq.html"]' 'PartialEq' #[derive(Debug, PartialEq)] pub struct Bar; impl Trait for Bar { diff --git a/tests/rustdoc/jump-to-def/derive-macro.rs b/tests/rustdoc/jump-to-def/derive-macro.rs new file mode 100644 index 000000000000..24deac047883 --- /dev/null +++ b/tests/rustdoc/jump-to-def/derive-macro.rs @@ -0,0 +1,24 @@ +// This test ensures that the same link is generated in both intra-doc links +// and in jump to def links. + +//@ compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +// First we check intra-doc links. +//@ has 'foo/struct.Bar.html' +//@ has - '//a[@href="{{channel}}/core/fmt/macros/derive.Debug.html"]' 'Debug' +//@ has - '//a[@href="{{channel}}/core/cmp/derive.PartialEq.html"]' 'PartialEq' + +// We also check the "title" attributes. +//@ has - '//a[@href="{{channel}}/core/fmt/macros/derive.Debug.html"]/@title' 'derive core::fmt::macros::Debug' +//@ has - '//a[@href="{{channel}}/core/cmp/derive.PartialEq.html"]/@title' 'derive core::cmp::PartialEq' + +// Then we check that they are the same in jump to def. + +/// [Debug][derive@Debug] and [PartialEq][derive@PartialEq] +//@ has 'src/foo/derive-macro.rs.html' +//@ has - '//a[@href="{{channel}}/core/fmt/macros/derive.Debug.html"]' 'Debug' +//@ has - '//a[@href="{{channel}}/core/cmp/derive.PartialEq.html"]' 'PartialEq' +#[derive(Debug, PartialEq)] +pub struct Bar;