diff --git a/src/test/rustdoc-gui/source-anchor-scroll.goml b/src/test/rustdoc-gui/source-anchor-scroll.goml index 4e51c8dcac0af..b82c67c92a272 100644 --- a/src/test/rustdoc-gui/source-anchor-scroll.goml +++ b/src/test/rustdoc-gui/source-anchor-scroll.goml @@ -7,11 +7,11 @@ size: (600, 800) // We check that the scroll is at the top first. assert-property: ("html", {"scrollTop": "0"}) -click: '//a[text() = "barbar"]' +click: '//a[text() = "barbar" and @href="../../src/link_to_definition/lib.rs.html#4-6"]' assert-property: ("html", {"scrollTop": "125"}) -click: '//a[text() = "bar"]' +click: '//a[text() = "bar" and @href="../../src/link_to_definition/lib.rs.html#27-35"]' assert-property: ("html", {"scrollTop": "166"}) -click: '//a[text() = "sub_fn"]' +click: '//a[text() = "sub_fn" and @href="../../src/link_to_definition/lib.rs.html#1-3"]' assert-property: ("html", {"scrollTop": "53"}) // We now check that clicking on lines doesn't change the scroll diff --git a/src/test/rustdoc/check-source-code-urls-to-def.rs b/src/test/rustdoc/check-source-code-urls-to-def.rs index 12c5df2871cf5..c24834cb99731 100644 --- a/src/test/rustdoc/check-source-code-urls-to-def.rs +++ b/src/test/rustdoc/check-source-code-urls-to-def.rs @@ -28,11 +28,11 @@ impl Foo { fn babar() {} -// @has - '//a/@href' '/struct.String.html' +// @has - '//a/@href' '/string.rs.html' // @has - '//a/@href' '/primitive.u32.html' // @has - '//a/@href' '/primitive.str.html' // @count - '//a[@href="../../src/foo/check-source-code-urls-to-def.rs.html#23"]' 5 -// @has - '//a[@href="../../source_code/struct.SourceCode.html"]' 'source_code::SourceCode' +// @has - '//a[@href="../../src/source_code/source_code.rs.html#1"]' 'source_code::SourceCode' pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) { let x = 12; let y: Foo = Foo; diff --git a/src/test/rustdoc/jump-to-def-doc-links.rs b/src/test/rustdoc/jump-to-def-doc-links.rs new file mode 100644 index 0000000000000..014d5803299cb --- /dev/null +++ b/src/test/rustdoc/jump-to-def-doc-links.rs @@ -0,0 +1,51 @@ +// compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +// @has 'src/foo/jump-to-def-doc-links.rs.html' + +// @has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' +// @has - '//a[@href="../../foo/struct.Foo.html"]' 'Foo' +pub struct Bar; pub struct Foo; + +// @has - '//a[@href="../../foo/enum.Enum.html"]' 'Enum' +pub enum Enum { + Variant1(String), + Variant2(u8), +} + +// @has - '//a[@href="../../foo/struct.Struct.html"]' 'Struct' +pub struct Struct { + pub a: u8, + b: Foo, +} + +impl Struct { + pub fn foo() {} + pub fn foo2(&self) {} + fn bar() {} + fn bar(&self) {} +} + +// @has - '//a[@href="../../foo/trait.Trait.html"]' 'Trait' +pub trait Trait { + fn foo(); +} + +impl Trait for Struct { + fn foo() {} +} + +// @has - '//a[@href="../../foo/union.Union.html"]' 'Union' +pub union Union { + pub a: u16, + pub f: u32, +} + +// @has - '//a[@href="../../foo/fn.bar.html"]' 'bar' +pub fn bar(b: Bar) { + let x = Foo; +} + +// @has - '//a[@href="../../foo/bar/index.html"]' 'bar' +pub mod bar {}