summary refs log tree commit diff
path: root/tests/rustdoc
diff options
context:
space:
mode:
authorbinarycat <binarycat@envs.net>2025-03-16 15:42:04 -0500
committerbinarycat <binarycat@envs.net>2025-03-22 12:47:05 -0500
commitb46412f6d7fde0c24780b0808aa7aefbc18d9e1e (patch)
tree97d04d722b6eac31dd023b54928a128b717bfd58 /tests/rustdoc
parentd497e43a1664eaad5e5850f5f8c11c9e16f5ef66 (diff)
downloadrust-b46412f6d7fde0c24780b0808aa7aefbc18d9e1e.tar.gz
rust-b46412f6d7fde0c24780b0808aa7aefbc18d9e1e.zip
rustdoc: be more strict about "Methods from Deref"
hack: is_doc_subtype_of always returns true for TyAlias

it's worth noting that this function is only used in
the handling of "Methods from Deref", and we were previously
assuming all generic parameters were meaningless,
so this is still an improvment from the status quo.

this change means that we will have strictly less false positives
without adding any new false negitives.

Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
Diffstat (limited to 'tests/rustdoc')
-rw-r--r--tests/rustdoc/deref/deref-methods-24686-target.rs27
1 files changed, 27 insertions, 0 deletions
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 00000000000..e019488ca80
--- /dev/null
+++ b/tests/rustdoc/deref/deref-methods-24686-target.rs
@@ -0,0 +1,27 @@
+#![crate_name = "foo"]
+
+// test for https://github.com/rust-lang/rust/issues/24686
+use std::ops::Deref;
+
+pub struct Foo<T>(T);
+impl Foo<i32> {
+    pub fn get_i32(&self) -> i32 { self.0 }
+}
+impl Foo<u32> {
+    pub fn get_u32(&self) -> u32 { self.0 }
+}
+
+// Note that the same href is used both on the method itself,
+// and on the sidebar items.
+//@ has foo/struct.Bar.html
+//@ has - '//a[@href="#method.get_i32"]' 'get_i32'
+//@ !has - '//a[@href="#method.get_u32"]' 'get_u32'
+//@ count - '//ul[@class="block deref-methods"]//a' 1
+//@ count - '//a[@href="#method.get_i32"]' 2
+pub struct Bar(Foo<i32>);
+impl Deref for Bar {
+    type Target = Foo<i32>;
+    fn deref(&self) -> &Foo<i32> {
+        &self.0
+    }
+}