From 5bc76873517d152fc5753c28059b247daabbf341 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 4 Jan 2024 20:20:07 +0100 Subject: [PATCH] Add regression test for jump to def static method calls --- .../rustdoc/check-source-code-urls-to-def.rs | 2 +- tests/rustdoc/jump-to-def-doc-links-calls.rs | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/rustdoc/jump-to-def-doc-links-calls.rs diff --git a/tests/rustdoc/check-source-code-urls-to-def.rs b/tests/rustdoc/check-source-code-urls-to-def.rs index b803c7e9e86c7..c31c579030e0d 100644 --- a/tests/rustdoc/check-source-code-urls-to-def.rs +++ b/tests/rustdoc/check-source-code-urls-to-def.rs @@ -62,7 +62,7 @@ pub trait AnotherTrait2 {} // @has - '//pre[@class="rust"]//a[@href="#61"]' 'AnotherTrait2' pub fn foo4() { - let x: Vec = Vec::new(); + let x: Vec<&dyn AnotherTrait2> = Vec::new(); } // @has - '//pre[@class="rust"]//a[@href="../../foo/primitive.bool.html"]' 'bool' diff --git a/tests/rustdoc/jump-to-def-doc-links-calls.rs b/tests/rustdoc/jump-to-def-doc-links-calls.rs new file mode 100644 index 0000000000000..549d068528e25 --- /dev/null +++ b/tests/rustdoc/jump-to-def-doc-links-calls.rs @@ -0,0 +1,27 @@ +// compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +// @has 'src/foo/jump-to-def-doc-links-calls.rs.html' + +// @has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' +pub struct Bar; + +impl std::default::Default for Bar { + // @has - '//a[@href="#20-22"]' 'Self::new' + fn default() -> Self { + Self::new() + } +} + +// @has - '//a[@href="#8"]' 'Bar' +impl Bar { + // @has - '//a[@href="#24-26"]' 'Self::bar' + pub fn new()-> Self { + Self::bar() + } + + pub fn bar() -> Self { + Self + } +}