From 23dcf455020807b36431e89784662d783c2f4361 Mon Sep 17 00:00:00 2001 From: binarycat Date: Mon, 24 Feb 2025 14:17:05 -0600 Subject: [PATCH 1/4] rustdoc: add known-bug test for issue #24686 --- .../deref/deref-methods-24686-target.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/rustdoc/deref/deref-methods-24686-target.rs diff --git a/tests/rustdoc/deref/deref-methods-24686-target.rs b/tests/rustdoc/deref/deref-methods-24686-target.rs new file mode 100644 index 0000000000000..171b3be7a5e76 --- /dev/null +++ b/tests/rustdoc/deref/deref-methods-24686-target.rs @@ -0,0 +1,23 @@ +//@ known-bug +#![crate_name = "foo"] + +// test for https://github.com/rust-lang/rust/issues/24686 +use std::ops::Deref; + +pub struct Foo(T); +impl Foo { + pub fn get_i32(&self) -> i32 { self.0 } +} +impl Foo { + pub fn get_u32(&self) -> u32 { self.0 } +} +//@ has foo/struct.Bar.html +//@ has - '//a[@href="#method.get_i32"]' 'get_i32' +//@ !has - '//a[@href="#method.get_u32"]' 'get_u32' +pub struct Bar(Foo); +impl Deref for Bar { + type Target = Foo; + fn deref(&self) -> &Foo { + &self.0 + } +} From 382b57724568d89d97b3fa7f76f38f65f4620e7e Mon Sep 17 00:00:00 2001 From: binarycat Date: Mon, 24 Feb 2025 14:37:18 -0600 Subject: [PATCH 2/4] known bug 24686: add `count` directive to ensure no extra methods --- tests/rustdoc/deref/deref-methods-24686-target.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/rustdoc/deref/deref-methods-24686-target.rs b/tests/rustdoc/deref/deref-methods-24686-target.rs index 171b3be7a5e76..8531d1200b706 100644 --- a/tests/rustdoc/deref/deref-methods-24686-target.rs +++ b/tests/rustdoc/deref/deref-methods-24686-target.rs @@ -14,6 +14,7 @@ impl Foo { //@ has foo/struct.Bar.html //@ has - '//a[@href="#method.get_i32"]' 'get_i32' //@ !has - '//a[@href="#method.get_u32"]' 'get_u32' +//@ count - '//a[@class="method"]' 1 pub struct Bar(Foo); impl Deref for Bar { type Target = Foo; From 4a4383e07bf6bedb03bad26193572e830caa9d6e Mon Sep 17 00:00:00 2001 From: binarycat Date: Mon, 24 Feb 2025 15:16:47 -0600 Subject: [PATCH 3/4] add argument to known-bug directive --- tests/rustdoc/deref/deref-methods-24686-target.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rustdoc/deref/deref-methods-24686-target.rs b/tests/rustdoc/deref/deref-methods-24686-target.rs index 8531d1200b706..5e052d6795fba 100644 --- a/tests/rustdoc/deref/deref-methods-24686-target.rs +++ b/tests/rustdoc/deref/deref-methods-24686-target.rs @@ -1,4 +1,4 @@ -//@ known-bug +//@ known-bug: #24686 #![crate_name = "foo"] // test for https://github.com/rust-lang/rust/issues/24686 From 39b5edad45e2b5145d11de5372d43e2d77ee1f04 Mon Sep 17 00:00:00 2001 From: binarycat Date: Mon, 24 Feb 2025 20:09:49 -0600 Subject: [PATCH 4/4] make test check-fail --- tests/rustdoc/deref/deref-methods-24686-target.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/rustdoc/deref/deref-methods-24686-target.rs b/tests/rustdoc/deref/deref-methods-24686-target.rs index 5e052d6795fba..7926298825697 100644 --- a/tests/rustdoc/deref/deref-methods-24686-target.rs +++ b/tests/rustdoc/deref/deref-methods-24686-target.rs @@ -1,4 +1,5 @@ //@ known-bug: #24686 +//@ run-fail #![crate_name = "foo"] // test for https://github.com/rust-lang/rust/issues/24686 @@ -14,7 +15,7 @@ impl Foo { //@ has foo/struct.Bar.html //@ has - '//a[@href="#method.get_i32"]' 'get_i32' //@ !has - '//a[@href="#method.get_u32"]' 'get_u32' -//@ count - '//a[@class="method"]' 1 +//@ count - '//a[@class="fn"]' 1 pub struct Bar(Foo); impl Deref for Bar { type Target = Foo;